Skip to content

Commit

Permalink
fix qa
Browse files Browse the repository at this point in the history
  • Loading branch information
Helveg committed Mar 28, 2024
1 parent e1abe1a commit f0525a1
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 75 deletions.
10 changes: 7 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.1.1
hooks:
- id: black
language_version: python3
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
26 changes: 12 additions & 14 deletions bsb_hdf5/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@
HDF5 storage engine for the BSB framework.
"""

from bsb import (
config,
__version__ as bsb_version,
MPILock,
Engine,
StorageNode as IStorageNode,
NoopLock,
)
from .placement_set import PlacementSet
from .connectivity_set import ConnectivitySet
from .file_store import FileStore
from .morphology_repository import MorphologyRepository
from datetime import datetime
import json
import h5py
import os
import shutil
from datetime import datetime

import h5py
import shortuuid
from bsb import Engine, MPILock, NoopLock
from bsb import StorageNode as IStorageNode
from bsb import __version__ as bsb_version
from bsb import config

from .connectivity_set import ConnectivitySet
from .file_store import FileStore
from .morphology_repository import MorphologyRepository
from .placement_set import PlacementSet

__version__ = "4.0.0-rc2"
__all__ = [
Expand Down
8 changes: 5 additions & 3 deletions bsb_hdf5/chunks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
objects within them.
"""

from bsb import Chunk, chunklist
import numpy as np
import contextlib
from .resource import handles_handles, HANDLED

import numpy as np
from bsb import Chunk, chunklist

from .resource import HANDLED, handles_handles


class ChunkLoader:
Expand Down
15 changes: 7 additions & 8 deletions bsb_hdf5/connectivity_set.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import json

import errr
from bsb import (
DatasetNotFoundError,
Chunk,
chunklist,
ConnectivitySet as IConnectivitySet,
)
from .resource import Resource, handles_handles, HANDLED
import numpy as np
import json
from bsb import Chunk
from bsb import ConnectivitySet as IConnectivitySet
from bsb import DatasetNotFoundError, chunklist

from .resource import HANDLED, Resource, handles_handles

_root = "/connectivity/"

Expand Down
7 changes: 4 additions & 3 deletions bsb_hdf5/file_store.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import json
import time
from uuid import uuid4

import numpy as np
from bsb.storage.interfaces import FileStore as IFileStore
from bsb.exceptions import MissingActiveConfigError
from bsb.storage.interfaces import FileStore as IFileStore

from .resource import Resource
from uuid import uuid4
import json

_root = "files"

Expand Down
20 changes: 10 additions & 10 deletions bsb_hdf5/morphology_repository.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from bsb.morphologies import Morphology, Branch
from bsb._encoding import EncodedLabels
from bsb.exceptions import MorphologyRepositoryError, MissingMorphologyError
from bsb.storage.interfaces import (
MorphologyRepository as IMorphologyRepository,
StoredMorphology,
)
from .resource import Resource, handles_handles, HANDLED
import numpy as np
import json
import itertools
import json

import numpy as np
from bsb._encoding import EncodedLabels
from bsb.exceptions import MissingMorphologyError, MorphologyRepositoryError
from bsb.morphologies import Branch, Morphology
from bsb.storage.interfaces import MorphologyRepository as IMorphologyRepository
from bsb.storage.interfaces import StoredMorphology

from .resource import HANDLED, Resource, handles_handles

_root = "/morphologies"

Expand Down
22 changes: 12 additions & 10 deletions bsb_hdf5/placement_set.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import itertools
import json

import numpy as np
from bsb import config
from bsb._encoding import EncodedLabels
from bsb.exceptions import (
MissingMorphologyError,
DatasetExistsError,
DatasetNotFoundError,
MissingMorphologyError,
)
from bsb import config
from bsb.storage._chunks import Chunk, chunklist
from bsb._encoding import EncodedLabels
from bsb.storage.interfaces import PlacementSet as IPlacementSet
from bsb.morphologies import MorphologySet, RotationSet
from bsb.morphologies.selector import MorphologySelector
from .resource import Resource, handles_handles, HANDLED
from .chunks import ChunkLoader, ChunkedProperty, ChunkedCollection
import numpy as np
import itertools
import json
from bsb.storage._chunks import Chunk, chunklist
from bsb.storage.interfaces import PlacementSet as IPlacementSet

from .chunks import ChunkedCollection, ChunkedProperty, ChunkLoader
from .resource import HANDLED, Resource, handles_handles

_root = "/placement/"

Expand Down
9 changes: 5 additions & 4 deletions bsb_hdf5/resource.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import functools
import inspect
import typing

import numpy as np
import h5py
import inspect
import functools
import numpy as np

if typing.TYPE_CHECKING:
from . import HDF5Engine
Expand Down Expand Up @@ -57,7 +57,8 @@ def __init__(self, engine: "HDF5Engine", path: str):

def __eq__(self, other):
return (
self._engine == getattr(other, "_engine", None) and self._path == other._path
self._engine == getattr(other, "_engine", None)
and self._path == other._path
)

def require(self, handle):
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ docs = [
"sphinx-copybutton==0.5.0"
]

[tool.isort]
profile = "black"

[tool.flit.module]
name = "bsb_hdf5"

Expand Down
2 changes: 1 addition & 1 deletion test/test_chunks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
from bsb.core import Scaffold
from bsb.storage import Chunk
from bsb_test import NumpyTestCase, skip_parallel, timeout, RandomStorageFixture
from bsb_test import NumpyTestCase, RandomStorageFixture, skip_parallel, timeout
from bsb_test.configs import get_test_config


Expand Down
8 changes: 5 additions & 3 deletions test/test_cs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from bsb.services.pool import WorkflowError
from bsb_test import FixedPosConfigFixture, RandomStorageFixture, NumpyTestCase
import unittest

from bsb.core import Scaffold
from bsb.services.pool import WorkflowError
from bsb_test import FixedPosConfigFixture, NumpyTestCase, RandomStorageFixture

from bsb_hdf5.connectivity_set import LocationOutOfBoundsError
import unittest


class TestConnectivitySet(
Expand Down
11 changes: 5 additions & 6 deletions test/test_interface.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from bsb_test.engines import (
TestStorage as _TestStorage,
TestPlacementSet as _TestPlacementSet,
TestMorphologyRepository as _TestMorphologyRepository,
TestConnectivitySet as _TestConnectivitySet,
)
import unittest

from bsb_test.engines import TestConnectivitySet as _TestConnectivitySet
from bsb_test.engines import TestMorphologyRepository as _TestMorphologyRepository
from bsb_test.engines import TestPlacementSet as _TestPlacementSet
from bsb_test.engines import TestStorage as _TestStorage


class TestStorage(_TestStorage, unittest.TestCase, engine_name="hdf5"):
pass
Expand Down
19 changes: 10 additions & 9 deletions test/test_mr.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from bsb.services import MPI
from bsb.storage import Storage
import numpy as np
import unittest
import json
import h5py
import os
import unittest

import h5py
import numpy as np
from bsb.services import MPI
from bsb.storage import Storage


class TestHandcrafted(unittest.TestCase):
Expand Down Expand Up @@ -60,7 +61,9 @@ def setUpClass(cls):
ds = g.create_dataset("data", data=data)
ds.attrs["labels"] = json.dumps({1: []})
ds.attrs["properties"] = []
g.create_dataset("graph", data=[[i + 1, -1] for i in range(4)] + [[5, 0]])
g.create_dataset(
"graph", data=[[i + 1, -1] for i in range(4)] + [[5, 0]]
)
f.create_dataset("morphology_meta", data=json.dumps({"M": {}}))
MPI.barrier()

Expand Down Expand Up @@ -121,9 +124,7 @@ def test_multi_branch_single_element(self):
msg = "Single point unattached branches should still be root."
self.assertEqual(5, len(m.roots), msg)
self.assertEqual(5, len(m.branches), "Missing branch")
msg = (
"Flatten of single point branches should produce n-branch x n-vectors matrix."
)
msg = "Flatten of single point branches should produce n-branch x n-vectors matrix."
matrix = m.flatten()
self.assertEqual((5, 3), matrix.shape, msg)
msg = "Flatten produced an incorrect matrix"
Expand Down
6 changes: 5 additions & 1 deletion test/test_setup/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import os, sys, unittest, threading
import os
import sys
import threading
import unittest

import numpy as np

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
Expand Down

0 comments on commit f0525a1

Please sign in to comment.