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

BUG: fix float string literal issues #624

Merged
merged 5 commits into from
Nov 25, 2024
Merged

Conversation

bsipocz
Copy link
Member

@bsipocz bsipocz commented Nov 25, 2024

This logic was introduced in the big registry overhaul PR #289, and I see no review discussion for this part of the code.

Looking at it now, I think f-strings should be powerful enough when generating the SQL string. If not, we will definitely need some use case coverage in the tests, too.

First commit fixes #623, but I think the cleanup in the second commit should work, too.

The changes in numpy printoptions in the tests ensure that we indeed trigger the bug (it does have ample test coverage with existing tests). I expect some other places may be affected and will rely on CI to smoke out the version dependencies of them and will see whether they are bugs or the fixes can be included here, too.

@bsipocz bsipocz added this to the v1.6.1 milestone Nov 25, 2024
@bsipocz bsipocz requested a review from msdemlei November 25, 2024 09:46
Copy link
Contributor

@msdemlei msdemlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tried to fathom why unit tests didn't catch that one, and I can't find time to do that now. Similarly, I would have to spend more time than I have now to set up a numpy2 testbed, and so I have not actually ascertained that f-string interpolation will produce valid SQL literals. Since that seems very plausible, though, I will approve, but I am grateful if someone will do some stress testing of fix.

@bsipocz
Copy link
Member Author

bsipocz commented Nov 25, 2024

I have not tried to fathom why unit tests didn't catch that one,

We have opted in legacy printing in the test configs, so this all got effectively turned off for all unit tests, initially as a workaround, but apparently it had unintended consequences

I'm working on finding a fix that actually works for all the version and will push a commit for that, hopefully shortly.

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.31%. Comparing base (c4080f7) to head (eba8c6f).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #624      +/-   ##
==========================================
- Coverage   82.31%   82.31%   -0.01%     
==========================================
  Files          72       72              
  Lines        7431     7429       -2     
==========================================
- Hits         6117     6115       -2     
  Misses       1314     1314              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@bsipocz
Copy link
Member Author

bsipocz commented Nov 25, 2024

OK, so with this latest commit I made a slight change, but I don't think it's making anything worse. Prior this we had the repr as "(23, 'Illuminatus')", and now we will make everything explicit string with "('23', 'Illuminatus')". Note that 23 was in fact already a string, and our other, default option would be to keep the numpy prints (as of "(np.int64(23), np.str_('Illuminatus'))", which I don't think is desirable here. cross-reference: https://numpy.org/devdocs/release/2.0.0-notes.html#representation-of-numpy-scalars-changed

Please re-review to say whether you are OK with this, or prefer if I find some other way to keep exactly what we had before.

@bsipocz bsipocz requested a review from msdemlei November 25, 2024 12:02
Copy link
Contributor

@msdemlei msdemlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the caveats from my last review (plus I have not thought about whether DALQuery.__repr__ changes might break code): Let's go.

@bsipocz
Copy link
Member Author

bsipocz commented Nov 25, 2024

FWIW, I'm on np 2.0+ in all my dev envs (and this PR gets rid of the legacy print workaround, too), and we do have many of the notebooks/astroquery/etc CI, so those provide some actual testsbeds. I had a quickrun of their tests with this branch and it looked all OK, but I'll keep an eye on CI statuses for the longer running version.

@bsipocz bsipocz merged commit 2bf4e3f into astropy:main Nov 25, 2024
13 checks passed
@bsipocz bsipocz deleted the BUG_np_repr branch November 25, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: DALQueryError caused by interpolated np.float64
2 participants