-
-
Notifications
You must be signed in to change notification settings - Fork 423
Revert kwarg-only function arguments for splatalogue #2696
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
Conversation
f384e3c
to
c200b49
Compare
Codecov Report
@@ Coverage Diff @@
## main #2696 +/- ##
=======================================
Coverage 65.73% 65.74%
=======================================
Files 233 233
Lines 17842 17844 +2
=======================================
+ Hits 11729 11732 +3
+ Misses 6113 6112 -1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Hmm, the docs still has the doctest-skip-all, thus we haven't notice this before. Why do you feel strongly against requiring being explicit? E.g. in practice all the parameters are optional as you either need the min/max or the bandname, so just assuming that if two are given they would be min/max is not exactly great. So, what about updating the docs instead, and enabling remote testing on it? |
The band name should be regarded as optional, imo, and the min/max frequency should not. They are only technically optional, in the literal sense of a query can be executed without raising an immediate error if you give a band name. You cannot execute successful queries without providing either a tight pair of frequencies or a band name plus a chemical name. This is a module I'm intimately familiar with, and I believe I did some searching for use cases on github, too, and all uses I saw (that were not astroquery clones or my own test cases....) use positional arguments. https://github.com/search?p=4&q=splatalogue.query_lines&type=Code That said, I do think we should update the docs to use explicit keywords in all examples. |
72ec6b6
to
3003a02
Compare
I don't understand the readthedocs failure. I'm not sure if it's related or not; the traceback makes no sense. |
The error messages were nonsense, but were caused by doubling up sphinx block directives |
Interesting, this never caused an issue before, the doubling up just caused an ugly rendering. |
Maybe it was because I put them on consecutive lines? The message never told me what I was doing was wrong specifically, but it caused errors in every other module. |
We had them in consecutive lines in all the other PRs that were opted in for the testing, but most of those was a while ago and likely used older sphinx. I haven't checked, but it might become more strict. Anyway, I'm glad you find the fix. |
OK. I still don't like it from the pure API design POV, but could live with the two positional arguments. I would not think making them mandatory would make things better, the band kward feels very useful. |
The main change in this PR is this one: astroquery/astroquery/splatalogue/core.py Line 422 in 86ec38f
so I kept the arguments as optional positional arguments. I also made regex_str: astroquery/astroquery/splatalogue/core.py Line 79 in 86ec38f
a positional argument, since the intent of that function is to search. Otherwise, this is all documentation fixes. It's ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, some more comments. The main blocker is the kwarg rename, it should be done with a deprecation decorator.
And please add a changelog about the rename, too.
astroquery/splatalogue/core.py
Outdated
def get_species_ids(self, *, restr=None, reflags=0, recache=False): | ||
def get_species_ids(self, regex_str=None, *, reflags=0, recache=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This renaming of an arg is an API change that has to be done with the deprecation decorator. Unless restr
was added since 0.4.6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and if rename happens, you may want to use a name that's more informative. Maybe species_regex
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'm willing to abandon that. restr
wasn't great, it was just short. It... kind of was never intended to be a kwarg
, just an internal required positional variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, good reminder that internal stuff should be named well, too. Or at least the stuff that ends up in signatures and docstrings.
I'm happy to push commits to this, but it will need to wait until at least the evening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I will revisit this when I can; may not be this evening either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed the variable, but I still prefer to keep it as a positional argument. I added the deprecation warning.
@@ -66,10 +66,12 @@ def species_lookuptable(*, filename='splat-species.json', recache=False): | |||
# check to see if the file exists; if not, we run the | |||
# scraping routine | |||
if recache or not os.path.isfile(file_cache): | |||
species = get_json_species_ids(filename) | |||
species = get_json_species_ids(outfile=filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are some patchy test coverage around this load/build methods, and even __main__
, so would be nice to clean up that, too (can be done separately, I've just spotted it now).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, agreed - I already expanded test coverage a bit, I think? but, some stuff is still not caught
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've not done anything with this but suggest we merge anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More comments regarding the documentation, basically the asserts should go, but otherwise things are looking good.
@@ -1,5 +1,3 @@ | |||
.. doctest-skip-all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting why the examples work in this without remote-data? Would it make sense to make it opt-out to use the shipped json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many of them are labeled remote-data; only a couple work without it.
@bsipocz any idea what's going on with the dev deps build? Looks like pyvo and codecov don't get along? |
Ahh, so codecov actually bite us. cc @pllim |
refactor of some broken code and renames some variables for clarity. The assertions are added because one test case resulted in a supposedly-json file being read in as a string, which resulted in breakage downstream
c8c3b64
to
8c24bb6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When CI is all clean, this is good to go.
Splatalogue was modified to accept only keyword-specified arguments, but
Splatalogue.query_lines()
is not valid. Currently, all of the docs have invalid examples as a result. This simple modification fixes the problem. The standard usage is, and should be:the alternative, which is presently being enforced, should be optional:
There's another optional approach that is supported either way: