Skip to content

Commit

Permalink
Merge pull request #19 from VisLab/main
Browse files Browse the repository at this point in the history
Fussing with the imports to remove Ruff complaints
  • Loading branch information
VisLab authored Aug 5, 2024
2 parents d3caf1e + 507aaa4 commit e21883f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 111 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ user guide explains in more detail how to use this extension for HED.
pip install -U ndx-hed
```

**Matlab:** The Matlab extension is under development
**Matlab:** The Matlab extension is under development.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ preview = true
exclude = ".git|.mypy_cache|.tox|.venv|venv|.ipynb_checkpoints|_build/|dist/|__pypackages__|.ipynb|docs/"

[tool.ruff]
select = ["E", "F", "T100", "T201", "T203"]
lint.select = ["E", "F", "T100", "T201", "T203"]
exclude = [
".git",
".tox",
Expand All @@ -114,8 +114,8 @@ exclude = [
]
line-length = 120

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"src/spec/create_extension_spec.py" = ["T201"]

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 17
62 changes: 0 additions & 62 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,3 @@
if __name__ == "__main__":
setup()

# import os
#
# from setuptools import setup, find_packages
# from shutil import copy2
#
# # load README.md/README.rst file
# try:
# if os.path.exists('README.md'):
# with open('README.md', 'r') as fp:
# readme = fp.read()
# readme_type = 'text/markdown; charset=UTF-8'
# elif os.path.exists('README.rst'):
# with open('README.rst', 'r') as fp:
# readme = fp.read()
# readme_type = 'text/x-rst; charset=UTF-8'
# else:
# readme = ""
# except Exception:
# readme = ""
#
# setup_args = {
# 'name': 'ndx-hed',
# 'version': '0.1.0',
# 'description': 'NWB extension for storing HED annotations in VectorData format.',
# 'long_description': readme,
# 'long_description_content_type': readme_type,
# 'author': 'Ryan Ly, Kay Robbins',
# 'author_email': 'rly@lbl.gov, Kay.Robbins@utsa.edu',
# 'url': 'https://github.com/hed-standard/ndx-hed',
# 'license': 'BSD 3-Clause',
# 'install_requires': [
# 'pynwb>=1.1.2'
# ],
# 'packages': find_packages('src/pynwb'),
# 'package_dir': {'': 'src/pynwb'},
# 'package_data': {'ndx_hed': [
# 'spec/ndx-hed.namespace.yaml',
# 'spec/ndx-hed.extensions.yaml',
# ]},
# 'classifiers': [
# "Intended Audience :: Developers",
# "Intended Audience :: Science/Research",
# ],
# 'zip_safe': False
# }
#
#
# def _copy_spec_files(project_dir):
# ns_path = os.path.join(project_dir, 'spec', 'ndx-hed.namespace.yaml')
# ext_path = os.path.join(project_dir, 'spec', 'ndx-hed.extensions.yaml')
#
# dst_dir = os.path.join(project_dir, 'src', 'pynwb', 'ndx_hed', 'spec')
# if not os.path.exists(dst_dir):
# os.mkdir(dst_dir)
#
# copy2(ns_path, dst_dir)
# copy2(ext_path, dst_dir)
#
#
# if __name__ == '__main__':
# _copy_spec_files(os.path.dirname(__file__))
# setup(**setup_args)
43 changes: 4 additions & 39 deletions src/pynwb/ndx_hed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@
from pynwb import load_namespaces, get_class

# Set path of the namespace.yaml file to the expected install location
ndx_hed_specpath = os.path.join(
os.path.dirname(__file__),
'spec',
'ndx-hed.namespace.yaml'
)
ndx_hed_specpath = os.path.join(os.path.dirname(__file__), 'spec', 'ndx-hed.namespace.yaml')

# If the extension has not been installed yet but we are running directly from
# the git repo
# If the extension has not been installed yet, but we are running directly from the git repo
if not os.path.exists(ndx_hed_specpath):
ndx_hed_specpath = os.path.abspath(os.path.join(
os.path.dirname(__file__),
Expand All @@ -20,37 +15,7 @@

# Load the namespace
load_namespaces(ndx_hed_specpath)
#
# from . import io as __io # noqa: E402,F401
# from .hed_models import NWBHedVersion
#
# try:
# from importlib.resources import files
# except ImportError:
# # TODO: Remove when python 3.9 becomes the new minimum
# from importlib_resources import files
#
#
#
# # Get path to the namespace.yaml file with the expected location when installed not in editable mode
# __location_of_this_file = files(__name__)
# __spec_path = __location_of_this_file / "spec" / "ndx-hed.namespace.yaml"
#
# # If that path does not exist, we are likely running in editable mode. Use the local path instead
# if not os.path.exists(__spec_path):
# __spec_path = __location_of_this_file.parent.parent.parent / "spec" / "ndx-hed.namespace.yaml"
#
# # Load the namespace
# load_namespaces(str(__spec_path))
#
# # TODO: Define your classes here to make them accessible at the package level.
# # Either have PyNWB generate a class from the spec using `get_class` as shown
# # below or write a custom class and register it using the class decorator
# # `@register_class("TetrodeSeries", "ndx-hed")`
# # HedAnnotations = get_class("HedAnnotations", "ndx-hed")
# HedVersion = get_class("HedVersion", "ndx-hed")
#
# # Remove these functions from the package

del load_namespaces, get_class

from .hed_tags import HedTags
#from .hed_tags import HedTags as HedTags
4 changes: 2 additions & 2 deletions src/pynwb/tests/test_hed_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pynwb import NWBHDF5IO, NWBFile
from pynwb.testing.mock.file import mock_NWBFile
from pynwb.testing import TestCase, remove_test_file
from ndx_hed import HedTags
from ndx_hed.hed_tags import HedTags


class TestHedTagsConstructor(TestCase):
Expand Down Expand Up @@ -68,7 +68,7 @@ def test_get(self):
def test_temp(self):
tags = HedTags(hed_version='8.3.0', data=["Correct-action", "Incorrect-action"])
tags.add_row("Sensory-event, Visual-presentation")
print(tags)

def test_dynamic_table(self):
"""Add a HED column to a DynamicTable."""
my_table = DynamicTable(
Expand Down
5 changes: 1 addition & 4 deletions src/spec/create_extension_spec.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# -*- coding: utf-8 -*-
import os.path

from pynwb.spec import NWBNamespaceBuilder, export_spec, NWBDatasetSpec, NWBGroupSpec, NWBAttributeSpec

# TODO: import other spec classes as needed
# from pynwb.spec import , NWBLinkSpec, NWBDtypeSpec, NWBRefSpec
from pynwb.spec import NWBNamespaceBuilder, export_spec, NWBDatasetSpec, NWBAttributeSpec


def main():
Expand Down

0 comments on commit e21883f

Please sign in to comment.