Skip to content

Commit ed4394f

Browse files
committed
review fixes to docstrings and data backgrounds
1 parent b336f14 commit ed4394f

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

RATapi/inputs.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,6 @@ def make_input(project: RATapi.Project, controls: RATapi.Controls) -> tuple[Prob
126126
"background_parameters": "backgroundParams",
127127
"resolution_parameters": "resolutionParams",
128128
}
129-
checks_field = {
130-
"parameters": "params",
131-
"bulk_in": "bulkIns",
132-
"bulk_out": "bulkOuts",
133-
"scalefactors": "scalefactors",
134-
"domain_ratios": "domainRatios",
135-
"background_parameters": "backgroundParams",
136-
"resolution_parameters": "resolutionParams",
137-
}
138129

139130
prior_id = {"uniform": 1, "gaussian": 2, "jeffreys": 3}
140131

@@ -143,7 +134,7 @@ def make_input(project: RATapi.Project, controls: RATapi.Controls) -> tuple[Prob
143134
priors = Priors()
144135

145136
for class_list in RATapi.project.parameter_class_lists:
146-
setattr(checks, checks_field[class_list], [int(element.fit) for element in getattr(project, class_list)])
137+
setattr(checks, parameter_field[class_list], [int(element.fit) for element in getattr(project, class_list)])
147138
setattr(
148139
limits,
149140
parameter_field[class_list],
@@ -511,7 +502,7 @@ def append_data_background(data: np.array, background: np.array) -> np.array:
511502
if not np.allclose(data[:, 0], background[:, 0]):
512503
raise ValueError("The q-values of the data and background must be equal.")
513504

514-
return np.hstack((data, background[:, 1:]))
505+
return np.hstack((data, np.zeros((data.shape[0], 4 - data.shape[1])), background[:, 1:]))
515506

516507

517508
def make_controls(input_controls: RATapi.Controls) -> Control:

RATapi/models.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Background(Signal):
7777
type : TypeOptions
7878
The type of background (constant, function or data)
7979
source : str
80-
The source data for the background;
80+
The source of the background;
8181
- if type is 'constant', this should be the name of a background parameter.
8282
- if type is 'data', this should be the name of a dataset defined in `Project.data`.
8383
- if type is 'function', this should be the name of a custom function defined in `Project.custom_files`.
@@ -132,15 +132,16 @@ class Contrast(RATModel):
132132
The name of the bulk-out parameter which defines the SLD of the interface between the last
133133
layer and the environment.
134134
scalefactor : str
135+
The name of the scalefactor which defines how much the data for this contrast should be scaled.
135136
resolution : str
136137
The name of the instrument resolution for this contrast.
137138
resample : bool
138139
Whether adaptive resampling should be used for interface microslicing.
139140
model : list[str]
140141
If this is a standard layers model, this should be a list of layer names
141142
that make up the slab model for this contrast.
142-
For custom models, this should be a list of custom file names of the custom
143-
model functions.
143+
For custom models, this should be a list containing just the custom file name for the
144+
custom model function.
144145
145146
"""
146147

@@ -213,11 +214,13 @@ class ContrastWithRatio(RATModel):
213214
resample : bool
214215
Whether adaptive resampling should be used for interface microslicing.
215216
domain_ratio : str
217+
The name of the domain ratio parameter describing how the first domain should be weighted
218+
relative to the second.
216219
model : list[str]
217-
If this is a standard layers model, this should be a list of layer names
218-
that make up the slab model for this contrast.
219-
For custom models, this should be a list of custom file names of the custom
220-
model functions.
220+
If this is a standard layers model, this should be a list of the names of the two domain contrasts
221+
which make up the domain model for this contrast.
222+
For custom models, this should be a list containing just the custom file name for the
223+
custom model function.
221224
222225
"""
223226

@@ -302,7 +305,7 @@ class Data(RATModel, arbitrary_types_allowed=True):
302305
name : str
303306
The name of this dataset.
304307
data : np.ndarray[np.float64]
305-
The (x,y,z) data for this dataset, given as a Numpy array of three columns.
308+
The (x, y, error) data for this dataset, given as a Numpy array of three columns.
306309
data_range : list[float]
307310
simulation_range : list[float]
308311
@@ -405,10 +408,7 @@ class DomainContrast(RATModel):
405408
name : str
406409
The name of this domain contrast.
407410
model : list[str]
408-
If this is a standard layers model, this should be a list of layer names
409-
that make up the slab model for this contrast.
410-
For custom models, this should be a list of custom file names of the custom
411-
model functions.
411+
A list of layer names that make up the slab model for this contrast.
412412
413413
"""
414414

tests/test_inputs.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,16 @@ def test_append_data_background():
659659
background = np.array([[1, 10, 11], [4, 12, 13], [7, 14, 15]])
660660

661661
result = RATapi.inputs.append_data_background(data, background)
662-
np.testing.assert_allclose(result, np.array([[1, 2, 3, 10, 11], [4, 5, 6, 12, 13], [7, 8, 9, 14, 15]]))
662+
np.testing.assert_allclose(result, np.array([[1, 2, 3, 0, 10, 11], [4, 5, 6, 0, 12, 13], [7, 8, 9, 0, 14, 15]]))
663+
664+
665+
def test_append_data_background_res():
666+
"""Test that background data is correctly added to contrast data when a resolution is in the data."""
667+
data = np.array([[1, 2, 3, 4], [4, 5, 6, 6], [7, 8, 9, 72]])
668+
background = np.array([[1, 10, 11], [4, 12, 13], [7, 14, 15]])
669+
670+
result = RATapi.inputs.append_data_background(data, background)
671+
np.testing.assert_allclose(result, np.array([[1, 2, 3, 4, 10, 11], [4, 5, 6, 6, 12, 13], [7, 8, 9, 72, 14, 15]]))
663672

664673

665674
def test_append_data_background_error():

0 commit comments

Comments
 (0)