-
Notifications
You must be signed in to change notification settings - Fork 3
Better attributes integer values size handling #36
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
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.
Pull Request Overview
This PR improves integer attribute size handling in pycdfpp by introducing a shrink_int flag to preserve numpy integer types, refines _values_view_and_type logic, and expands tests to verify both Python and numpy integer attribute behavior.
- Refined integer sizing logic in
_values_view_and_type, addingshrink_intto distinguish Python vs numpy integers. - Expanded test suite with
test_inter_attributes_fits_min_integer_sizeandtest_inter_attributes_respect_numpy_types. - Updated imports, formatting, and wrappers for variable and attribute additions.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/python_saving/test.py | Added new tests for integer attribute sizing and numpy type respect; formatting adjustments |
| pycdfpp/init.py | Added shrink_int logic in _values_view_and_type; adjusted imports and wrapper signatures |
Comments suppressed due to low confidence (3)
tests/python_saving/test.py:78
- [nitpick] The test method name
test_inter_attributes_fits_min_integer_sizeis ambiguous; consider renaming totest_integer_attributes_fits_min_sizefor clarity.
def test_inter_attributes_fits_min_integer_size(self):
tests/python_saving/test.py:88
- [nitpick] The test name
test_inter_attributes_respect_numpy_typescould be clearer astest_integer_attributes_respect_numpy_typesto match the subject.
def test_inter_attributes_respect_numpy_types(self):
pycdfpp/init.py:308
- The docstring for
_add_attribute_wrappershould includenp.integerin thevaluestype description to match the signature and avoid confusion.
values : np.ndarray or List[float or int or datetime] or str
| values = values.astype(_min_integer_dtype(values, target_type)) | ||
| else: | ||
| return values, data_type or _NUMPY_TO_CDF_TYPE_[values.dtype.num] | ||
| return _values_view_and_type(values, data_type) |
Copilot
AI
Jun 19, 2025
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.
The recursive call to _values_view_and_type drops the original target_type. It should pass it through, e.g., return _values_view_and_type(values, data_type, target_type) to preserve the intended target.
| return _values_view_and_type(values, data_type) | |
| return _values_view_and_type(values, data_type, target_type) |
| import sys | ||
| import os |
Copilot
AI
Jun 19, 2025
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.
The sys module is imported but never used; consider removing this import to clean up unused dependencies.
| import sys | |
| import os | |
| import os | |
| import platform |
66fe64e to
703f00f
Compare
|



This pull request introduces several updates to the
pycdfpplibrary, focusing on improving compatibility, refining data handling, and enhancing test coverage. Key changes include the replacement of deprecatedByteString, updates to integer handling for attributes, and the addition of new tests to ensure proper functionality.Compatibility Improvements
ByteStringtype withbytes | bytearray | memoryviewfor compatibility with Python 3.9+ and future versions. (pycdfpp/__init__.py)Data Handling Enhancements
pycdfpp/__init__.py)_values_view_and_typeto respect numpy integer types when handling mixed integer lists. (pycdfpp/__init__.py)Test Coverage Expansion
tests/python_saving/test.py)tests/python_saving/test.py)Code Formatting and Cleanup
pycdfpp/__init__.py,tests/python_saving/test.py) [1] [2]…intX]