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

get_data_window cleanup #2510

Merged
merged 3 commits into from Aug 16, 2022
Merged

Conversation

groutr
Copy link
Contributor

@groutr groutr commented Jul 7, 2022

Supersedes #2262. Updated PR for rasterio 1.3.0.

Cleans up the implementation of get_data_window and extends it to properly handle 1D arrays. The documentation implied that 1D arrays are supported, but constructing a full window assumed 2 dimensions.

Primary wins:

  • doesn't create a masked array anymore
  • nicer handling of masked array (True maps to valid data)
  • Avoid some temporary array allocations and removed unnecessary rollaxis usage.
  • Small performance improvement.

@groutr groutr changed the title Get data window cleanup get_data_window cleanup Jul 7, 2022

num_dims = len(arr.shape)
if num_dims > 3:
if not 0 < arr.ndim <=3 :
Copy link
Member

Choose a reason for hiding this comment

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

👍

@sgillies sgillies added this to the 1.3.1 milestone Aug 11, 2022
@sgillies sgillies self-assigned this Aug 11, 2022
Copy link
Member

@sgillies sgillies left a comment

Choose a reason for hiding this comment

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

@groutr thanks! The only thing I request is that the new assertions added to tests be turned into new tests (using pytest.mark.parameterize or new functions, your choice).

@sgillies
Copy link
Member

@groutr if you don't have the time to update before 1.3.1 (#2546), let me know and I'll take care of the tests.

@groutr
Copy link
Contributor Author

groutr commented Aug 15, 2022

@sgillies I should be able to get this done by this evening.

Copy link
Member

@sgillies sgillies left a comment

Choose a reason for hiding this comment

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

Wonderful @groutr !

@sgillies sgillies merged commit 3001580 into rasterio:main Aug 16, 2022
snowman2 pushed a commit to snowman2/rasterio that referenced this pull request Aug 19, 2022
* Cleaner get_data_window implementation.

* Add tests.

* Separate assertions into distinct tests.
sgillies pushed a commit that referenced this pull request Aug 19, 2022
* Cleaner get_data_window implementation.

* Add tests.

* Separate assertions into distinct tests.

Co-authored-by: Ryan Grout <groutr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants