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

Warnings should refer to calling code location. #19

Open
cvm-a opened this issue Feb 1, 2024 · 1 comment
Open

Warnings should refer to calling code location. #19

cvm-a opened this issue Feb 1, 2024 · 1 comment

Comments

@cvm-a
Copy link

cvm-a commented Feb 1, 2024

The warnings in the sigfig library are reporting the location of the warning call within the sigfig library, like

/usr/lib/python3.11/site-packages/sigfig/sigfig.py:586: UserWarning: warning: 3 significant figures requested from number with only 1 significant figures

This makes it hard to find out what was the call to sigfig.roud that actually triggered this error. Instead, if we use the stacklevel argument to warn, like

warn("warning: %d significant figures requested from number with only %d significant figures" % (given['sigfigs'], len(num.map)), stacklevel=2)

the error message is like

/my/calling/code.py:270: UserWarning: warning: 3 significant figures requested from number with only 1 significant figures

Can we add the stacklevel argument to all the warning calls?

@MikeBusuttil
Copy link
Collaborator

absolutely, good call. Post a PR and it's going in!

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