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

Fix numpy str FutureWarning and modernize get_ifot slightly #321

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

taldcroft
Copy link
Member

Description

This fixes a FutureWarning caused by using np.str. The code got much cleaner due to an improvement in io.ascii since this kadi code was written. Now the converters kwarg can just be a dict of types (exactly the same as the types kwarg here). See https://docs.astropy.org/en/stable/io/ascii/read.html#parameters-for-read.

In addition I added a docstring and removed mutable values as keyword defaults in get_ifot.

Fixes #320

Interface impacts

The types dict option of get_ifot now requires that the type be specified as the actual type object (e.g. str or np.int64) instead of a str that is used in getattr(np, type).

I searched the sot repo on GitHub and found no instances outside of kadi that used the types kwarg of get_ifot.

Testing

Unit tests

  • Mac
(ska3) ➜  kadi git:(numpy-str-deprecation) git rev-parse HEAD                            
80834453bf4d9dc7dac0b9a5d8ae73e6bde8c375
(ska3) ➜  kadi git:(numpy-str-deprecation) pytest
======================================================== test session starts ========================================================
platform darwin -- Python 3.10.8, pytest-7.2.1, pluggy-1.0.0
rootdir: /Users/aldcroft/git, configfile: pytest.ini
plugins: timeout-2.1.0, anyio-3.6.2
collected 232 items                                                                                                                 

kadi/commands/tests/test_commands.py ......................................................................................   [ 37%]
kadi/commands/tests/test_states.py .......................x..............................................x................... [ 75%]
....                                                                                                                          [ 77%]
kadi/commands/tests/test_validate.py ....................                                                                     [ 86%]
kadi/tests/test_events.py ..........                                                                                          [ 90%]
kadi/tests/test_occweb.py ......................                                                                              [100%]

I don't have a speedy environment handy but that might be a good thing for the reviewer to test.

Independent check of unit tests by [REVIEWER NAME]

  • [PLATFORM]:

Functional tests

I ran the kadi_update_events script locally in current ska3-flight and confirmed that it ran successfully. I also confirmed that it fails without the fix changing "str" to str in models.py.

Copy link
Contributor

@javierggt javierggt left a comment

Choose a reason for hiding this comment

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

I ran testr including this PR, and no problem.

@taldcroft taldcroft merged commit d882568 into master Feb 14, 2024
4 checks passed
@taldcroft taldcroft deleted the numpy-str-deprecation branch February 14, 2024 22:57
This was referenced Mar 6, 2024
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

Successfully merging this pull request may close these issues.

FutureWarning: In the future np.str will be defined as the corresponding NumPy scalar
2 participants