Skip to content

Commit

Permalink
Merge branch 'dev' into numpy_2
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Jul 7, 2024
2 parents 871625e + 62edbe4 commit 7df9554
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/project_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
- name: Add to Developer Board
env:
TOKEN: ${{ steps.generate_token.outputs.token }}
uses: actions/add-to-project@v0.6.1
uses: actions/add-to-project@v1.0.1
with:
project-url: https://github.com/orgs/hdmf-dev/projects/7
github-token: ${{ env.TOKEN }}

- name: Add to Community Board
env:
TOKEN: ${{ steps.generate_token.outputs.token }}
uses: actions/add-to-project@v0.6.1
uses: actions/add-to-project@v1.0.1
with:
project-url: https://github.com/orgs/hdmf-dev/projects/8
github-token: ${{ env.TOKEN }}
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ dependencies = [
"pandas>=1.0.5",
"ruamel.yaml>=0.16",
"scipy>=1.4",
"zarr >= 2.12.0",
"importlib-resources; python_version < '3.9'", # TODO: remove when minimum python version is 3.9
]
dynamic = ["version"]
Expand Down
13 changes: 9 additions & 4 deletions src/hdmf/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
from warnings import warn
from typing import Tuple
from itertools import product, chain
from zarr import Array as ZarrArray

try:
from zarr import Array as ZarrArray
ZARR_INSTALLED = True
except ImportError:
ZARR_INSTALLED = False

import h5py
import numpy as np
Expand All @@ -16,9 +21,6 @@ def append_data(data, arg):
if isinstance(data, (list, DataIO)):
data.append(arg)
return data
elif isinstance(data, ZarrArray):
data.append([arg], axis=0)
return data
elif type(data).__name__ == 'TermSetWrapper': # circular import
data.append(arg)
return data
Expand All @@ -33,6 +35,9 @@ def append_data(data, arg):
data.resize(shape)
data[-1] = arg
return data
elif ZARR_INSTALLED and isinstance(data, ZarrArray):
data.append([arg], axis=0)
return data
else:
msg = "Data cannot append to object of type '%s'" % type(data)
raise ValueError(msg)
Expand Down
25 changes: 24 additions & 1 deletion tests/unit/utils_test/test_data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,32 @@

import numpy as np
from numpy.testing import assert_array_equal
import zarr

try:
import zarr
ZARR_INSTALLED = True
except ImportError:
ZARR_INSTALLED = False


class MyIterable:
def __init__(self, data):
self.data = data


class TestAppendData(TestCase):
def test_append_exception(self):
data = MyIterable([1, 2, 3, 4, 5])
with self.assertRaises(ValueError):
append_data(data, 4)


class TestZarrAppendData(TestCase):

def setUp(self):
if not ZARR_INSTALLED:
self.skipTest("optional Zarr package is not installed")


def test_append_data_zarr(self):
zarr_array = zarr.array([1,2,3])
Expand Down

0 comments on commit 7df9554

Please sign in to comment.