Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add from_array convenience functions #219

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

tlambert03
Copy link
Owner

@tlambert03 tlambert03 commented Sep 24, 2023

This adds convenience functions that make it easy to construct ome objects for arrays:

something like:

data = np.empty((2, 2, 3, 10, 20, 3), dtype=np.uint16)

img = ome_image_like(
    data,
    description="test",
    channels={"name": ['A', 'B', 'C'], "color": "red"},
    planes={"position_x": [1] * 12, "exposure_time": 3},
)  # returns an ome_types.model.Image
<Image xmlns="http://www.openmicroscopy.org/Schemas/OME/2016-06"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2016-06
http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd" ID="Image:0">
  <Description>test</Description>
  <Pixels ID="Pixels:0" DimensionOrder="XYCZT" Type="uint16" SizeX="20" SizeY="10" SizeZ="2" SizeC="9" SizeT="2">
    <Channel ID="Channel:0" Name="A" SamplesPerPixel="3" Color="-16776961"/>
    <Channel ID="Channel:1" Name="B" SamplesPerPixel="3" Color="-16776961"/>
    <Channel ID="Channel:2" Name="C" SamplesPerPixel="3" Color="-16776961"/>
    <Plane TheZ="0" TheT="0" TheC="0" ExposureTime="3.0" PositionX="1.0"/>
    <Plane TheZ="0" TheT="0" TheC="1" ExposureTime="3.0" PositionX="1.0"/>
    <Plane TheZ="0" TheT="0" TheC="2" ExposureTime="3.0" PositionX="1.0"/>
    <Plane TheZ="1" TheT="0" TheC="0" ExposureTime="3.0" PositionX="1.0"/>
    <Plane TheZ="1" TheT="0" TheC="1" ExposureTime="3.0" PositionX="1.0"/>
    <Plane TheZ="1" TheT="0" TheC="2" ExposureTime="3.0" PositionX="1.0"/>
    <Plane TheZ="0" TheT="1" TheC="0" ExposureTime="3.0" PositionX="1.0"/>
    <Plane TheZ="0" TheT="1" TheC="1" ExposureTime="3.0" PositionX="1.0"/>
    <Plane TheZ="0" TheT="1" TheC="2" ExposureTime="3.0" PositionX="1.0"/>
    <Plane TheZ="1" TheT="1" TheC="0" ExposureTime="3.0" PositionX="1.0"/>
    <Plane TheZ="1" TheT="1" TheC="1" ExposureTime="3.0" PositionX="1.0"/>
    <Plane TheZ="1" TheT="1" TheC="2" ExposureTime="3.0" PositionX="1.0"/>
  </Pixels>
</Image>

@codecov
Copy link

codecov bot commented Sep 24, 2023

Codecov Report

Merging #219 (ad390f6) into main (a75d5f8) will decrease coverage by 4.80%.
Report is 2 commits behind head on main.
The diff coverage is 80.70%.

❗ Current head ad390f6 differs from pull request most recent head c345494. Consider uploading reports for the commit c345494 to get more accurate results

@@            Coverage Diff             @@
##             main     #219      +/-   ##
==========================================
- Coverage   86.11%   81.31%   -4.80%     
==========================================
  Files          26       27       +1     
  Lines        1217     1322     +105     
==========================================
+ Hits         1048     1075      +27     
- Misses        169      247      +78     
Files Coverage Δ
src/ome_types/_conversion.py 96.01% <100.00%> (+0.14%) ⬆️
src/ome_types/_mixins/_validators.py 97.22% <100.00%> (+0.44%) ⬆️
src/ome_types/_from_arrays.py 76.34% <76.34%> (ø)

... and 6 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 24, 2023

CodSpeed Performance Report

Merging #219 will not alter performance

Comparing from-array (ad390f6) with main (a75d5f8)

Summary

✅ 9 untouched benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant