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

Support numpy.bool_ dtype -> NativeBoolType #19

Merged
merged 1 commit into from
Mar 8, 2023
Merged

Conversation

gselzer
Copy link
Contributor

@gselzer gselzer commented Aug 16, 2022

This PR supports the conversion from numpy arrays with dtype np.bool8 to RandomAccessibleInterval<NativeBoolType>s, and adds a regression test to ensure this conversion is possible. (It actually adds more regression tests than that).

This PR is the minimal possible change required to implement this functionality.

Conversion the other way is tricky, as we have discussed in #13, and the PRs that this work leans on are not enough to implement that conversion. The main issue lies in creating an Image of some BooleanType that can be converted. I am unable to create an UnsafeImg of any BooleanType, and although I can create an ArrayImg<BitType>, I cannot convert that using imglyb.to_numpy. Therefore, I leave that work for another PR.

This PR requires the work of imglib/imglib2-unsafe#8 and imglib/imglib2-imglyb#10 to make their way into releases before this will work. I have tested locally with snapshots of each.

@gselzer gselzer added the enhancement New feature or request label Aug 16, 2022
@gselzer gselzer requested a review from ctrueden August 16, 2022 21:32
@gselzer gselzer self-assigned this Aug 16, 2022
Specifically, we support conversion of np.ndarray objects of dtype
np.bool8 to RandomAccessibleIntervals of NativeBoolType. Conversion
going the other way is tricky, and is not fully tested by the work that
this feature addition leans on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants