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

FixedScaleOffset doc: change scale parameter type to float #356

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bogovicj
Copy link

@bogovicj bogovicj commented Oct 5, 2022

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)

@jakirkham
Copy link
Member

Thanks John! 🙏

This makes sense to me. Should we add an example in the docstring and maybe a test filter here?

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.

None yet

2 participants