dianna-ai / dianna

Deep Insight And Neural Network Analysis
https://dianna.readthedocs.io
Apache License 2.0
48 stars 13 forks source link

support ArrayLike data in to_xarray #825

Closed egpbos closed 2 months ago

egpbos commented 4 months ago

This commit makes dianna swallow more kinds of data items without users having to mangle them manually themselves. As long as your data is numpy ArrayLike it will go. The only blocker for this was the direct use of the .ndim attribute on data, which assumes it is already a numpy array rather than something that can trivially be converted to a numpy array. A PIL.Image is an example of such an ArrayLike type. We use this in explainable_embedding to feed items into the OpenAI CLIP model.

I sprinkled in some nice type hinting, of course, but not for the other parameters, because they would become monstrosities.

egpbos commented 4 months ago

Fixed the import issue from the previous CI build (tested locally). However, now we have a different, unrelated issue that we have to wait to get fixed (see #827 and #829).

loostrum commented 4 months ago

I rebased on main to get the linter fix in here. The changes themselves look good, nice generalization of to_xarray! Linter's happy as well, so let's merge.

elboyran commented 2 months ago

@egpbos many checks are not passing.

egpbos commented 2 months ago

Yep, those are mentioned above. They are unrelated to this PR.

cwmeijer commented 2 months ago

closing and reopening for rerunning tests