Skip to content

Commit f7cc015

Browse files
numpydoc build for base.py in Baseline class (#96)
* numpydoc build for base.py * [pre-commit.ci] auto fixes from pre-commit hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent bb71671 commit f7cc015

File tree

1 file changed

+63
-40
lines changed

1 file changed

+63
-40
lines changed

Diff for: src/diffpy/srmise/baselines/base.py

+63-40
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,19 @@ class BaselineFunction(BaseFunction):
2828
2929
Class members
3030
-------------
31-
parameterdict: A dictionary mapping string keys to their index in the
32-
sequence of parameters. These keys apply only to
33-
the default "internal" format.
34-
parformats: A sequence of strings defining what formats are recognized
35-
by a baseline function.
36-
default_formats: A dictionary which maps the strings "default_input" and
37-
"default_output" to strings also appearing in parformats.
38-
"default_input"-> format used internally within the class
39-
"default_output"-> Default format to use when converting
40-
parameters for outside use.
31+
parameterdict: dict
32+
The dictionary mapping string keys to their index in the
33+
sequence of parameters. These keys apply only to
34+
the default "internal" format.
35+
parformats: array-like
36+
The sequence of strings defining what formats are recognized
37+
by a baseline function.
38+
default_formats: dict
39+
The dictionary which maps the strings "default_input" and
40+
"default_output" to strings also appearing in parformats.
41+
"default_input"-> format used internally within the class
42+
"default_output"-> Default format to use when converting
43+
parameters for outside use.
4144
4245
Class methods (implemented by inheriting classes)
4346
-------------------------------------------------
@@ -70,19 +73,25 @@ def __init__(
7073
):
7174
"""Set parameterdict defined by subclass
7275
73-
parameterdict: A dictionary mapping string keys to their index in a
74-
sequence of parameters for this BaselineFunction subclass.
75-
parformats: A sequence strings containing all allowed input/output
76-
formats defined for the peak function's parameters.
77-
default_formats: A dictionary mapping the string keys "internal" and
78-
"default_output" to formats from parformats.
79-
metadict: Dictionary mapping string keys to tuple (v, m) where v is an
80-
additional argument required by function, and m is a method
81-
whose string output recreates v when passed to eval().
82-
base: A basefunction subclass instance which this one decorates with
83-
additional functionality.
84-
Cache: A class (not instance) which implements caching of BaseFunction
85-
evaluations."""
76+
parameterdict : dict
77+
The dictionary mapping string keys to their index in a
78+
sequence of parameters for this BaselineFunction subclass.
79+
parformats : array-like
80+
The sequence strings containing all allowed input/output
81+
formats defined for the peak function's parameters.
82+
default_formats : dict
83+
The dictionary mapping the string keys "internal" and
84+
default_output" to formats from parformats.
85+
metadict: dict
86+
The dictionary mapping string keys to tuple (v, m) where v is an
87+
additional argument required by function, and m is a method
88+
whose string output recreates v when passed to eval().
89+
base : The basefunction subclass
90+
The basefunction subclass instance which this one decorates with
91+
additional functionality.
92+
Cache : class
93+
The class (not instance) which implements caching of BaseFunction
94+
evaluations."""
8695
BaseFunction.__init__(self, parameterdict, parformats, default_formats, metadict, base, Cache)
8796

8897
# "Virtual" class methods ####
@@ -111,30 +120,44 @@ class Baseline(ModelPart):
111120
"""Represents a baseline associated with a BaselineFunction subclass."""
112121

113122
def __init__(self, owner, pars, free=None, removable=False, static_owner=False):
114-
"""Set instance members.
115-
116-
owner: an instance of a BaselineFunction subclass
117-
pars: Sequence of parameters which define the baseline
118-
free: Sequence of Boolean variables. If False, the corresponding
119-
parameter will not be changed.
120-
removable: (False) Boolean determines whether the baseline can be removed.
121-
static_owner: (False) Whether or not the owner can be changed with
122-
changeowner()
123-
124-
Note that free and removable are not mutually exclusive. If any
125-
values are not free but removable=True then the entire baseline may be
126-
may be removed during peak extraction, but the held parameters for the
127-
baseline will remain unchanged until that point.
123+
"""Initialize the BaselineComponent instance with specified configurations.
124+
125+
Parameters
126+
----------
127+
owner : BaselineFunction subclass instance
128+
The owner object which is an instance of a subclass of BaselineFunction.
129+
pars : array-like
130+
The sequence of parameters defining the characteristics of the baseline.
131+
free : Sequence of bool, optional
132+
The sequence parallel to `pars` where each boolean value indicates whether
133+
the corresponding parameter is adjustable. If False, that parameter is fixed.
134+
Defaults to None, implying all parameters are free by default.
135+
removable : bool, optional
136+
A flag indicating whether the baseline can be removed during processing.
137+
Defaults to False.
138+
static_owner : bool, optional
139+
Determines if the owner of the baseline can be altered using the
140+
` changeowner()` method. Defaults to False.
141+
142+
Notes
143+
-----
144+
- The `free` and `removable` parameters are independent; a baseline can be marked
145+
as removable even if some of its parameters are fixed (`free` is False). In such
146+
cases, the baseline may be removed during peak extraction, but the fixed
147+
parameters will persist until removal.
128148
"""
129149
ModelPart.__init__(self, owner, pars, free, removable, static_owner)
130150

131151
@staticmethod
132152
def factory(baselinestr, ownerlist):
133153
"""Instantiate a Peak from a string.
134154
135-
Parameters:
136-
baselinestr: string representing Baseline
137-
ownerlist: List of BaseFunctions that owner is in
155+
Parameters
156+
----------
157+
baselinestr : str
158+
The string representing Baseline
159+
ownerlist : array-like
160+
The list of BaseFunctions that owner is in
138161
"""
139162

140163
data = baselinestr.strip().splitlines()

0 commit comments

Comments
 (0)