Skip to content

Commit

Permalink
deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Nov 13, 2024
1 parent 1cb27a3 commit 4005204
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/hdmf/build/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def get_dt_container_cls(self, **kwargs):
If no class has been associated with the ``data_type`` from ``namespace``, a class will be dynamically
created and returned.
Replaces get_container_cls but namespace is optional. If namespace is unknown, it will be looked up from
Namespace is optional. If namespace is unknown, it will be looked up from
all namespaces.
"""
namespace, data_type, post_init_method, autogen = getargs('namespace', 'data_type',
Expand Down
4 changes: 2 additions & 2 deletions src/hdmf/common/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,8 @@ def add_column(self, **kwargs): # noqa: C901
index, table, enum, col_cls, check_ragged = popargs('index', 'table', 'enum', 'col_cls', 'check_ragged', kwargs)

if isinstance(index, VectorIndex):
warn("Passing a VectorIndex in for index may lead to unexpected behavior. This functionality will be "
"deprecated in a future version of HDMF.", category=FutureWarning, stacklevel=3)
msg = "Passing a VectorIndex may lead to unexpected behavior. This functionality is not supported."
raise ValueError(msg)

if name in self.__colids: # column has already been added
msg = "column '%s' already exists in %s '%s'" % (name, self.__class__.__name__, self.name)
Expand Down
29 changes: 0 additions & 29 deletions src/hdmf/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,21 +467,6 @@ def set_modified(self, **kwargs):
def children(self):
return tuple(self.__children)

@docval({'name': 'child', 'type': 'Container',
'doc': 'the child Container for this Container', 'default': None})
def add_child(self, **kwargs):
warn(DeprecationWarning('add_child is deprecated. Set the parent attribute instead.'))
child = getargs('child', kwargs)
if child is not None:
# if child.parent is a Container, then the mismatch between child.parent and parent
# is used to make a soft/external link from the parent to a child elsewhere
# if child.parent is not a Container, it is either None or a Proxy and should be set to self
if not isinstance(child.parent, AbstractContainer):
# actually add the child to the parent in parent setter
child.parent = self
else:
warn('Cannot add None as child to a container %s' % self.name)

@classmethod
def type_hierarchy(cls):
return cls.__mro__
Expand Down Expand Up @@ -913,20 +898,6 @@ def shape(self):
"""
return get_data_shape(self.__data)

@docval({'name': 'dataio', 'type': DataIO, 'doc': 'the DataIO to apply to the data held by this Data'})
def set_dataio(self, **kwargs):
"""
Apply DataIO object to the data held by this Data object
"""
warn(
"Data.set_dataio() is deprecated. Please use Data.set_data_io() instead.",
DeprecationWarning,
stacklevel=3,
)
dataio = getargs('dataio', kwargs)
dataio.data = self.__data
self.__data = dataio

def set_data_io(
self,
data_io_class: Type[DataIO],
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/common/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,7 @@ def test_add_column_vectorindex(self):
table.add_column(name='qux', description='qux column')
ind = VectorIndex(name='quux', data=list(), target=table['qux'])

msg = ("Passing a VectorIndex in for index may lead to unexpected behavior. This functionality will be "
"deprecated in a future version of HDMF.")
with self.assertWarnsWith(FutureWarning, msg):
with self.assertRaises(ValueError):
table.add_column(name='bad', description='bad column', index=ind)

def test_add_column_multi_index(self):
Expand Down
12 changes: 0 additions & 12 deletions tests/unit/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,6 @@ def test_all_children(self):
obj = species.all_objects
self.assertEqual(sorted(list(obj.keys())), sorted([species.object_id, species.id.object_id, col1.object_id]))

def test_add_child(self):
"""Test that add child creates deprecation warning and also properly sets child's parent and modified
"""
parent_obj = Container('obj1')
child_obj = Container('obj2')
parent_obj.set_modified(False)
with self.assertWarnsWith(DeprecationWarning, 'add_child is deprecated. Set the parent attribute instead.'):
parent_obj.add_child(child_obj)
self.assertIs(child_obj.parent, parent_obj)
self.assertTrue(parent_obj.modified)
self.assertIs(parent_obj.children[0], child_obj)

def test_parent_set_link_warning(self):
col1 = VectorData(
name='col1',
Expand Down
27 changes: 2 additions & 25 deletions tests/unit/utils_test/test_core_DataIO.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from copy import copy, deepcopy

import numpy as np
from hdmf.container import Data
from hdmf.data_utils import DataIO
from hdmf.testing import TestCase
import warnings


class DataIOTests(TestCase):
Expand All @@ -30,34 +28,13 @@ def test_dataio_slice_delegation(self):
dset = DataIO(indata)
self.assertTrue(np.all(dset[1:3, 5:8] == indata[1:3, 5:8]))

def test_set_dataio(self):
"""
Test that Data.set_dataio works as intended
"""
dataio = DataIO()
data = np.arange(30).reshape(5, 2, 3)
container = Data('wrapped_data', data)
msg = "Data.set_dataio() is deprecated. Please use Data.set_data_io() instead."
with self.assertWarnsWith(DeprecationWarning, msg):
container.set_dataio(dataio)
self.assertIs(dataio.data, data)
self.assertIs(dataio, container.data)

def test_set_dataio_data_already_set(self):
def test_set_data_io_data_already_set(self):
"""
Test that Data.set_dataio works as intended
"""
dataio = DataIO(data=np.arange(30).reshape(5, 2, 3))
data = np.arange(30).reshape(5, 2, 3)
container = Data('wrapped_data', data)
with self.assertRaisesWith(ValueError, "cannot overwrite 'data' on DataIO"):
with warnings.catch_warnings(record=True):
warnings.filterwarnings(
action='ignore',
category=DeprecationWarning,
message="Data.set_dataio() is deprecated. Please use Data.set_data_io() instead.",
)
container.set_dataio(dataio)
dataio.data=[1,2,3,4]

def test_dataio_options(self):
"""
Expand Down

0 comments on commit 4005204

Please sign in to comment.