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
get_obs_products method supports product_type parameter as string or list #2995
base: main
Are you sure you want to change the base?
get_obs_products method supports product_type parameter as string or list #2995
Conversation
Hi there! |
Hi @davidglt , please rebase your branch. It seems there is a conflict in CHANGES.rst file. |
Hi there! Cheers, |
I'm not exactly sure what went wrong with the rebase here, I suspect it might not been rebased on the correct branch. Given that there are new conflicts I do a rebase again and will report back the command history I will have used. |
2d0bebd
to
7b88527
Compare
Given that there were a lot of incorrect edits for the changelog, I removed those commits during the rebase and instead added a single clean on once the rest has been rebased. Here are the commands: Make sure you have the astropy/astroquery repo added as a git remote (I call this
Have a fresh version of the main repo:
Interactive rebase on
Once the rebase is done, I edited the changelog file and added that commit. Now, the important part (which might have been the step that didn't worked previously) is to force push the branch back to github. I call the ESAC fork
|
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.
Please add a test that covers the list case for product_type input. Also see the inline comments as I suspect the a bug, but also suggest a shorter solution for the enhancement.
astroquery/esa/jwst/core.py
Outdated
@@ -83,6 +83,15 @@ def __init__(self, *, tap_plus_handler=None, data_handler=None, show_messages=Tr | |||
if show_messages: | |||
self.get_status_messages() | |||
|
|||
def __check_list_strings(self, list): |
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 would strongly advise calling the parameter something else than list
to avoid overriding the list()
astroquery/esa/jwst/core.py
Outdated
def __check_list_strings(self, list): | ||
if list is None: | ||
return False | ||
if list and all(isinstance(elem, str) for elem in list): |
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.
a single string is iterable and this will return True, is that the logic you want to do here?
astroquery/esa/jwst/core.py
Outdated
|
||
if self.__check_list_strings(product_type): | ||
if type(product_type) is list: | ||
tap_product_type = ",".join(str(elem) for elem in product_type) | ||
else: | ||
tap_product_type = product_type | ||
else: | ||
tap_product_type = None |
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 function is only used in this one place, so I would instead suggest something in-place here along the line of the following few line. Arguably this doesn't gracefully handle the case when the input list is not full of strings, but the docs calls for strings, so duct-typeing should be sufficient. And with this the extra private function is not needed either.
if self.__check_list_strings(product_type): | |
if type(product_type) is list: | |
tap_product_type = ",".join(str(elem) for elem in product_type) | |
else: | |
tap_product_type = product_type | |
else: | |
tap_product_type = None | |
if isinstance(product_type, list): | |
tap_product_type = ",".join(str(elem) for elem in product_type) | |
elif isinstance(product_type, str): | |
tap_product_type = product_type | |
else: | |
tap_product_type = None |
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.
Brigitta, thank you very much for your comments and patience!
I was not using the --force in the push, my fault :)
About this method "check_list_strings" is used as in other submodules (ex. hubble), but you’re right, in jwst no, I can delete it and check the entries directly in "get_obs_products".
Cheers,
David
Also, @davidglt - if you add the email address you made the commits with to your github profile, these commits will properly show up as your contributions. |
7b88527
to
6e9dfbd
Compare
Hi Brigitta, I am working to implement a new test for the product_type parameter as string or list |
The get_obs_products method now checks the input argument product_type with the method _check_list_strings and allows using strings or lists