Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Division by zero in convergence test if yMax == yMin, #6

Open
arurke opened this issue Feb 18, 2022 · 2 comments
Open

Division by zero in convergence test if yMax == yMin, #6

arurke opened this issue Feb 18, 2022 · 2 comments
Assignees

Comments

@arurke
Copy link
Contributor

arurke commented Feb 18, 2022

In analysis_metric(), if all elements in "y-axis" data are the same (i.e. min and max are identical), it leads to a division by zero in the convergence test, see https://github.com/romain-jacob/triscale/blob/master/helpers.py#L66 and two lines above.

The issue can easily be reproduced:

x = np.arange(0, 100)
y_same_value = np.full(len(x), 100)
df = pd.DataFrame(
    {'x': x,
     'y': y_same_value})

triscale.analysis_metric( 
    df,
    metric = {'measure': 50},
    convergence = {'expected': True})

>  triscale/helpers.py:66: RuntimeWarning: invalid value encountered in true_divide

An intuitive solution is to simply state that the data is converged in such cases with identical elements, but perhaps I am missing something about the statistics so I'll leave the PR to someone else 😅

@romain-jacob romain-jacob self-assigned this Mar 14, 2022
@romain-jacob
Copy link
Owner

Thanks for reporting!

Indeed, if all elements are the same, the empirical evidence for "has converged" is as strong as it gets :-) I'll add a test case for that.

@arurke
Copy link
Contributor Author

arurke commented May 30, 2022

On further inspection, the problem occurs for metrics only if:

  1. All data is equal AND bounds are not set, or
  2. Bounds are set by user to equal values (which raises other questions)

The issue is present for all invocations of convergence_test(). E.g. for KPIs it occurs if all values are equal (as bounds are always set to max(), min()).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants