-
Notifications
You must be signed in to change notification settings - Fork 26
Add fallback Array vis to support stacks of JPEG/PNG images #1768
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
Author
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. cf. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,21 +3,18 @@ import { | |
| assertGroup, | ||
| assertGroupWithChildren, | ||
| isGroup, | ||
| isScalarSelection, | ||
| } from '@h5web/shared/guards'; | ||
| import { | ||
| type ArrayShape, | ||
| type Dataset, | ||
| type DType, | ||
| type GroupWithChildren, | ||
| type ProvidedEntity, | ||
| type ScalarShape, | ||
| type ScalarValue, | ||
| } from '@h5web/shared/hdf5-models'; | ||
| import { getChildEntity } from '@h5web/shared/hdf5-utils'; | ||
| import { createArrayFromView } from '@h5web/shared/vis-utils'; | ||
| import ndarray from 'ndarray'; | ||
|
|
||
| import { applyMapping } from '../../vis-packs/core/utils'; | ||
|
|
||
| export const SLOW_TIMEOUT = 3000; | ||
|
|
||
| export function findMockEntity( | ||
|
|
@@ -46,19 +43,22 @@ export function findMockEntity( | |
| return child; | ||
| } | ||
|
|
||
| export function sliceValue<T extends DType>( | ||
| value: unknown, | ||
| dataset: Dataset<ArrayShape | ScalarShape, T>, | ||
| export function sliceValue( | ||
| value: unknown[], | ||
| dataset: Dataset<ArrayShape>, | ||
| selection: string, | ||
| ): ScalarValue<T>[] { | ||
| ): unknown { | ||
| const { shape } = dataset; | ||
| const dataArray = ndarray(value as ScalarValue<typeof dataset.type>[], shape); | ||
| const mappedArray = applyMapping( | ||
|
||
| dataArray, | ||
| selection.split(',').map((s) => (s === ':' ? s : Number.parseInt(s))), | ||
| ); | ||
| const dataArray = ndarray(value, shape); | ||
|
|
||
| const slicingState = selection | ||
| .split(',') | ||
| .map((val) => (val === ':' ? null : Number.parseInt(val))); | ||
|
|
||
| const slicedView = dataArray.pick(...slicingState); | ||
| const slicedArray = createArrayFromView(slicedView); | ||
|
|
||
| return mappedArray.data; | ||
| return isScalarSelection(selection) ? slicedArray.get(0) : slicedArray.data; | ||
| } | ||
|
|
||
| export function getChildrenPaths( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.