Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ packages =
trsfile.engine
trsfile.converters
install_requires =
numpy>=1,<2
numpy>=1.24,<3
include_package_data = True

[options.extras_require]
Expand Down
12 changes: 6 additions & 6 deletions tests/test_parameter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from io import BytesIO
from unittest import TestCase

from numpy import ndarray, int16, array, int32, int64, single, double, uint8, int8, uint16, bool8
from numpy import ndarray, int16, array, int32, int64, single, double, uint8, int8, uint16

from trsfile.traceparameter import BooleanArrayParameter, ByteArrayParameter, DoubleArrayParameter, FloatArrayParameter, \
IntegerArrayParameter, ShortArrayParameter, LongArrayParameter, StringParameter
Expand All @@ -13,8 +13,8 @@ def test_bool_parameter(self):
param1 = BooleanArrayParameter([True, False, True])
self.assertEqual(serialized_param, param1.serialize())
self.assertEqual(BooleanArrayParameter.deserialize(BytesIO(serialized_param), 3), param1)
param2 = BooleanArrayParameter(ndarray(shape=[3], dtype=bool8,
buffer=array([bool8(val) for val in [True, False, True]])))
param2 = BooleanArrayParameter(ndarray(shape=[3], dtype=bool,
buffer=array([bool(val) for val in [True, False, True]])))
self.assertEqual(param1, param2)

with self.assertRaises(TypeError):
Expand Down Expand Up @@ -47,10 +47,10 @@ def test_byte_parameter(self):
ByteArrayParameter([0, '1'])
with self.assertRaises(TypeError):
ByteArrayParameter([bytes([0, 1, 2, 3]), bytes([4, 5, 6, 7])])
with self.assertRaises(OverflowError):
ByteArrayParameter(ndarray(shape=[16], dtype=int8, buffer=array(int_data, dtype=int8)))
with self.assertRaises(TypeError):
ByteArrayParameter(ndarray(shape=[16], dtype=int8, buffer=array([int8(val) for val in int_data])))
with self.assertRaises(TypeError):
ByteArrayParameter(ndarray(shape=[16], dtype=uint16, buffer=array([uint16(val) for val in int_data])))
ByteArrayParameter(ndarray(shape=[16], dtype=uint16, buffer=array(int_data, dtype=uint16)))
with self.assertRaises(ValueError):
ByteArrayParameter([])
with self.assertRaises(ValueError):
Expand Down
6 changes: 3 additions & 3 deletions trsfile/traceparameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from io import BytesIO
from typing import Any

from numpy import ndarray, integer, bool8, uint8, double, single
from numpy import ndarray, integer, uint8, double, single

from trsfile.utils import encode_as_short, read_short

Expand Down Expand Up @@ -75,7 +75,7 @@ def deserialize(io_bytes: BytesIO) -> TraceSetParameter:


class BooleanArrayParameter(TraceParameter):
_expected_type_string = "List[bool] or ndarray[bool8]"
_expected_type_string = "List[bool] or ndarray[bool]"

def __len__(self):
return len(bytes(self.value))
Expand All @@ -96,7 +96,7 @@ def _has_expected_type(value: Any) -> bool:
if type(value) is list:
return all(isinstance(elem, bool) for elem in value)
elif type(value) is ndarray:
return all(isinstance(elem, bool8) for elem in value)
return value.dtype == bool
return False


Expand Down