Skip to content

Commit 05e37fd

Browse files
fm3jstriebel
andauthored
Assert that numpy arg to vec3int has integer values (#434)
* Assert that numpy arg to vec3int has integer values * Update Changelog.md Co-authored-by: Jonathan Striebel <[email protected]>
1 parent 325e10f commit 05e37fd

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

webknossos/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ For upgrade instructions, please check the respective *Breaking Changes* section
1212
### Breaking Changes
1313
### Added
1414
### Changed
15+
- The `Vec3Int` constructor now asserts that its components are whole numbers also in numpy case. [#434](https://github.com/scalableminds/webknossos-libs/pull/434)
1516
### Fixed
1617

1718
## [0.8.16](https://github.com/scalableminds/webknossos-cuber/releases/tag/v0.8.16) - 2021-09-22

webknossos/webknossos/geometry/vec3_int.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __new__(
1515
return vec
1616

1717
as_tuple: Optional[Tuple[int, int, int]] = None
18-
value_error = "Vector components must be three integers or a Vec3IntLike object"
18+
value_error = f"Vector components must be three integers or a Vec3IntLike object, got {vec}, {y}, {z}"
1919

2020
if isinstance(vec, int):
2121
assert y is not None and z is not None, value_error
@@ -24,6 +24,7 @@ def __new__(
2424
else:
2525
assert y is None and z is None, value_error
2626
if isinstance(vec, np.ndarray):
27+
assert np.count_nonzero(vec % 1) == 0, value_error
2728
assert vec.shape == (
2829
3,
2930
), f"Numpy array for Vec3Int must have shape (3,), got {vec.shape}."

0 commit comments

Comments
 (0)