Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1fea4aa
started implementation of ImageWidget, nothing is tested yet
kushalkolar Dec 2, 2022
1bc65a0
basic stuff finished for single plot with a slider, need to test
kushalkolar Dec 2, 2022
6592cc3
basic image widget works
kushalkolar Dec 2, 2022
658f298
docs
kushalkolar Dec 2, 2022
5cc91ae
splitting imagewidget into two classes
kushalkolar Dec 4, 2022
7a6a136
split ImageWidget into ImageWidgetSingle and later ImageWidgetGrid
kushalkolar Dec 4, 2022
7cce91f
combined single and grid ImageWidget into single class
kushalkolar Dec 4, 2022
56a9b1c
simple and grid image widget works, tested with simple args, need to …
kushalkolar Dec 4, 2022
79f4452
catch another user error
kushalkolar Dec 4, 2022
e4f6b12
fix type annotation
kushalkolar Dec 4, 2022
5028ce7
docstrings, started slice_avg implementation
kushalkolar Dec 4, 2022
5ef32eb
slice averaging on single and multiple dimensions works perfectly
kushalkolar Dec 5, 2022
eca6599
is_array() checks for and attr, better error messages
kushalkolar Dec 8, 2022
0e3cf16
rename axis -> dims
kushalkolar Dec 10, 2022
570c076
make most imagewidget methods private, most attributes as read-only p…
kushalkolar Dec 10, 2022
4764b84
quick_min_max() returns pre-computed min max if int or float, imagewi…
kushalkolar Dec 10, 2022
afc0378
vmin vmax for gridplot
kushalkolar Dec 10, 2022
fc3365b
Merge branch 'master' into high-level-widgets
kushalkolar Dec 11, 2022
b1e922c
update Image -> ImageGraphic
kushalkolar Dec 11, 2022
e6c5d3a
refactor, window_funcs now works very well, slow with multiple dims b…
kushalkolar Dec 11, 2022
64faffd
vminmax works, also added names for subplots, everything works
kushalkolar Dec 11, 2022
8fc63b3
proper-ish image widget example
kushalkolar Dec 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
is_array() checks for and attr, better error messages
  • Loading branch information
kushalkolar committed Dec 8, 2022
commit eca659926d3708887a03c8e4cfd2dbdfaf89f46d
17 changes: 13 additions & 4 deletions fastplotlib/widgets/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ def is_arraylike(obj) -> bool:
Checks if the object is array-like.
For now just checks if obj has `__getitem__()`
"""
return hasattr(obj, "__getitem__")
for attr in [
"__getitem__",
"shape",
"ndim"
]:
if not hasattr(obj, attr):
return False

return True


class ImageWidget:
Expand Down Expand Up @@ -115,7 +123,8 @@ def __init__(

else:
raise TypeError(
f"`data` must be a list of `numpy.ndarray` representing a grid of images/image sequences"
f"If passing a list to `data` all elements must be an "
f"array-like type representing an n-dimensional image"
)

elif is_arraylike(data):
Expand All @@ -125,8 +134,8 @@ def __init__(
self.plot_type = "single"
else:
raise TypeError(
f"`data` must be of type `numpy.ndarray` representing a single image/image sequence "
f"or a list of `numpy.ndarray` representing a grid of images/image sequences"
f"`data` must be an array-like type representing an n-dimensional image "
f"or a list of array-like representing a grid of n-dimensional images"
)

# default axes order if not passed
Expand Down