Skip to content

Commit 3a198c7

Browse files
committed
Improve check for numerical types
1 parent 6c1f4d3 commit 3a198c7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/dmu/generic/typing_utilities.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from typing import TypeVar, Type, cast
66
import pandas as pnd
7-
import numpy
87

98
from dmu.logging.log_store import LogStore
109

@@ -33,9 +32,11 @@ def numeric_from_series(
3332
raise ValueError(f'Cannot find {name} in row: {row}')
3433

3534
val = row[name]
35+
numerical_types = int, float
3636

37-
if not isinstance(val, (int, float, bool, numpy.integer, numpy.floating, numpy.bool_)):
38-
raise ValueError(f'Value {name}={val} is not numeric')
37+
if not isinstance(val, numerical_types):
38+
type_name = type(val)
39+
raise ValueError(f'Value {name}={val} is not numeric, but {type_name}')
3940

4041
if numeric is int:
4142
return cast(Num, int(val))

0 commit comments

Comments
 (0)