From 48579d24755b1d759ca9a1e1dc3136d275831b92 Mon Sep 17 00:00:00 2001 From: luiz Date: Wed, 23 Apr 2025 10:12:00 +0200 Subject: [PATCH 1/2] fix overflow --- neo/rawio/blackrockrawio.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/neo/rawio/blackrockrawio.py b/neo/rawio/blackrockrawio.py index b650acfa5..d6ace4299 100644 --- a/neo/rawio/blackrockrawio.py +++ b/neo/rawio/blackrockrawio.py @@ -1058,8 +1058,8 @@ def __read_nsx_data_variant_a(self, nsx_nb): filename = ".".join([self._filenames["nsx"], f"ns{nsx_nb}"]) # get shape of data - shape = (self.__nsx_params["2.1"](nsx_nb)["nb_data_points"], self.__nsx_basic_header[nsx_nb]["channel_count"]) - offset = self.__nsx_params["2.1"](nsx_nb)["bytes_in_headers"] + shape = (int(self.__nsx_params["2.1"](nsx_nb)["nb_data_points"]), int(self.__nsx_basic_header[nsx_nb]["channel_count"])) + offset = int(self.__nsx_params["2.1"](nsx_nb)["bytes_in_headers"]) # read nsx data # store as dict for compatibility with higher file specs @@ -1831,7 +1831,7 @@ def __get_file_size(self, filename): file_size = filebuf.tell() filebuf.close() - return file_size + return int(file_size) def __get_min_time(self): """ @@ -2007,8 +2007,8 @@ def __get_nsx_param_variant_a(self, nsx_nb): nsx_parameters = { "nb_data_points": int( - (self.__get_file_size(filename) - bytes_in_headers) - / (2 * self.__nsx_basic_header[nsx_nb]["channel_count"]) + (int(self.__get_file_size(filename)) - int(bytes_in_headers)) + / int(2 * self.__nsx_basic_header[nsx_nb]["channel_count"]) - 1 ), "labels": labels, From 065c155e7c05979907e5bd61c8b4e30442a9d29b Mon Sep 17 00:00:00 2001 From: luiz Date: Wed, 23 Apr 2025 14:48:53 +0200 Subject: [PATCH 2/2] int --- neo/rawio/blackrockrawio.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/neo/rawio/blackrockrawio.py b/neo/rawio/blackrockrawio.py index d6ace4299..be0f62091 100644 --- a/neo/rawio/blackrockrawio.py +++ b/neo/rawio/blackrockrawio.py @@ -1078,10 +1078,10 @@ def __read_nsx_data_variant_b(self, nsx_nb): for data_bl in self.__nsx_data_header[nsx_nb].keys(): # get shape and offset of data shape = ( - self.__nsx_data_header[nsx_nb][data_bl]["nb_data_points"], - self.__nsx_basic_header[nsx_nb]["channel_count"], + int(self.__nsx_data_header[nsx_nb][data_bl]["nb_data_points"]), + int(self.__nsx_basic_header[nsx_nb]["channel_count"]), ) - offset = self.__nsx_data_header[nsx_nb][data_bl]["offset_to_data_block"] + offset = int(self.__nsx_data_header[nsx_nb][data_bl]["offset_to_data_block"]) # read data data[data_bl] = np.memmap(filename, dtype="int16", shape=shape, offset=offset, mode="r") @@ -1828,10 +1828,10 @@ def __get_file_size(self, filename): """ filebuf = open(filename, "rb") filebuf.seek(0, os.SEEK_END) - file_size = filebuf.tell() + file_size = int(filebuf.tell()) filebuf.close() - return int(file_size) + return file_size def __get_min_time(self): """