Repository navigation
Includes basic np dlpack function that is tested to work across jax a… #1067
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
Changes from 5 commits
2f232d6
9621942
14cd6e2
cfee3a1
a2d273a
a1512f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -198,6 +198,19 @@ def spatial_dims(self, sdims: Sequence[str]): | |||||||||
|
|
||||||||||
| self._spatial_dims = tuple(sdims) | ||||||||||
|
|
||||||||||
| ## This is the ordered sequence of data indices that will be displayed | ||||||||||
| self._spatial_dims_indices = tuple( | ||||||||||
| self.spatial_dims.index(d) for d in self.dims if d in self.spatial_dims | ||||||||||
| ) | ||||||||||
|
|
||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| @property | ||||||||||
| def spatial_dims_indices(self) -> tuple[int, ...]: | ||||||||||
| """ | ||||||||||
| The ordered sequence of data indices that will be displayed | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| """ | ||||||||||
| return self._spatial_dims_indices | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
kushalkolar marked this conversation as resolved.
|
||||||||||
| @property | ||||||||||
| def tooltip(self) -> bool: | ||||||||||
| """ | ||||||||||
|
|
@@ -529,12 +542,7 @@ async def get_window_output(self, indices: dict[str, Any]) -> ArrayProtocol: | |||||||||
| f"windowed_slice.ndim != len(self.spatial_dims): {windowed_slice.ndim} != {len(self.spatial_dims)}" | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| # transpose to spatial dims | ||||||||||
| spatial_dims_int = tuple( | ||||||||||
| self.spatial_dims.index(d) for d in self.dims if d in self.spatial_dims | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| return windowed_slice.transpose(*spatial_dims_int) | ||||||||||
| return windowed_slice | ||||||||||
|
|
||||||||||
| async def _get_raw_data_slice(self, indices: dict[str, Any]) -> ArrayProtocol: | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -186,6 +186,18 @@ def spatial_dims(self, sdims: tuple[str, str] | tuple[str, str, str]): | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| self._spatial_dims = tuple(sdims) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## This is the ordered sequence of data indices that will be displayed | ||||||||||||||||||||||||
| self._spatial_dims_indices = tuple( | ||||||||||||||||||||||||
| self.spatial_dims.index(d) for d in self.dims if d in self.spatial_dims | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @property | ||||||||||||||||||||||||
| def spatial_dims_indices(self) -> tuple[int, ...]: | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| The ordered sequence of data indices that will be displayed | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| return self._spatial_dims_indices | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
| @property | ||||||||||||||||||||||||
| def rgb_dim(self) -> str | None: | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
|
|
@@ -258,7 +270,8 @@ async def get(self, indices: dict[str, Any]) -> ArrayProtocol: | |||||||||||||||||||||||
| if isinstance(window_output, CudaArrayProtocol): | ||||||||||||||||||||||||
| window_output = await run_in_thread_pool(self._executor, cuda_to_numpy, window_output) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return window_output | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
| return window_output.transpose(*self.spatial_dims_indices) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def _recompute_histogram(self): | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -112,6 +112,7 @@ def __init__( | |||||||||||||||||||||||
| self.cmap_transform_each = cmap_transform_each | ||||||||||||||||||||||||
| self.sizes = sizes | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
kushalkolar marked this conversation as resolved.
|
||||||||||||||||||||||||
| def _check_shape_feature( | ||||||||||||||||||||||||
| self, prop: str, check_shape: tuple[int, int] | ||||||||||||||||||||||||
| ) -> tuple[int, int]: | ||||||||||||||||||||||||
|
|
@@ -298,6 +299,18 @@ def spatial_dims(self, sdims: tuple[str, str, str]): | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| self._spatial_dims = tuple(sdims) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## This is the ordered sequence of data indices that will be displayed | ||||||||||||||||||||||||
| self._spatial_dims_indices = tuple( | ||||||||||||||||||||||||
| self.spatial_dims.index(d) for d in self.dims if d in self.spatial_dims | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @property | ||||||||||||||||||||||||
| def spatial_dims_indices(self) -> tuple[int, ...]: | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| The ordered sequence of data indices that will be displayed | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| return self._spatial_dims_indices | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
| @property | ||||||||||||||||||||||||
| def slider_dims(self) -> set[Hashable]: | ||||||||||||||||||||||||
| # append `p` dim to slider dims | ||||||||||||||||||||||||
|
|
@@ -555,6 +568,8 @@ async def get(self, indices: dict[str, Any]) -> dict[str, ArrayProtocol]: | |||||||||||||||||||||||
| if isinstance(data, CudaArrayProtocol): | ||||||||||||||||||||||||
| data = await run_in_thread_pool(self._executor, cuda_to_numpy, data) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| data = data.transpose(*self._spatial_dims_int) | ||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
you made it a public property but didn't use it? |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||
| "data": data, | ||||||||||||||||||||||||
| **other, | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -143,6 +143,18 @@ def spatial_dims(self, sdims: tuple[str, str, str]): | |||||||||||||||||||||||
| f"Spatial dimensions must haves shape (num_vecs, 2, [2 or 3]) you passed {sdims}" | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## This is the ordered sequence of data indices that will be displayed | ||||||||||||||||||||||||
| self._spatial_dims_indices = tuple( | ||||||||||||||||||||||||
| self.spatial_dims.index(d) for d in self.dims if d in self.spatial_dims | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @property | ||||||||||||||||||||||||
| def spatial_dims_indices(self) -> tuple[int, ...]: | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| The ordered sequence of data indices that will be displayed | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| return self._spatial_dims_indices | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
| async def get(self, indices: dict[str, Any]) -> ArrayProtocol: | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| Get the data at the given index, process data through the window functions. | ||||||||||||||||||||||||
|
|
@@ -157,7 +169,7 @@ async def get(self, indices: dict[str, Any]) -> ArrayProtocol: | |||||||||||||||||||||||
| Example: get((100, 5)) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| # this will be squeezed output, with dims in the order of the user set spatial dims | ||||||||||||||||||||||||
| # this will be squeezed output, with dims in the order of self.dims | ||||||||||||||||||||||||
| window_output = await self.get_window_output(indices) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # apply spatial_func; CUDA arrays run inline, numpy goes through the thread pool | ||||||||||||||||||||||||
|
|
@@ -175,7 +187,8 @@ async def get(self, indices: dict[str, Any]) -> ArrayProtocol: | |||||||||||||||||||||||
| if isinstance(window_output, CudaArrayProtocol): | ||||||||||||||||||||||||
| window_output = await run_in_thread_pool(self._executor, cuda_to_numpy, window_output) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return window_output | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
| return window_output.transpose(*self._spatial_dims_indices) | ||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
it's a public property use it |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| class NDVectors(NDGraphic): | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.