diff --git a/ballpark/utils.py b/ballpark/utils.py index d012f6f..18a0489 100644 --- a/ballpark/utils.py +++ b/ballpark/utils.py @@ -87,7 +87,15 @@ def unwrapped_function(values, *vargs, **kwargs): if scalar: values = [values] - results = fn(values, *vargs, **kwargs) + # Handle negative inputs by converting to positive, then correcting the output + + is_negative = list(map(lambda x : x < 0, values)) + multipliers = [-1 if negative else 1 for negative in is_negative] + positive_inputs = [value * multiplier for value, multiplier in zip(values, multipliers)] + + positive_results = fn(positive_inputs, *vargs, **kwargs) + + results = ["-" + positive_result if negative else positive_result for positive_result, negative in zip(positive_results, is_negative)] if scalar: results = results[0]