Skip to content

Commit 8eaea9d

Browse files
Fix numpy downcast warnings
1 parent e38cdb9 commit 8eaea9d

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

accelforge/mapper/FFM/_pareto_df/df_convention.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import functools
22
import re
33

4+
from accelforge.util import NUMPY_FLOAT_TYPE
45
from accelforge.util._frozenset import fzs
56
from accelforge.frontend.workload import Rank
67
from accelforge.util._base_analysis_types import ActionKey, VerboseActionKey
@@ -208,18 +209,22 @@ def is_fused_loop_col(c: str) -> bool:
208209
def is_n_iterations_col(c: str) -> bool:
209210
return c.startswith("fused_loop<SEP>n_iterations")
210211

211-
212-
def add_to_col(df, target, source):
212+
def ensure_float_type(df, target, source):
213213
if target in df:
214214
target_type = df[target].dtype
215215
source_type = df[source].dtype
216216
if target_type != source_type:
217-
df[target] = df[target].astype("float64")
218-
df[source] = df[source].astype("float64")
217+
df[target] = df[target].astype(NUMPY_FLOAT_TYPE)
218+
df[source] = df[source].astype(NUMPY_FLOAT_TYPE)
219+
220+
221+
def add_to_col(df, target, source):
222+
ensure_float_type(df, target, source)
219223
df.loc[:, target] = df[target] + df[source] if target in df else df[source]
220224

221225

222226
def max_to_col(df, target, source):
227+
ensure_float_type(df, target, source)
223228
df.loc[:, target] = df[[target, source]].max(axis=1) if target in df else df[source]
224229

225230

0 commit comments

Comments
 (0)