From 91875dabb20a2fd0da12332556b595ba23d2b496 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 9 Oct 2023 23:27:33 -0700 Subject: [PATCH] re-enable janky hdmf mapping test just to have it on the board for morale Fix serializing datasets --- nwb_linkml/src/nwb_linkml/types/ndarray.py | 3 +++ nwb_linkml/tests/test_maps/test_hdmf.py | 15 +++++++++++---- nwb_linkml/tests/test_translate.py | 16 ---------------- 3 files changed, 14 insertions(+), 20 deletions(-) delete mode 100644 nwb_linkml/tests/test_translate.py diff --git a/nwb_linkml/src/nwb_linkml/types/ndarray.py b/nwb_linkml/src/nwb_linkml/types/ndarray.py index e1265ce..2477b6c 100644 --- a/nwb_linkml/src/nwb_linkml/types/ndarray.py +++ b/nwb_linkml/src/nwb_linkml/types/ndarray.py @@ -4,6 +4,7 @@ Extension of nptyping NDArray for pydantic that allows for JSON-Schema serializa * Order to store data in (row first) """ import base64 +import pdb from pathlib import Path from typing import ( Any, @@ -119,6 +120,8 @@ class NDArray(_NDArray): def array_to_list(instance: np.ndarray | DaskArray) -> list|dict: if isinstance(instance, DaskArray): arr = instance.__array__() + elif isinstance(instance, NDArrayProxy): + arr = instance[:] else: arr = instance diff --git a/nwb_linkml/tests/test_maps/test_hdmf.py b/nwb_linkml/tests/test_maps/test_hdmf.py index c3bc784..7b022e7 100644 --- a/nwb_linkml/tests/test_maps/test_hdmf.py +++ b/nwb_linkml/tests/test_maps/test_hdmf.py @@ -5,20 +5,27 @@ import h5py import time from nwb_linkml.maps.hdmf import model_from_dynamictable, dynamictable_to_model +from ..fixtures import data_dir NWBFILE = '/Users/jonny/Dropbox/lab/p2p_ld/data/nwb/sub-738651046_ses-760693773.nwb' -@pytest.mark.skip() -def test_make_dynamictable(): - h5f = h5py.File(NWBFILE, 'r') +@pytest.mark.parametrize( + 'dataset', + [ + 'aibs.nwb' + ] +) +def test_make_dynamictable(data_dir, dataset): + nwbfile = data_dir / dataset + h5f = h5py.File(nwbfile, 'r') group = h5f['units'] start_time = time.time() model = model_from_dynamictable(group) data = dynamictable_to_model(group, model) + ser = data.model_dump_json() end_time = time.time() total_time = end_time - start_time - pdb.set_trace() diff --git a/nwb_linkml/tests/test_translate.py b/nwb_linkml/tests/test_translate.py deleted file mode 100644 index 062b26a..0000000 --- a/nwb_linkml/tests/test_translate.py +++ /dev/null @@ -1,16 +0,0 @@ -import pdb - -import pytest -from pathlib import Path -#from nwb_linkml.translate import generate_from_nwbfile - -# def test_generate_pydantic(): -# # pass until we rig up smaller test data -# pass - - #NWBFILE = Path('/Users/jonny/Dropbox/lab/p2p_ld/data/nwb/sub-738651046_ses-760693773.nwb') - - #pydantic_module = generate_from_nwbfile(NWBFILE) - - #pdb.set_trace() -