Skip to content

Commit 7c81f2c

Browse files
committed
Fix argument typehints for scaling transform funcs
1 parent ca69e87 commit 7c81f2c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

isicle/conformers.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import pandas as pd
33
from statsmodels.stats.weightstats import DescrStatsW
4-
4+
import re
55
from isicle import io
66
from isicle.geometry import Geometry, XYZGeometry
77
from isicle.utils import TypedList, safelist, scaling_factors
@@ -431,7 +431,7 @@ def select_scaling_factors(self, index):
431431
self.scaling_factors.update(tempdict)
432432

433433
def _transform_quadratic(
434-
self, value, a=float, b=float, c=float, constant=float, coefficient=float
434+
self, value, a: float, b: float, c: float, constant: float, coefficient: float
435435
):
436436
"""
437437
Apply quadratic value coefficients in the form of
@@ -442,13 +442,17 @@ def _transform_quadratic(
442442
quadratic_result = a * value**2 + b * value + c
443443
return constant - coefficient * quadratic_result
444444

445-
def _transform_slope_intercept(self, value, slope=float, intercept=float):
445+
def _transform_slope_intercept(self, value, slope: float, intercept: float):
446446
if not isinstance(slope, float):
447-
slope = float(slope)
447+
try:
448+
slope = float(slope)
449+
except:
450+
slope = np.nan
448451
if not isinstance(intercept, float):
449-
intercept = float(intercept)
450-
if np.isnan(slope) or np.isnan(intercept):
451-
return np.nan
452+
try:
453+
intercept = float(intercept)
454+
except:
455+
intercept = np.nan
452456
return (intercept - value) / (-slope)
453457

454458
def apply_scaling_factors(self):

0 commit comments

Comments
 (0)