Skip to content

Commit 8dcaf49

Browse files
committed
compare as dtype child of np.integer
1 parent b88886b commit 8dcaf49

4 files changed

Lines changed: 10 additions & 13 deletions

File tree

gnss_lib_py/parsers/navdata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def from_pandas_df(self, pandas_df):
121121

122122
dtypes = dict(pandas_df.dtypes)
123123
for row, dtype in dtypes.items():
124-
if np.issubdtype(dtype,int):
124+
if np.issubdtype(dtype,np.integer):
125125
dtype = np.int64
126126
self.orig_dtypes[row] = dtype
127127

@@ -974,7 +974,7 @@ def __setitem__(self, key_idx, new_value):
974974
self.str_map[key_idx] = {}
975975
# update original dtype in case of replacing values
976976
dtype = np.asarray(new_value).dtype
977-
if np.issubdtype(dtype, int):
977+
if np.issubdtype(dtype, np.integer):
978978
dtype = np.int64
979979
self.orig_dtypes[key_idx] = dtype
980980
if self.array.shape == (0,0):
@@ -1020,7 +1020,7 @@ def __setitem__(self, key_idx, new_value):
10201020
# update original dtype in case of replacing values
10211021
for row_index in rows:
10221022
dtype = np.asarray(new_value).dtype
1023-
if np.issubdtype(dtype, int):
1023+
if np.issubdtype(dtype, np.integer):
10241024
dtype = np.int64
10251025
self.orig_dtypes[self.inv_map[row_index]] = dtype
10261026

gnss_lib_py/utils/time_conversions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def unix_millis_to_datetime(unix_millis):
274274
t_utc : datetime.datetime
275275
UTC time as a datetime object.
276276
"""
277-
if np.issubdtype(type(unix_millis),int) or isinstance(unix_millis,np.ndarray):
277+
if np.issubdtype(type(unix_millis), np.integer):
278278
unix_millis = float(unix_millis)
279279
t_utc = UNIX_EPOCH_0 + timedelta(milliseconds=unix_millis)
280280
t_utc = t_utc.replace(tzinfo=timezone.utc)

tests/parsers/test_navdata.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def test_replace_mapper_all(df_simple, rows):
575575
np.array([10,2,46,67,98,300]))
576576

577577
assert new_navdata["names"].dtype == object
578-
assert np.issubdtype(new_navdata["integers"].dtype, int)
578+
assert np.issubdtype(new_navdata["integers"].dtype, np.integer)
579579
assert new_navdata["floats"].dtype == np.float64
580580
assert new_navdata["strings"].dtype == object
581581

@@ -589,7 +589,7 @@ def test_replace_mapper_all(df_simple, rows):
589589
np.array([10,2,46,67,98,300]))
590590

591591
assert data_temp["names"].dtype == object
592-
assert np.issubdtype(data_temp["integers"].dtype, int)
592+
assert np.issubdtype(data_temp["integers"].dtype, np.integer)
593593
assert data_temp["floats"].dtype == np.float64
594594
assert data_temp["strings"].dtype == object
595595

@@ -634,7 +634,7 @@ def test_replace_mapper_partial(df_simple, rows):
634634
np.array([10,2,45,67,98,300]))
635635

636636
assert new_navdata["names"].dtype == object
637-
assert np.issubdtype(new_navdata["integers"].dtype, int)
637+
assert np.issubdtype(new_navdata["integers"].dtype, np.integer)
638638
assert new_navdata["floats"].dtype == np.float64
639639
assert new_navdata["strings"].dtype == object
640640

@@ -648,7 +648,7 @@ def test_replace_mapper_partial(df_simple, rows):
648648
np.array([10,2,45,67,98,300]))
649649

650650
assert data_temp["names"].dtype == object
651-
assert np.issubdtype(data_temp["integers"].dtype, int)
651+
assert np.issubdtype(data_temp["integers"].dtype, np.integer)
652652
assert data_temp["floats"].dtype == np.float64
653653
assert data_temp["strings"].dtype == object
654654

@@ -692,7 +692,7 @@ def test_replace_mapper_type_change(df_simple):
692692
assert data["names"].dtype == object
693693
assert data["integers"].dtype == object
694694
assert data["floats"].dtype == np.float64
695-
assert np.issubdtype(data["strings"].dtype, int)
695+
assert np.issubdtype(data["strings"].dtype, np.integer)
696696

697697
def test_rename_mapper_and_rows(df_simple):
698698
"""Test data renaming functionality with type changes and row names.

tests/utils/test_time_conversions.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,7 @@ def test_datetime_to_unix_millis():
205205
# Testing reverse conversion
206206
t_rev = tc.unix_millis_to_datetime(out_unix_millis)
207207
assert t_datetime == t_rev
208-
209-
t_rev = tc.unix_millis_to_datetime(np.array(out_unix_millis).astype(np.int64))
210-
assert t_datetime == t_rev
211-
208+
212209

213210
def test_datetime_to_gps_millis():
214211
"""Test UTC datetime to milliseconds since GPS epoch conversion

0 commit comments

Comments
 (0)