Skip to content

Commit 5ae4a97

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

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

RATapi/inputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ def append_data_background(data: np.array, background: np.array) -> np.array:
511511
if not np.allclose(data[:, 0], background[:, 0]):
512512
raise ValueError("The q-values of the data and background must be equal.")
513513

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

516516

517517
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)