Skip to content

Commit fb7bbaa

Browse files
authored
Rename delta to eps for float-based assertions (#1)
* Rename `delta` to `eps` for float-based assertions * Fix tests
1 parent 00485cc commit fb7bbaa

3 files changed

Lines changed: 36 additions & 19 deletions

File tree

lib/galaxy/tool_util/verify/asserts/image.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def assert_has_image_mean_intensity(
156156
output_bytes: bytes,
157157
channel: Optional[Union[int, str]] = None,
158158
value: Optional[Union[float, str]] = None,
159-
delta: Union[float, str] = 0.01,
159+
eps: Union[float, str] = 0.01,
160160
min: Optional[Union[float, str]] = None,
161161
max: Optional[Union[float, str]] = None,
162162
) -> None:
@@ -167,7 +167,7 @@ def assert_has_image_mean_intensity(
167167
_assert_float(
168168
actual=im_arr.mean(),
169169
label="mean intensity",
170-
tolerance=delta,
170+
tolerance=eps,
171171
expected=value,
172172
range_min=min,
173173
range_max=max,
@@ -178,7 +178,7 @@ def assert_has_image_center_of_mass(
178178
output_bytes: bytes,
179179
channel: Optional[Union[int, str]] = None,
180180
point: Optional[Union[Tuple[float, float], str]] = None,
181-
delta: Union[float, str] = 0.01,
181+
eps: Union[float, str] = 0.01,
182182
) -> None:
183183
"""
184184
Asserts the specified output is an image and has the specified center of mass.
@@ -193,8 +193,8 @@ def assert_has_image_center_of_mass(
193193
actual_center_of_mass = _compute_center_of_mass(im_arr)
194194
distance = numpy.linalg.norm(numpy.subtract(point, actual_center_of_mass))
195195
assert distance <= float(
196-
delta
197-
), f"Wrong center of mass: {actual_center_of_mass} (expected {point}, distance: {distance}, delta: {delta})"
196+
eps
197+
), f"Wrong center of mass: {actual_center_of_mass} (expected {point}, distance: {distance}, eps: {eps})"
198198

199199

200200
def _get_image_labels(
@@ -271,7 +271,7 @@ def assert_has_image_mean_object_size(
271271
labels: Optional[Union[str, List[int]]] = None,
272272
exclude_labels: Optional[Union[str, List[int]]] = None,
273273
value: Optional[Union[float, str]] = None,
274-
delta: Union[float, str] = 0.01,
274+
eps: Union[float, str] = 0.01,
275275
min: Optional[Union[float, str]] = None,
276276
max: Optional[Union[float, str]] = None,
277277
) -> None:
@@ -283,7 +283,7 @@ def assert_has_image_mean_object_size(
283283
_assert_float(
284284
actual=actual_mean_object_size,
285285
label="mean object size",
286-
tolerance=delta,
286+
tolerance=eps,
287287
expected=value,
288288
range_min=min,
289289
range_max=max,

lib/galaxy/tool_util/xsd/galaxy.xsd

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2858,7 +2858,7 @@ $attribute_list::5
28582858
<xs:annotation>
28592859
<xs:documentation xml:lang="en"><![CDATA[
28602860
Asserts the output is an image and has a specific mean intensity value of ``value``
2861-
plus/minus ``delta`` (e.g., ``<image_has_mean_intensity value="0.83" />``).
2861+
plus/minus ``eps`` (e.g., ``<image_has_mean_intensity value="0.83" />``).
28622862
Alternatively the range of the expected mean intensity value can be specified by ``min`` and/or ``max``.
28632863
28642864
$attribute_list::5
@@ -2870,9 +2870,9 @@ $attribute_list::5
28702870
<xs:documentation xml:lang="en">The required mean value of the image intensities.</xs:documentation>
28712871
</xs:annotation>
28722872
</xs:attribute>
2873-
<xs:attribute name="delta" type="xs:float" use="optional" default="0.01">
2873+
<xs:attribute name="eps" type="xs:float" use="optional" default="0.01">
28742874
<xs:annotation>
2875-
<xs:documentation xml:lang="en">The absolute tolerance to be used for ``value`` (defaults to ``0.01``). The observed mean value of the image intensities has to be in the range ``value +- delta``.</xs:documentation>
2875+
<xs:documentation xml:lang="en">The absolute tolerance to be used for ``value`` (defaults to ``0.01``). The observed mean value of the image intensities has to be in the range ``value +- eps``.</xs:documentation>
28762876
</xs:annotation>
28772877
</xs:attribute>
28782878
<xs:attribute name="min" type="xs:float" use="optional">
@@ -2895,7 +2895,7 @@ $attribute_list::5
28952895
<xs:annotation>
28962896
<xs:documentation xml:lang="en"><![CDATA[
28972897
Asserts the output is an image and has a specific center of mass of ``point``,
2898-
or has an Euclidean distance of ``delta`` or less to that point (e.g.,
2898+
or has an Euclidean distance of ``eps`` or less to that point (e.g.,
28992899
``<has_image_center_of_mass point="511.07, 223.34" />``).
29002900
29012901
$attribute_list::5
@@ -2907,7 +2907,7 @@ $attribute_list::5
29072907
<xs:documentation xml:lang="en">The required center of mass of the image intensities (horizontal and vertical coordinate, separated by a comma).</xs:documentation>
29082908
</xs:annotation>
29092909
</xs:attribute>
2910-
<xs:attribute name="delta" type="xs:float" use="optional" default="0.01">
2910+
<xs:attribute name="eps" type="xs:float" use="optional" default="0.01">
29112911
<xs:annotation>
29122912
<xs:documentation xml:lang="en">The maximum allowed Euclidean distance to the required center of mass (defaults to ``0.01``).</xs:documentation>
29132913
</xs:annotation>
@@ -2969,8 +2969,9 @@ $attribute_list::5
29692969
<xs:complexType name="AssertHasImageMeanObjectSize">
29702970
<xs:annotation>
29712971
<xs:documentation xml:lang="en"><![CDATA[
2972-
Asserts the output is an image with labeled objects which have the specified mean size (number of pixels, e.g.,
2973-
``<has_image_mean_object_size value="111.87" exclude_labels="0" />``). The labels must be unique.
2972+
Asserts the output is an image with labeled objects which have the specified mean size (number of pixels),
2973+
plus/minus ``eps`` (e.g., ``<has_image_mean_object_size value="111.87" exclude_labels="0" />``).
2974+
The labels must be unique.
29742975
29752976
$attribute_list::5
29762977
]]>
@@ -2981,9 +2982,9 @@ $attribute_list::5
29812982
<xs:documentation xml:lang="en">The required mean size of the uniquely labeled objects.</xs:documentation>
29822983
</xs:annotation>
29832984
</xs:attribute>
2984-
<xs:attribute name="delta" type="xs:float" use="optional" default="0.01">
2985+
<xs:attribute name="eps" type="xs:float" use="optional" default="0.01">
29852986
<xs:annotation>
2986-
<xs:documentation xml:lang="en">The absolute tolerance to be used for ``value`` (defaults to ``0.01``). The observed mean size of the uniquely labeled objects has to be in the range ``value +- delta``.</xs:documentation>
2987+
<xs:documentation xml:lang="en">The absolute tolerance to be used for ``value`` (defaults to ``0.01``). The observed mean size of the uniquely labeled objects has to be in the range ``value +- eps``.</xs:documentation>
29872988
</xs:annotation>
29882989
</xs:attribute>
29892990
<xs:attribute name="min" type="xs:float" use="optional">

test/functional/tools/validation_image.xml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@
2121
</assert_contents>
2222
</output>
2323
</test>
24+
<test>
25+
<param name="input" value="im3_b.tif" />
26+
<output name="output">
27+
<assert_contents>
28+
<has_image_width value="30" delta="2" />
29+
</assert_contents>
30+
</output>
31+
</test>
32+
<test expect_test_failure="true">
33+
<param name="input" value="im3_b.tif" />
34+
<output name="output">
35+
<assert_contents>
36+
<has_image_width value="29" delta="2" />
37+
</assert_contents>
38+
</output>
39+
</test>
2440
<test>
2541
<param name="input" value="im3_b.tif" />
2642
<output name="output">
@@ -49,7 +65,7 @@
4965
<param name="input" value="im3_b.tif" />
5066
<output name="output">
5167
<assert_contents>
52-
<has_image_mean_intensity channel="0" value="0.24" delta="0.0100000001" />
68+
<has_image_mean_intensity channel="0" value="0.24" eps="0.0100000001" />
5369
</assert_contents>
5470
</output>
5571
</test>
@@ -122,7 +138,7 @@
122138
<param name="input" value="im2_b.png" />
123139
<output name="output">
124140
<assert_contents>
125-
<has_image_mean_object_size value="511" delta="0.9" />
141+
<has_image_mean_object_size value="511" eps="0.9" />
126142
</assert_contents>
127143
</output>
128144
</test>
@@ -134,7 +150,7 @@
134150
<has_image_height value="32" />
135151
<has_image_channels value="1" />
136152
<has_image_labels value="2" />
137-
<has_image_mean_object_size value="511" delta="1.0" />
153+
<has_image_mean_object_size value="511" eps="1.0" />
138154
</assert_contents>
139155
</output>
140156
</test>

0 commit comments

Comments
 (0)