11import functools
22import re
3-
3+ import pandas as pd
44from accelforge .util import NUMPY_FLOAT_TYPE
55from accelforge .util ._frozenset import fzs
66from accelforge .frontend .workload import Rank
@@ -212,9 +212,16 @@ def is_n_iterations_col(c: str) -> bool:
212212def ensure_float_type (df , target , source ):
213213 if target in df :
214214 target_type = df [target ].dtype
215- source_type = df [source ].dtype
216- if target_type != source_type :
215+ else :
216+ target_type = NUMPY_FLOAT_TYPE
217+
218+ if isinstance (source , pd .Series ):
219+ if target in df and target_type != source .dtype :
217220 df [target ] = df [target ].astype (NUMPY_FLOAT_TYPE )
221+ elif source in df :
222+ if target_type != df [source ].dtype :
223+ if target in df :
224+ df [target ] = df [target ].astype (NUMPY_FLOAT_TYPE )
218225 df [source ] = df [source ].astype (NUMPY_FLOAT_TYPE )
219226
220227
@@ -227,6 +234,12 @@ def max_to_col(df, target, source):
227234 ensure_float_type (df , target , source )
228235 df .loc [:, target ] = df [[target , source ]].max (axis = 1 ) if target in df else df [source ]
229236
237+ def add_to_col (df , target , source ):
238+ ensure_float_type (df , target , source )
239+ if isinstance (source , pd .Series ):
240+ df [target ] = df [target ] + source
241+ else :
242+ df .loc [:, target ] = df [target ] + df [source ] if target in df else df [source ]
230243
231244def is_objective_col (c ):
232245 return partition_col (c , "Total" ) is not None
0 commit comments