mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Rename assertion attribute value
This commit is contained in:
@@ -49,7 +49,7 @@ def _assert_float(
|
||||
|
||||
def assert_has_image_width(
|
||||
output_bytes: bytes,
|
||||
value: Optional[Union[int, str]] = None,
|
||||
width: Optional[Union[int, str]] = None,
|
||||
delta: Union[int, str] = 0,
|
||||
min: Optional[Union[int, str]] = None,
|
||||
max: Optional[Union[int, str]] = None,
|
||||
@@ -62,7 +62,7 @@ def assert_has_image_width(
|
||||
with Image.open(buf) as im:
|
||||
_assert_number(
|
||||
im.size[0],
|
||||
value,
|
||||
width,
|
||||
delta,
|
||||
min,
|
||||
max,
|
||||
@@ -74,7 +74,7 @@ def assert_has_image_width(
|
||||
|
||||
def assert_has_image_height(
|
||||
output_bytes: bytes,
|
||||
value: Optional[Union[int, str]] = None,
|
||||
height: Optional[Union[int, str]] = None,
|
||||
delta: Union[int, str] = 0,
|
||||
min: Optional[Union[int, str]] = None,
|
||||
max: Optional[Union[int, str]] = None,
|
||||
@@ -87,7 +87,7 @@ def assert_has_image_height(
|
||||
with Image.open(buf) as im:
|
||||
_assert_number(
|
||||
im.size[1],
|
||||
value,
|
||||
height,
|
||||
delta,
|
||||
min,
|
||||
max,
|
||||
@@ -99,7 +99,7 @@ def assert_has_image_height(
|
||||
|
||||
def assert_has_image_channels(
|
||||
output_bytes: bytes,
|
||||
value: Optional[Union[int, str]] = None,
|
||||
channels: Optional[Union[int, str]] = None,
|
||||
delta: Union[int, str] = 0,
|
||||
min: Optional[Union[int, str]] = None,
|
||||
max: Optional[Union[int, str]] = None,
|
||||
@@ -112,7 +112,7 @@ def assert_has_image_channels(
|
||||
with Image.open(buf) as im:
|
||||
_assert_number(
|
||||
len(im.getbands()),
|
||||
value,
|
||||
channels,
|
||||
delta,
|
||||
min,
|
||||
max,
|
||||
@@ -155,7 +155,7 @@ def _get_image(
|
||||
def assert_has_image_mean_intensity(
|
||||
output_bytes: bytes,
|
||||
channel: Optional[Union[int, str]] = None,
|
||||
value: Optional[Union[float, str]] = None,
|
||||
mean_intensity: Optional[Union[float, str]] = None,
|
||||
eps: Union[float, str] = 0.01,
|
||||
min: Optional[Union[float, str]] = None,
|
||||
max: Optional[Union[float, str]] = None,
|
||||
@@ -168,7 +168,7 @@ def assert_has_image_mean_intensity(
|
||||
actual=im_arr.mean(),
|
||||
label="mean intensity",
|
||||
tolerance=eps,
|
||||
expected=value,
|
||||
expected=mean_intensity,
|
||||
range_min=min,
|
||||
range_max=max,
|
||||
)
|
||||
@@ -176,25 +176,24 @@ def assert_has_image_mean_intensity(
|
||||
|
||||
def assert_has_image_center_of_mass(
|
||||
output_bytes: bytes,
|
||||
center_of_mass: Union[Tuple[float, float], str],
|
||||
channel: Optional[Union[int, str]] = None,
|
||||
point: Optional[Union[Tuple[float, float], str]] = None,
|
||||
eps: Union[float, str] = 0.01,
|
||||
) -> None:
|
||||
"""
|
||||
Asserts the specified output is an image and has the specified center of mass.
|
||||
"""
|
||||
im_arr = _get_image(output_bytes, channel)
|
||||
if point is not None:
|
||||
if isinstance(point, str):
|
||||
point_parts = [c.strip() for c in point.split(",")]
|
||||
assert len(point_parts) == 2
|
||||
point = (float(point_parts[0]), float(point_parts[1]))
|
||||
assert len(point) == 2, "point must have two components"
|
||||
actual_center_of_mass = _compute_center_of_mass(im_arr)
|
||||
distance = numpy.linalg.norm(numpy.subtract(point, actual_center_of_mass))
|
||||
assert distance <= float(
|
||||
eps
|
||||
), f"Wrong center of mass: {actual_center_of_mass} (expected {point}, distance: {distance}, eps: {eps})"
|
||||
if isinstance(center_of_mass, str):
|
||||
center_of_mass_parts = [c.strip() for c in center_of_mass.split(",")]
|
||||
assert len(center_of_mass_parts) == 2
|
||||
center_of_mass = (float(center_of_mass_parts[0]), float(center_of_mass_parts[1]))
|
||||
assert len(center_of_mass) == 2, "center_of_mass must have two components"
|
||||
actual_center_of_mass = _compute_center_of_mass(im_arr)
|
||||
distance = numpy.linalg.norm(numpy.subtract(center_of_mass, actual_center_of_mass))
|
||||
assert distance <= float(
|
||||
eps
|
||||
), f"Wrong center of mass: {actual_center_of_mass} (expected {center_of_mass}, distance: {distance}, eps: {eps})"
|
||||
|
||||
|
||||
def _get_image_labels(
|
||||
@@ -270,7 +269,7 @@ def assert_has_image_mean_object_size(
|
||||
channel: Optional[Union[int, str]] = None,
|
||||
labels: Optional[Union[str, List[int]]] = None,
|
||||
exclude_labels: Optional[Union[str, List[int]]] = None,
|
||||
value: Optional[Union[float, str]] = None,
|
||||
mean_object_size: Optional[Union[float, str]] = None,
|
||||
eps: Union[float, str] = 0.01,
|
||||
min: Optional[Union[float, str]] = None,
|
||||
max: Optional[Union[float, str]] = None,
|
||||
@@ -284,7 +283,7 @@ def assert_has_image_mean_object_size(
|
||||
actual=actual_mean_object_size,
|
||||
label="mean object size",
|
||||
tolerance=eps,
|
||||
expected=value,
|
||||
expected=mean_object_size,
|
||||
range_min=min,
|
||||
range_max=max,
|
||||
)
|
||||
|
||||
@@ -2758,15 +2758,15 @@ $attribute_list::5
|
||||
<xs:complexType name="AssertHasImageWidth">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en"><![CDATA[
|
||||
Asserts the output is an image and has a specific width (in pixels) of ``value``
|
||||
plus/minus ``delta`` (e.g., ``<has_image_width value="512" delta="2" />``).
|
||||
Asserts the output is an image and has a specific width (in pixels),
|
||||
plus/minus ``delta`` (e.g., ``<has_image_width width="512" delta="2" />``).
|
||||
Alternatively the range of the expected width can be specified by ``min`` and/or ``max``.
|
||||
|
||||
$attribute_list::5
|
||||
]]>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:attribute name="value" type="xs:integer" use="optional">
|
||||
<xs:attribute name="width" type="xs:integer" use="optional">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">Expected width of the image (in pixels).`</xs:documentation>
|
||||
</xs:annotation>
|
||||
@@ -2791,15 +2791,15 @@ $attribute_list::5
|
||||
<xs:complexType name="AssertHasImageHeight">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en"><![CDATA[
|
||||
Asserts the output is an image and has a specific height (in pixels) of ``value``
|
||||
plus/minus ``delta`` (e.g., ``<has_image_height value="512" delta="2" />``).
|
||||
Asserts the output is an image and has a specific height (in pixels),
|
||||
plus/minus ``delta`` (e.g., ``<has_image_height height="512" delta="2" />``).
|
||||
Alternatively the range of the expected height can be specified by ``min`` and/or ``max``.
|
||||
|
||||
$attribute_list::5
|
||||
]]>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:attribute name="value" type="xs:integer" use="optional">
|
||||
<xs:attribute name="height" type="xs:integer" use="optional">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">Expected height of the image (in pixels).`</xs:documentation>
|
||||
</xs:annotation>
|
||||
@@ -2824,15 +2824,15 @@ $attribute_list::5
|
||||
<xs:complexType name="AssertHasImageChannels">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en"><![CDATA[
|
||||
Asserts the output is an image and has a specific number of channels of ``value``
|
||||
plus/minus ``delta`` (e.g., ``<has_image_height value="512" delta="2" />``).
|
||||
Asserts the output is an image and has a specific number of channels,
|
||||
plus/minus ``delta`` (e.g., ``<has_image_channels channels="3" />``).
|
||||
Alternatively the range of the expected number of channels can be specified by ``min`` and/or ``max``.
|
||||
|
||||
$attribute_list::5
|
||||
]]>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:attribute name="value" type="xs:integer" use="optional">
|
||||
<xs:attribute name="channels" type="xs:integer" use="optional">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">Expected number of channels of the image.`</xs:documentation>
|
||||
</xs:annotation>
|
||||
@@ -2857,15 +2857,15 @@ $attribute_list::5
|
||||
<xs:complexType name="AssertHasImageMeanIntensity">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en"><![CDATA[
|
||||
Asserts the output is an image and has a specific mean intensity value of ``value``
|
||||
plus/minus ``eps`` (e.g., ``<image_has_mean_intensity value="0.83" />``).
|
||||
Asserts the output is an image and has a specific mean intensity value,
|
||||
plus/minus ``eps`` (e.g., ``<image_has_mean_intensity mean_intensity="0.83" />``).
|
||||
Alternatively the range of the expected mean intensity value can be specified by ``min`` and/or ``max``.
|
||||
|
||||
$attribute_list::5
|
||||
]]>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:attribute name="value" type="xs:float" use="optional">
|
||||
<xs:attribute name="mean_intensity" type="xs:float" use="optional">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">The required mean value of the image intensities.</xs:documentation>
|
||||
</xs:annotation>
|
||||
@@ -2894,15 +2894,15 @@ $attribute_list::5
|
||||
<xs:complexType name="AssertHasImageCenterOfMass">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en"><![CDATA[
|
||||
Asserts the output is an image and has a specific center of mass of ``point``,
|
||||
Asserts the output is an image and has a specific center of mass,
|
||||
or has an Euclidean distance of ``eps`` or less to that point (e.g.,
|
||||
``<has_image_center_of_mass point="511.07, 223.34" />``).
|
||||
``<has_image_center_of_mass center_of_mass="511.07, 223.34" />``).
|
||||
|
||||
$attribute_list::5
|
||||
]]>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:attribute name="point" type="xs:string" use="optional">
|
||||
<xs:attribute name="center_of_mass" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">The required center of mass of the image intensities (horizontal and vertical coordinate, separated by a comma).</xs:documentation>
|
||||
</xs:annotation>
|
||||
@@ -2970,14 +2970,14 @@ $attribute_list::5
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en"><![CDATA[
|
||||
Asserts the output is an image with labeled objects which have the specified mean size (number of pixels),
|
||||
plus/minus ``eps`` (e.g., ``<has_image_mean_object_size value="111.87" exclude_labels="0" />``).
|
||||
plus/minus ``eps`` (e.g., ``<has_image_mean_object_size mean_object_size="111.87" exclude_labels="0" />``).
|
||||
The labels must be unique.
|
||||
|
||||
$attribute_list::5
|
||||
]]>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:attribute name="value" type="xs:float" use="optional">
|
||||
<xs:attribute name="mean_object_size" type="xs:float" use="optional">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">The required mean size of the uniquely labeled objects.</xs:documentation>
|
||||
</xs:annotation>
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
<param name="input" value="im1_uint8.tif" />
|
||||
<output name="output">
|
||||
<assert_contents>
|
||||
<has_image_width value="32" />
|
||||
<has_image_height value="32" />
|
||||
<has_image_channels value="1" />
|
||||
<has_image_center_of_mass point="15.61, 15.48" />
|
||||
<has_image_width width="32" />
|
||||
<has_image_height height="32" />
|
||||
<has_image_channels channels="1" />
|
||||
<has_image_center_of_mass center_of_mass="15.61, 15.48" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
@@ -25,7 +25,7 @@
|
||||
<param name="input" value="im3_b.tif" />
|
||||
<output name="output">
|
||||
<assert_contents>
|
||||
<has_image_width value="30" delta="2" />
|
||||
<has_image_width width="30" delta="2" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
@@ -33,7 +33,7 @@
|
||||
<param name="input" value="im3_b.tif" />
|
||||
<output name="output">
|
||||
<assert_contents>
|
||||
<has_image_width value="29" delta="2" />
|
||||
<has_image_width width="29" delta="2" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
@@ -41,15 +41,15 @@
|
||||
<param name="input" value="im3_b.tif" />
|
||||
<output name="output">
|
||||
<assert_contents>
|
||||
<has_image_width value="32" />
|
||||
<has_image_height value="32" />
|
||||
<has_image_channels value="3" />
|
||||
<has_image_center_of_mass channel="0" point="7.5, 7.5" />
|
||||
<has_image_mean_intensity channel="0" value="0.25" />
|
||||
<has_image_mean_intensity channel="1" value="0.0" />
|
||||
<has_image_mean_intensity channel="2" value="0" />
|
||||
<has_image_center_of_mass point="7.5, 7.5" />
|
||||
<has_image_mean_intensity value="0.08333333333" />
|
||||
<has_image_width width="32" />
|
||||
<has_image_height height="32" />
|
||||
<has_image_channels channels="3" />
|
||||
<has_image_center_of_mass channel="0" center_of_mass="7.5, 7.5" />
|
||||
<has_image_mean_intensity channel="0" mean_intensity="0.25" />
|
||||
<has_image_mean_intensity channel="1" mean_intensity="0.0" />
|
||||
<has_image_mean_intensity channel="2" mean_intensity="0" />
|
||||
<has_image_center_of_mass center_of_mass="7.5, 7.5" />
|
||||
<has_image_mean_intensity mean_intensity="0.08333333333" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
@@ -57,7 +57,7 @@
|
||||
<param name="input" value="im3_b.tif" />
|
||||
<output name="output">
|
||||
<assert_contents>
|
||||
<has_image_mean_intensity channel="0" value="0.24" />
|
||||
<has_image_mean_intensity channel="0" mean_intensity="0.24" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
@@ -65,7 +65,7 @@
|
||||
<param name="input" value="im3_b.tif" />
|
||||
<output name="output">
|
||||
<assert_contents>
|
||||
<has_image_mean_intensity channel="0" value="0.24" eps="0.0100000001" />
|
||||
<has_image_mean_intensity channel="0" mean_intensity="0.24" eps="0.0100000001" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
@@ -98,11 +98,11 @@
|
||||
<param name="input" value="im2_b.png" />
|
||||
<output name="output">
|
||||
<assert_contents>
|
||||
<has_image_width value="32" />
|
||||
<has_image_height value="32" />
|
||||
<has_image_channels value="1" />
|
||||
<has_image_width width="32" />
|
||||
<has_image_height height="32" />
|
||||
<has_image_channels channels="1" />
|
||||
<has_image_labels value="1" exclude_labels="0" />
|
||||
<has_image_mean_object_size value="256" exclude_labels="0" />
|
||||
<has_image_mean_object_size mean_object_size="256" exclude_labels="0" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
@@ -110,11 +110,11 @@
|
||||
<param name="input" value="im2_b.png" />
|
||||
<output name="output">
|
||||
<assert_contents>
|
||||
<has_image_width value="32" />
|
||||
<has_image_height value="32" />
|
||||
<has_image_channels value="1" />
|
||||
<has_image_width width="32" />
|
||||
<has_image_height height="32" />
|
||||
<has_image_channels channels="1" />
|
||||
<has_image_labels value="2" />
|
||||
<has_image_mean_object_size value="512" />
|
||||
<has_image_mean_object_size mean_object_size="512" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
@@ -122,7 +122,7 @@
|
||||
<param name="input" value="im2_b.png" />
|
||||
<output name="output">
|
||||
<assert_contents>
|
||||
<has_image_mean_object_size labels="0" value="768" />
|
||||
<has_image_mean_object_size labels="0" mean_object_size="768" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
@@ -130,7 +130,7 @@
|
||||
<param name="input" value="im2_b.png" />
|
||||
<output name="output">
|
||||
<assert_contents>
|
||||
<has_image_mean_object_size labels="0, 1" value="512" />
|
||||
<has_image_mean_object_size labels="0, 1" mean_object_size="512" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
@@ -138,7 +138,7 @@
|
||||
<param name="input" value="im2_b.png" />
|
||||
<output name="output">
|
||||
<assert_contents>
|
||||
<has_image_mean_object_size value="511" eps="0.9" />
|
||||
<has_image_mean_object_size mean_object_size="511" eps="0.9" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
@@ -146,11 +146,11 @@
|
||||
<param name="input" value="im2_b.png" />
|
||||
<output name="output">
|
||||
<assert_contents>
|
||||
<has_image_width value="32" />
|
||||
<has_image_height value="32" />
|
||||
<has_image_channels value="1" />
|
||||
<has_image_width width="32" />
|
||||
<has_image_height height="32" />
|
||||
<has_image_channels channels="1" />
|
||||
<has_image_labels value="2" />
|
||||
<has_image_mean_object_size value="511" eps="1.0" />
|
||||
<has_image_mean_object_size mean_object_size="511" eps="1.0" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
|
||||
Reference in New Issue
Block a user