Skip to content

Commit 497ba9f

Browse files
committed
Add warning when truncation occurs.
1 parent 3a9a554 commit 497ba9f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/citrine/informatics/predictors/chemical_formula_featurizer.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ def powers(self) -> List[int]:
158158
"""The list of powers when computing generalized weighted means of element properties."""
159159
warn("The type of 'powers' will change to a list of floats in v4.0.0. To retrieve them as "
160160
"floats now, use 'powers_as_float'.")
161-
return [int(p) for p in self._powers]
161+
truncated = [int(p) for p in self._powers]
162+
if truncated != self._powers:
163+
diffs = [f"{x} => {y}" for x, y in zip(self._powers, truncated) if x != y]
164+
warn(f"The following powers were cast to ints: {'; '.join(diffs)}.")
165+
return truncated
162166

163167
@powers.setter
164168
def powers(self, value: List[Union[int, float]]):

0 commit comments

Comments
 (0)