numcodecs
numcodecs copied to clipboard
FixedScaleOffset doc: change scale parameter type to float
This PR is a small change to the documentation of the FixedScaleOffset:
changing the type of the scale parameter from int
to float
.
The filter currently behaves reasonably and as I would expect if a passing a float to the scale parameter:
# random angles in the range [-pi,pi]
x = (np.random.random([64]) * 2 * np.pi) - np.pi
# encode in the range [0,255] with a byte
f = FixedScaleOffset(scale= (255.0 / (2.0 * np.pi) ), offset=-np.pi, dtype='float64', astype='uint8')
# behaves as expected
x_enc = f.encode(x)
x_dec = f.decode(x_enc)
and is a potentially useful application of this filter.
As well, this documentation change makes this filter's description consistent with the scale_factor
and add_offset
attributes of NetCDF.
When scale_factor and add_offset are used for packing, the associated variable (containing the packed data) is typically of type byte or short, whereas the unpacked values are intended to be of type float or double. The attributes scale_factor and add_offset should both be of the type intended for the unpacked data, e.g. float or double.
(emphasis mine)
TODO:
- [ ] Unit tests and/or doctests in docstrings
- [ ]
tox -e py310
passes locally - [ ] Docstrings and API docs for any new/modified user-facing classes and functions
- [ ] Changes documented in docs/release.rst
- [ ]
tox -e docs
passes locally - [ ] GitHub Actions CI passes
- [ ] Test coverage to 100% (Coveralls passes)
Thanks John! 🙏
This makes sense to me. Should we add an example in the docstring and maybe a test filter here?