DASDAE / dascore

A python library for distributed fiber optic sensing
Other
71 stars 16 forks source link

Fix rolling center #406

Closed ahmadtourei closed 2 months ago

ahmadtourei commented 2 months ago

Description

This PR fixes two issues regarding the center=True in the Patch.rolling function when engine="numpy":

  1. The first issue was related to using a wrong -window//2 roll size instead of -(window//2) in np.roll function to roll NaN values. This could cause unequal NaNs at the beginning and end of the rolled patch.
  2. The second issue was related to using -(window//2) instead of -(num_nans//2) inside the np.roll that led to the wrong number of indices to roll when the step size is not equal to None (and therefore the size of the padded array is different than the original patch's data).

Checklist

I have (if applicable):

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.84%. Comparing base (a59dc35) to head (adc2a14).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #406 +/- ## ======================================= Coverage 99.84% 99.84% ======================================= Files 109 109 Lines 8843 8843 ======================================= Hits 8829 8829 Misses 14 14 ``` | [Flag](https://app.codecov.io/gh/DASDAE/dascore/pull/406/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DASDAE) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/DASDAE/dascore/pull/406/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DASDAE) | `99.84% <100.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DASDAE#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

d-chambers commented 2 months ago

Hey @ahmadtourei,

I just looked over the code and it looks good. Also, thanks for correcting some of the misleading comments.