-
Notifications
You must be signed in to change notification settings - Fork 26
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
JP-1713: fix gentle_asarray
structured array handling and allow extra columns in datamodel schema
#189
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #189 +/- ##
==========================================
+ Coverage 64.01% 64.28% +0.27%
==========================================
Files 101 101
Lines 5558 5606 +48
==========================================
+ Hits 3558 3604 +46
- Misses 2000 2002 +2
☔ View full report in Codecov by Sentry. |
gentle_asarray
oddities and allow extra columns in datamodel schema
gentle_asarray
oddities and allow extra columns in datamodel schemagentle_asarray
structured array handling and allow extra columns in datamodel schema
c96b625
to
059a7c7
Compare
This comment was marked as outdated.
This comment was marked as outdated.
I ran another regression test run this morning and it had one failure:
|
374b488
to
81620e0
Compare
gentle_asarray
structured array handling and allow extra columns in datamodel schemagentle_asarray
structured array handling and allow extra columns in datamodel schema
81620e0
to
26496a0
Compare
this breaks the test_gentle_asarray_field_name_case likely because gentle_asarray is not mapping dtypes as expected (taking names from the provided dtype instead of the input).
26496a0
to
f653693
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.
I think this is a great fix. Thanks!
Thanks for reviewing the changes! |
This fixes issues with
gentle_asarray
handling of structured arrays (see #188) and adds support for allowing extra columns in tables defined in datamodel schema.gentle_asarray
is used when setting a data model property when the value is _cast to a dtype defined by the schema. (Here is one example fromproperties.py
which includes several uses of_cast
for__setattr__
,__setitem__
etc...).Prior to this PR
gentle_asarray
mangled some dtypes when used with structured arrays (see #188 for more examples and details). For example,This PR:
gentle_asarray
by inverting some conditionals to allow removing nested if statements (to improve readability)allow_extra_columns
togentle_asarray
to allow extra columns (which will be put at the end of the required columns) and exposes this option in the schema (see the oifits schema changes in this PR).As mentioned above
_safe_asanyarray
is now used for byte order differences. Although fitsrec appears to ignore byte order differences for views (unlike normal structured arrays) this breaks down if a binary mask is applied to the fitsrec and can result in unexpected byte swaps and erroneous values.@perrygreenfield I think this is another reason to remove all uses of fitsrec.
While working on this PR I discovered that the jwst miri cubepars reference files contain tables with columns in an order that do not match the schema (see #188). Prior to this PR, columns names but not dtypes were being swapped. This was not an issue in practice as the swapped columns have the same dtype. With this PR the names and dtypes are swapped (and tests were added for this and several other cases, see the new parametrized test in
test_util.py
).This PR moves the single test
test_gentle_asarray
fromtest_storage.py
intotest_util.py
and removestest_storage.py
.The changes in this PR will make JP-1713 easier to address as we won't need to make different oifits schemas for each file type (which have different, optional columns in some tables).
Checklist
CHANGES.rst
(either inBug Fixes
orChanges to API
)