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

BUG: Fix bug in numpy.pad() #25963

Merged
merged 2 commits into from
Jun 14, 2024
Merged

BUG: Fix bug in numpy.pad() #25963

merged 2 commits into from
Jun 14, 2024

Conversation

EngineerEricXie
Copy link
Contributor

@EngineerEricXie EngineerEricXie commented Mar 8, 2024

See #25926 for the bug

@EngineerEricXie
Copy link
Contributor Author

EngineerEricXie commented Mar 8, 2024

@eendebakpt
Copy link
Contributor

Looks good to me! The code for np.pad is a bit complex, maybe refactoring can improve that (but probably not for this PR).

@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Mar 22, 2024
@charris
Copy link
Member

charris commented Mar 22, 2024

Please squash on merge.

See numpy#25926 for the bug

Fix linter bug (E501 line too long)
@EngineerEricXie
Copy link
Contributor Author

@charris I have squashed the commits and force pushed the branch for this PR. As it's my first PR, I want to ensure I've followed the correct process. Please let me know if there's anything incorrect or if I've missed any steps. Thanks!

@ngoldbaum ngoldbaum added the triage review Issue/PR to be discussed at the next triage meeting label Apr 17, 2024
@seberg
Copy link
Member

seberg commented Apr 17, 2024

@lagru do you have time to take a brief look (probably for along). IIRC you were the last one who looked at this.

@ngoldbaum ngoldbaum added triaged Issue/PR that was discussed in a triage meeting and removed triage review Issue/PR to be discussed at the next triage meeting labels Apr 17, 2024
@lagru
Copy link
Contributor

lagru commented May 7, 2024

@seberg, sorry for the late response. I'm not sure when I will get to it in the next few days, but it's on my list.

# by ensuring period can only be a multiple of the original
# area's length.
old_length = (old_length - 1) // (original_period - 1) \
* (original_period - 1) + 1
Copy link
Member

Choose a reason for hiding this comment

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

Looks like the + 1 is subtracted out in the second line below. This line should also be indented for readability.

Copy link
Member

Choose a reason for hiding this comment

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

Instead of line continuation, you can put the whole right hand side in parenthesis.

@EngineerEricXie
Copy link
Contributor Author

@charris I have made some modifications according to your suggestions. However, one check regarding FreeBSD has failed. Since I only modified a single line of code, I am curious about how I can fix this problem. Could you provide some suggestions? Thank you!

@charris
Copy link
Member

charris commented Jun 11, 2024

The FreeBSD failure is unrelated and is an infrastructure problem, not a code problem.

@EngineerEricXie
Copy link
Contributor Author

@charris Thanks for replying! Do you think this PR is good to go, or is there anything else I should address?

@charris
Copy link
Member

charris commented Jun 13, 2024

Looks like you have unintended changes, pulling in a couple of submodules among other things. Might want to redo the last commit.

@EngineerEricXie
Copy link
Contributor Author

@charris I have redone the last commit, removed the unintended changes, and force-pushed it. However, it caused some checks related to the GCC version to fail. Should this cause any trouble while merging?

@charris
Copy link
Member

charris commented Jun 14, 2024

some checks related to the GCC version

That is an unrelated error due to a recent merge.

@charris charris merged commit 6f428f2 into numpy:main Jun 14, 2024
65 of 68 checks passed
@charris
Copy link
Member

charris commented Jun 14, 2024

Thanks @EngineerEricXie .

The code seems unnecessarily complex for the simple operation it implements, it would be nice to refactor it. I think a good starting point would be to move the iteration into _set_reflect_both, which would simplify the logic and make things clearer. Might even have separate functions for the two different edge cases. If Python were fast, I'd just implement an iterator for indexing the two cases, it would look cleaner in C :)

charris pushed a commit to charris/numpy that referenced this pull request Jun 15, 2024
* BUG: Fix bug in numpy.pad() and add test cases

See numpy#25926 for the bug

Fix linter bug (E501 line too long)

* Increase readability and clarity
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jun 15, 2024
@EngineerEricXie EngineerEricXie deleted the pad_debug branch June 15, 2024 13:38
ArvidJB pushed a commit to ArvidJB/numpy that referenced this pull request Nov 1, 2024
* BUG: Fix bug in numpy.pad() and add test cases

See numpy#25926 for the bug

Fix linter bug (E501 line too long)

* Increase readability and clarity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug triaged Issue/PR that was discussed in a triage meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants