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

Add a function for subsampling functionality #141

Merged
merged 8 commits into from
Jun 22, 2021

Conversation

adehecq
Copy link
Member

@adehecq adehecq commented Jun 3, 2021

As mentioned in PR #135, a shared subsampling function would be useful.

Done:

  • created the function
  • added tests

To do:

  • add tests with option 'return_indices"
  • replace with this function where needed

@adehecq adehecq linked an issue Jun 3, 2021 that may be closed by this pull request
@adehecq adehecq marked this pull request as draft June 3, 2021 16:52
@rhugonnet
Copy link
Member

So should we merge this? @adehecq

Copy link
Contributor

@erikmannerfelt erikmannerfelt left a comment

Choose a reason for hiding this comment

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

Sorry for not having reviewed this earlier. I just have a few small comments that I feel are to a lesser or higher degree important.

xdem/spatial_tools.py Outdated Show resolved Hide resolved
valids = np.argwhere(~mask.flatten()).squeeze()

# Checks that array and npoints are correct
assert np.ndim(valids) == 1
Copy link
Contributor

Choose a reason for hiding this comment

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

This will raise an AssertionError without explanation. Could one be added? Python's AssertionErrors are inherently a little annoying I think because they don't tell the user anything!!

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, but actually, I don't think this error should ever happen. It's just to make sure that the array has been flattened correctly and has the expected shape.
I can write "Something is wrong with array dimension, check input data and shape"

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 05f5e40

"""
Randomly subsample a 1D or 2D array by a subsampling factor, taking only non NaN/masked values.

:param subsample: If < 1, will be considered a fraction of valid pixels to extract.
Copy link
Contributor

Choose a reason for hiding this comment

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

If <= 1 (to be consistent with the functionality)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 05f5e40

@erikmannerfelt
Copy link
Contributor

Is this ready for approval? It looks great now in my book!

@rhugonnet
Copy link
Member

Is this ready for approval? It looks great now in my book!

+1

@adehecq
Copy link
Member Author

adehecq commented Jun 22, 2021

Is this ready for approval? It looks great now in my book!

Yes, I just need to check that the tests pass and run the linters.

@adehecq adehecq marked this pull request as ready for review June 22, 2021 09:24
Copy link
Member

@rhugonnet rhugonnet left a comment

Choose a reason for hiding this comment

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

Not much changed by the linters!

@adehecq
Copy link
Member Author

adehecq commented Jun 22, 2021

Not much changed by the linters!

Of course, I naturally write good code! ;-)

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.

Allow custom subsampling for each CoregPipeline step separately.
3 participants