Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Mar 28, 2024
1 parent d16be50 commit e83257d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
12 changes: 4 additions & 8 deletions src/hdmf/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ def append_data(data, arg):
data.append(arg)
return data
elif isinstance(data, np.ndarray):
if isinstance(arg, np.ndarray):
if data.ndim == arg.ndim:
# arg is a structured array or an array with matching data
# dimensions
return np.append(data, arg)
else: # arg is a row vector
return np.append(data, np.expand_dims(arg, axis=0), axis=0)
else: # arg is a scalar
if len(data.dtype)>0:
# data is a structured array
return np.append(data, arg)
else: # arg is a scalar or row vector
return np.append(data, np.expand_dims(arg, axis=0), axis=0)
elif isinstance(data, h5py.Dataset):
shape = list(data.shape)
Expand Down
10 changes: 1 addition & 9 deletions tests/unit/common/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,6 @@ def test_compound_data_append(self):

np.testing.assert_array_equal(compound_vector_data.data, np.append(c_data, c_data2))

def test_append_array(self):
a = np.array([[1, 2, 3]])
b = np.array([7, 8, 9])
col = VectorData(name='foo', description='...', data=a)
col.append(b)

np.testing.assert_array_equal(col.data, np.array([[1,2,3],[7,8,9]]))

def test_compound_data_extend(self):
c_data = np.array([('Homo sapiens', 24)], dtype=[('species', 'U50'), ('age', 'i4')])
c_data2 = np.array([('Mus musculus', 24)], dtype=[('species', 'U50'), ('age', 'i4')])
Expand All @@ -256,7 +248,7 @@ def test_compound_data_extend(self):
@unittest.skipIf(not LINKML_INSTALLED, "optional LinkML module is not installed")
def test_add_ref_wrapped_array_append(self):
data = np.array(['Homo sapiens'])
data2 = np.array(['Mus musculus'])
data2 = 'Mus musculus'
terms = TermSet(term_schema_path='tests/unit/example_test_term_set.yaml')
vector_data = VectorData(
name='Species_1',
Expand Down

0 comments on commit e83257d

Please sign in to comment.