Skip to content

Commit

Permalink
Merge branch 'dev' into improve_error
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 authored Aug 19, 2024
2 parents 5700a07 + 875712b commit 23668f8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
# hooks:
# - id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.9
rev: v0.5.7
hooks:
- id: ruff
# - repo: https://github.com/econchick/interrogate
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
- Added new attribute "dimension_labels" on `DatasetBuilder` which specifies the names of the dimensions used in the
dataset based on the shape of the dataset data and the dimension names in the spec for the data type. This attribute
is available on build (during the write process), but not on read of a dataset from a file. @rly [#1081](https://github.com/hdmf-dev/hdmf/pull/1081)
- Speed up loading namespaces by skipping register_type when already registered. @magland [#1102](https://github.com/hdmf-dev/hdmf/pull/1102)
- Speed up namespace loading: return a shallow copy rather than a deep copy in build_const_args. @magland [#1103](https://github.com/hdmf-dev/hdmf/pull/1103)

## HDMF 3.14.2 (July 7, 2024)

Expand Down
20 changes: 12 additions & 8 deletions src/hdmf/spec/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,15 +466,19 @@ def __load_namespace(self, namespace, reader, resolve=True):
return included_types

def __register_type(self, ndt, inc_ns, catalog, registered_types):
spec = inc_ns.get_spec(ndt)
spec_file = inc_ns.catalog.get_spec_source_file(ndt)
self.__register_dependent_types(spec, inc_ns, catalog, registered_types)
if isinstance(spec, DatasetSpec):
built_spec = self.dataset_spec_cls.build_spec(spec)
if ndt in registered_types:
# already registered
pass
else:
built_spec = self.group_spec_cls.build_spec(spec)
registered_types.add(ndt)
catalog.register_spec(built_spec, spec_file)
spec = inc_ns.get_spec(ndt)
spec_file = inc_ns.catalog.get_spec_source_file(ndt)
self.__register_dependent_types(spec, inc_ns, catalog, registered_types)
if isinstance(spec, DatasetSpec):
built_spec = self.dataset_spec_cls.build_spec(spec)
else:
built_spec = self.group_spec_cls.build_spec(spec)
registered_types.add(ndt)
catalog.register_spec(built_spec, spec_file)

def __register_dependent_types(self, spec, inc_ns, catalog, registered_types):
"""Ensure that classes for all types used by this type are registered
Expand Down
3 changes: 1 addition & 2 deletions src/hdmf/spec/spec.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
from abc import ABCMeta
from collections import OrderedDict
from copy import deepcopy
from warnings import warn

from ..utils import docval, getargs, popargs, get_docval
Expand Down Expand Up @@ -84,7 +83,7 @@ class ConstructableDict(dict, metaclass=ABCMeta):
def build_const_args(cls, spec_dict):
''' Build constructor arguments for this ConstructableDict class from a dictionary '''
# main use cases are when spec_dict is a ConstructableDict or a spec dict read from a file
return deepcopy(spec_dict)
return spec_dict.copy()

@classmethod
def build_spec(cls, spec_dict):
Expand Down

0 comments on commit 23668f8

Please sign in to comment.