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

Math domain error #6

Closed
prjemian opened this issue Jan 8, 2024 · 1 comment · Fixed by #7
Closed

Math domain error #6

prjemian opened this issue Jan 8, 2024 · 1 comment · Fixed by #7
Labels
bug Something isn't working

Comments

@prjemian
Copy link
Owner

prjemian commented Jan 8, 2024

CI for apstools encounters a math domain error occasionally. This line:

return math.sqrt((self.YY - self.mean_y * self.Y) / (self.n - 1))

Calling code is the problem yet the reporting here could be more informative (such as checking for negative argument to math.sqrt() or (n-1) < 1.

@prjemian prjemian added the bug Something isn't working label Jan 8, 2024
@prjemian
Copy link
Owner Author

prjemian commented Feb 8, 2024

Note:

In [1]: import math

In [2]: math.sqrt(1)
Out[2]: 1.0

In [3]: math.sqrt(0)
Out[3]: 0.0

In [4]: math.sqrt(1/0)
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
Cell In[4], line 1
----> 1 math.sqrt(1/0)

ZeroDivisionError: division by zero

In [5]: math.sqrt(-1)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[5], line 1
----> 1 math.sqrt(-1)

ValueError: math domain error

Only one possibility for a math domain error.

prjemian added a commit that referenced this issue Feb 8, 2024
prjemian added a commit that referenced this issue Feb 8, 2024
prjemian added a commit that referenced this issue Feb 8, 2024
prjemian added a commit that referenced this issue Feb 8, 2024
prjemian added a commit that referenced this issue Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant