diff --git a/setup.cfg b/setup.cfg index 90cc2f5..9911b21 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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] diff --git a/tests/test_parameter.py b/tests/test_parameter.py index 45636a9..05ae071 100644 --- a/tests/test_parameter.py +++ b/tests/test_parameter.py @@ -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 @@ -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): @@ -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): diff --git a/trsfile/traceparameter.py b/trsfile/traceparameter.py index 494115d..51b5184 100644 --- a/trsfile/traceparameter.py +++ b/trsfile/traceparameter.py @@ -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 @@ -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)) @@ -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