Skip to content

Commit d150840

Browse files
committed
Add fallback Array vis for datasets with array shape
1 parent 34808da commit d150840

File tree

22 files changed

+496
-330
lines changed

22 files changed

+496
-330
lines changed

packages/app/src/__tests__/CorePack.test.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ test('visualize 1D compound dataset', async () => {
9696
expect(page.getByText('Argon')).toBeVisible();
9797
});
9898

99+
test('visualize 1D mixed compound dataset', async () => {
100+
await renderApp('/nD_datasets/oneD_compound_mixed');
101+
102+
expect(getVisTabs()).toEqual([Vis.Array]);
103+
expect(getSelectedVisTab()).toBe(Vis.Array);
104+
expect(page.getByText('"int": 42')).toBeVisible();
105+
});
106+
107+
test('visualize 1D opaque dataset', async () => {
108+
await renderApp('/nD_datasets/oneD_opaque');
109+
110+
expect(getVisTabs()).toEqual([Vis.Array]);
111+
expect(getSelectedVisTab()).toBe(Vis.Array);
112+
expect(page.getByText('"foo"')).toBeVisible();
113+
});
114+
99115
test('visualize 2D dataset', async () => {
100116
await renderApp('/nD_datasets/twoD');
101117

@@ -164,6 +180,14 @@ test('visualize 2D complex dataset', async () => {
164180
expect(page.getByRole('figure', { name: 'twoD_cplx (phase)' })).toBeVisible();
165181
});
166182

183+
test('visualize 2D opaque dataset', async () => {
184+
await renderApp('/nD_datasets/twoD_opaque');
185+
186+
expect(getVisTabs()).toEqual([Vis.Array]);
187+
expect(getSelectedVisTab()).toBe(Vis.Array);
188+
expect(page.getByText('Uint8Array [ 0,1 ]')).toBeVisible();
189+
});
190+
167191
test('show interactions help for heatmap according to "keep ratio"', async () => {
168192
await renderApp();
169193

packages/app/src/__tests__/DimensionMapper.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ test('slice through 2D dataset', async () => {
108108
expect(d0Slider).toHaveValue(1);
109109
});
110110

111+
test('slice through 2D opaque dataset', async () => {
112+
const { user } = await renderApp('/nD_datasets/twoD_opaque');
113+
114+
expect(page.getByText('Uint8Array [ 0,1 ]')).toBeVisible();
115+
116+
// Move to next slice with keyboard
117+
const d0Slider = page.getByRole('slider', { name: 'D0' });
118+
await user.type(d0Slider, '{ArrowUp}');
119+
120+
expect(d0Slider).toHaveValue(1);
121+
await expect.element(page.getByText('Uint8Array [ 4,5 ]')).toBeVisible();
122+
});
123+
111124
test('maintain mapping when switching to inspect mode and back', async () => {
112125
await renderApp({
113126
initialPath: '/nD_datasets/twoD',

packages/app/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,12 @@ export {
191191
export { arrayDef, scalarDef, parseShape } from '@h5web/shared/hdf5-utils';
192192

193193
export { default as ValueFetcher } from './vis-packs/core/ValueFetcher';
194-
export { applyMapping, getBaseArray, toNumArray } from './vis-packs/core/utils';
194+
export {
195+
applyMapping,
196+
getBaseArray,
197+
toNumArray,
198+
isScalarSelection,
199+
} from './vis-packs/core/utils';
195200
export {
196201
useBaseArray,
197202
useMappedArray,

packages/app/src/providers/h5grove/__snapshots__/h5grove-api.test.ts.snap

Lines changed: 100 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,42 +1626,59 @@ exports[`test file matches snapshot 1`] = `
16261626
],
16271627
},
16281628
{
1629-
"name": "compound_nested_scalar",
1629+
"name": "compound_mixed_1D",
16301630
"rawType": {
16311631
"class": 6,
16321632
"dtype": {
1633+
"arr": "|V8",
1634+
"bool": "|b1",
16331635
"nested": {
16341636
"bigint": "<i8",
1635-
"bool": "|b1",
16361637
"cplx": "<c8",
1638+
"vlen": "|O",
16371639
},
16381640
},
16391641
"members": [
1642+
{
1643+
"base": {
1644+
"class": 0,
1645+
"dtype": "|i1",
1646+
"order": 0,
1647+
"sign": 1,
1648+
"size": 1,
1649+
},
1650+
"class": 8,
1651+
"dtype": "|b1",
1652+
"members": {
1653+
"FALSE": 0,
1654+
"TRUE": 1,
1655+
},
1656+
"name": "bool",
1657+
"size": 1,
1658+
},
1659+
{
1660+
"base": {
1661+
"class": 1,
1662+
"dtype": "<f4",
1663+
"order": 0,
1664+
"size": 4,
1665+
},
1666+
"class": 10,
1667+
"dims": [
1668+
2,
1669+
],
1670+
"dtype": "|V8",
1671+
"name": "arr",
1672+
"size": 8,
1673+
},
16401674
{
16411675
"class": 6,
16421676
"dtype": {
16431677
"bigint": "<i8",
1644-
"bool": "|b1",
16451678
"cplx": "<c8",
1679+
"vlen": "|O",
16461680
},
16471681
"members": [
1648-
{
1649-
"base": {
1650-
"class": 0,
1651-
"dtype": "|i1",
1652-
"order": 0,
1653-
"sign": 1,
1654-
"size": 1,
1655-
},
1656-
"class": 8,
1657-
"dtype": "|b1",
1658-
"members": {
1659-
"FALSE": 0,
1660-
"TRUE": 1,
1661-
},
1662-
"name": "bool",
1663-
"size": 1,
1664-
},
16651682
{
16661683
"class": 6,
16671684
"dtype": "<c8",
@@ -1692,32 +1709,58 @@ exports[`test file matches snapshot 1`] = `
16921709
"sign": 1,
16931710
"size": 8,
16941711
},
1712+
{
1713+
"base": {
1714+
"class": 0,
1715+
"dtype": "<u8",
1716+
"order": 0,
1717+
"sign": 0,
1718+
"size": 8,
1719+
},
1720+
"class": 9,
1721+
"dtype": "|O",
1722+
"name": "vlen",
1723+
"size": 16,
1724+
},
16951725
],
16961726
"name": "nested",
1697-
"size": 17,
1727+
"size": 32,
16981728
},
16991729
],
1700-
"size": 17,
1730+
"size": 41,
17011731
},
17021732
"shape": {
1703-
"class": "Scalar",
1704-
"dims": [],
1733+
"class": "Array",
1734+
"dims": [
1735+
2,
1736+
],
17051737
},
17061738
"type": {
17071739
"class": "Compound",
17081740
"fields": Map {
1741+
"bool" => {
1742+
"base": {
1743+
"class": "Integer",
1744+
"endianness": "little-endian",
1745+
"signed": true,
1746+
"size": 8,
1747+
},
1748+
"class": "Boolean",
1749+
},
1750+
"arr" => {
1751+
"base": {
1752+
"class": "Float",
1753+
"endianness": "little-endian",
1754+
"size": 32,
1755+
},
1756+
"class": "Array",
1757+
"dims": [
1758+
2,
1759+
],
1760+
},
17091761
"nested" => {
17101762
"class": "Compound",
17111763
"fields": Map {
1712-
"bool" => {
1713-
"base": {
1714-
"class": "Integer",
1715-
"endianness": "little-endian",
1716-
"signed": true,
1717-
"size": 8,
1718-
},
1719-
"class": "Boolean",
1720-
},
17211764
"cplx" => {
17221765
"class": "Complex",
17231766
"imagType": {
@@ -1737,121 +1780,50 @@ exports[`test file matches snapshot 1`] = `
17371780
"signed": true,
17381781
"size": 64,
17391782
},
1783+
"vlen" => {
1784+
"base": {
1785+
"class": "Integer",
1786+
"endianness": "little-endian",
1787+
"signed": false,
1788+
"size": 64,
1789+
},
1790+
"class": "Array (variable length)",
1791+
},
17401792
},
17411793
},
17421794
},
17431795
},
17441796
"value": [
17451797
[
17461798
true,
1747-
[
1748-
1,
1749-
2,
1750-
],
1751-
3,
1752-
],
1753-
],
1754-
},
1755-
{
1756-
"name": "compound_array_vlen_1D",
1757-
"rawType": {
1758-
"class": 6,
1759-
"dtype": {
1760-
"arr": "|V8",
1761-
"vlen": "|O",
1762-
},
1763-
"members": [
1764-
{
1765-
"base": {
1766-
"class": 1,
1767-
"dtype": "<f4",
1768-
"order": 0,
1769-
"size": 4,
1770-
},
1771-
"class": 10,
1772-
"dims": [
1773-
2,
1774-
],
1775-
"dtype": "|V8",
1776-
"name": "arr",
1777-
"size": 8,
1778-
},
1779-
{
1780-
"base": {
1781-
"class": 0,
1782-
"dtype": "<u8",
1783-
"order": 0,
1784-
"sign": 0,
1785-
"size": 8,
1786-
},
1787-
"class": 9,
1788-
"dtype": "|O",
1789-
"name": "vlen",
1790-
"size": 16,
1791-
},
1792-
],
1793-
"size": 24,
1794-
},
1795-
"shape": {
1796-
"class": "Array",
1797-
"dims": [
1798-
3,
1799-
],
1800-
},
1801-
"type": {
1802-
"class": "Compound",
1803-
"fields": Map {
1804-
"arr" => {
1805-
"base": {
1806-
"class": "Float",
1807-
"endianness": "little-endian",
1808-
"size": 32,
1809-
},
1810-
"class": "Array",
1811-
"dims": [
1812-
2,
1813-
],
1814-
},
1815-
"vlen" => {
1816-
"base": {
1817-
"class": "Integer",
1818-
"endianness": "little-endian",
1819-
"signed": false,
1820-
"size": 64,
1821-
},
1822-
"class": "Array (variable length)",
1823-
},
1824-
},
1825-
},
1826-
"value": [
1827-
[
18281799
[
18291800
0,
18301801
1,
18311802
],
18321803
[
1833-
0,
1804+
[
1805+
1,
1806+
2,
1807+
],
1808+
3,
1809+
[],
18341810
],
18351811
],
18361812
[
1813+
false,
18371814
[
18381815
2,
18391816
3,
18401817
],
18411818
[
1842-
0,
1843-
1,
1844-
],
1845-
],
1846-
[
1847-
[
1848-
4,
1849-
5,
1850-
],
1851-
[
1852-
0,
1853-
1,
1854-
2,
1819+
[
1820+
4,
1821+
5,
1822+
],
1823+
6,
1824+
[
1825+
42,
1826+
],
18551827
],
18561828
],
18571829
],

0 commit comments

Comments
 (0)