@@ -369,18 +369,26 @@ class ModelCluster(object):
369
369
def __init__ (self , model , * args , ** kwds ):
370
370
"""Intialize explicitly, or from existing ModelCluster.
371
371
372
- Parameters [Explicit creation]
373
- model - Peaks object, or None->empty model
374
- baseline - Baseline object, or None->0
375
- r_data - Numpy array of r coordinates
376
- y_data - Numpy array of y values
377
- y_error - Numpy array of uncertainties in y
378
- cluster_slice - slice object defining the range of cluster. None->all data
379
- error_method - an ErrorEvaluator subclass
380
- peak_funcs - a sequence of PeakFunction instances
381
-
382
- Parameters [Creation from existing ModelCluster]
383
- model - ModelCluster instance, or sequence of ModelCluster instances
372
+ Parameters
373
+ ----------
374
+ model : (lists of) ModelCluster instance
375
+ The ModelCluster instances to be clustered.
376
+ If it is None, then a ModelCluster object is created.
377
+ baseline : Baseline object
378
+ The Baseline object, if it is None, set to 0.
379
+ r_data : array-like
380
+ The numpy array of r coordinates
381
+ y_data : array-like
382
+ The numpy array of y values
383
+ y_error : array-like
384
+ The numpy array of uncertainties in y
385
+ cluster_slice : slice object
386
+ The slice object defining the range of cluster. If the input is None,
387
+ then it will take the entire range.
388
+ error_method : ErrorEvaluator subclass
389
+ The error evaluator to use to calculate quality of model to data.
390
+ peak_funcs : a sequence of PeakFunction instances
391
+ The peak instances to use to calculate the cluster of data.
384
392
"""
385
393
self .last_fit_size = 0
386
394
self .slice = None
@@ -437,7 +445,13 @@ def addexternalpeaks(self, peaks):
437
445
"""Add peaks (and their value) to self.
438
446
439
447
Parameters
440
- peaks - A Peaks object
448
+ ----------
449
+ peaks : A Peaks object
450
+ The peaks to be added
451
+
452
+ Returns
453
+ -------
454
+ None
441
455
"""
442
456
self .replacepeaks (peaks )
443
457
self .y_data += peaks .value (self .r_data )
@@ -447,8 +461,9 @@ def writestr(self, **kwds):
447
461
"""Return partial string representation.
448
462
449
463
Keywords
450
- pfbaselist - List of peak function bases. Otherwise define list from self.
451
- blfbaselist - List of baseline function bases. Otherwise define list from self.
464
+ --------
465
+ pfbaselist - List of peak function bases. Otherwise, define list from self.
466
+ blfbaselist - List of baseline function bases.Otherwise, define list from self.
452
467
"""
453
468
from diffpy .srmise .basefunction import BaseFunction
454
469
@@ -524,8 +539,9 @@ def factory(mcstr, **kwds):
524
539
"""Create ModelCluster from string.
525
540
526
541
Keywords
527
- pfbaselist - List of peak function bases
528
- blfbaselist - List of baseline function bases
542
+ --------
543
+ pfbaselist : List of peak function bases
544
+ blfbaselist : List of baseline function bases
529
545
"""
530
546
from diffpy .srmise .basefunction import BaseFunction
531
547
@@ -696,8 +712,16 @@ def join_adjacent(m1, m2):
696
712
unchanged.
697
713
698
714
Parameters
699
- m1 - A ModelCluster
700
- m2 - A ModelCluster
715
+ ----------
716
+ m1 : ModelCluster instance
717
+ The first ModelCluster instance.
718
+ m2 : ModelCluster instance
719
+ The second ModelCluster instance.
720
+
721
+ Returns
722
+ -------
723
+ ModelCluster instance
724
+ The new ModelCluster instance between m1 and m2.
701
725
"""
702
726
# Check for members that must be shared.
703
727
if not (m1 .r_data is m2 .r_data ):
@@ -778,7 +802,17 @@ def join_adjacent(m1, m2):
778
802
)
779
803
780
804
def change_slice (self , new_slice ):
781
- """Change the slice which represents the extent of a cluster."""
805
+ """Change the slice which represents the extent of a cluster.
806
+
807
+ Parameters
808
+ ----------
809
+ new_slice : slice object
810
+ The new slice to change.
811
+
812
+ Returns
813
+ -------
814
+ None
815
+ """
782
816
old_slice = self .slice
783
817
self .slice = new_slice
784
818
self .r_cluster = self .r_data [new_slice ]
@@ -815,10 +849,16 @@ def npars(self, count_baseline=True, count_fixed=True):
815
849
"""Return number of parameters in model and baseline.
816
850
817
851
Parameters
818
- count_baseline - [True] Boolean determines whether or not to count
819
- parameters from baseline.
820
- count_fixed - [True] Boolean determines whether or not to include
821
- non-free parameters.
852
+ ----------
853
+ count_baseline : bool
854
+ The boolean determines whether to count parameters from baseline. Default is True.
855
+ count_fixed : bool
856
+ The boolean determines whether to include non-free parameters. Default is True.
857
+
858
+ Returns
859
+ -------
860
+ n : int
861
+ The number of parameters in model and baseline.
822
862
"""
823
863
n = self .model .npars (count_fixed = count_fixed )
824
864
if count_baseline and self .baseline is not None :
@@ -829,8 +869,15 @@ def replacepeaks(self, newpeaks, delslice=slice(0, 0)):
829
869
"""Replace peaks given by delslice by those in newpeaks.
830
870
831
871
Parameters
832
- newpeaks - Add each Peak in this Peaks to cluster.
833
- delslice - Existing peaks given by slice object are deleted.
872
+ ----------
873
+ newpeaks : Peak instance
874
+ The peak that id added to each existing peak to cluster.
875
+ delslice : Peak instance
876
+ The existing peaks given by slice object are deleted.
877
+
878
+ Returns
879
+ -------
880
+ None
834
881
"""
835
882
for p in self .model [delslice ]:
836
883
if not p .removable :
0 commit comments