Skip to content

Commit

Permalink
Fix test_chunks and error printing (#794)
Browse files Browse the repository at this point in the history
* * Fix test_chunks.py configuration

* Remove duplicated exception printing in case of failed node attribute casting.

* Update _attrs.py

---------

Co-authored-by: Robin De Schepper <robin.deschepper93@gmail.com>
  • Loading branch information
drodarie and Helveg committed Jan 9, 2024
1 parent 93cccea commit 00e43c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions bsb/config/_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
An attrs-inspired class annotation system, but my A stands for amateuristic.
"""
import builtins
import traceback

import errr

Expand Down Expand Up @@ -463,12 +462,11 @@ def __set__(self, instance, value):
e.node, e.attr = instance, self.attr_name
raise
except Exception as e:
traceback.print_exc()
raise CastError(
f"Couldn't cast '{value}' into {self.type.__name__}: {e}",
instance,
self.attr_name,
)
) from e
# The value was cast to its intented type and the new value can be set.
_setattr(instance, self.attr_name, value)
root = _strict_root(instance)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_chunks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import unittest

import numpy as np
from bsb_test import NumpyTestCase, skip_parallel, timeout
from bsb_test import NumpyTestCase, get_config_path, skip_parallel, timeout

from bsb.config import from_json
from bsb.core import Scaffold
from bsb.storage import Chunk

Expand Down Expand Up @@ -32,8 +33,7 @@ def test_default_chunk(self):
# basic chunk properties. For example uses `.place` directly.
def test_single_chunk(self):
# Test that specifying a single chunk only reads the data from that chunk
from bsb_test.pyconfig import cfg_single

cfg_single = from_json(get_config_path("test_single"))
self.network = network = Scaffold(cfg_single, clear=True)
self.ps = ps = network.get_placement_set("test_cell")
ps.include_chunk(Chunk((0, 0, 0), None))
Expand Down

0 comments on commit 00e43c6

Please sign in to comment.