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

Fixed warning in fourigui.py code #56

Closed
wants to merge 4 commits into from
Closed

Conversation

Fil158
Copy link

@Fil158 Fil158 commented Nov 6, 2024

Closes #22 Warning fixed in fourigui.py adding line 397 axes = list(range(len(size))) and modifying line 399 fftholder = np.fft.fftn(fftholder, s=size, axes=axes, norm="ortho")

Filippo Ballerini and others added 4 commits November 6, 2024 12:01
Your branch and 'origin/warning' have diverged,
and have 1 and 1 different commits each, respectively.
  (use "git pull" if you want to integrate the remote branch with yours)

All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)
Merge branch 'warning' of https://github.com/Filippo1598/diffpy.fourigui into warning

**Deprecated:**

* Deprecation warning fixed for axes in np.fft in fourigui.py
Copy link
Contributor

@bobleesj bobleesj Nov 6, 2024

Choose a reason for hiding this comment

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

@Fil158

Typically depreciated refers to classes and functions no longer supported.

Here, we are fixing these annoying warnings. So you can put it under "Fixed" - please refer to the "Lessons from ..." GitLab guide for writing a news file.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, next time I'll do so

Copy link
Contributor

Choose a reason for hiding this comment

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

No please do now. These are user facing news.

@bobleesj
Copy link
Contributor

bobleesj commented Nov 6, 2024

@Fil158 The original issue mentioned here was created to ensure we re-visit to fix these warnings. But, what exact warnings are you fixing and how? Even if it's a simple fix, we will probably forget things later and also it will be useful for future maintainers.

@bobleesj
Copy link
Contributor

bobleesj commented Nov 6, 2024

Warning fixed in fourigui.py adding line 397 axes = list(range(len(size))) and modifying line 399 fftholder = np.fft.fftn(fftholder, s=size, axes=axes, norm="ortho")

Thanks for this. Reviewers all can see what were changed. This information has no further value...

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

nice work....great to see..... A bit more discussion needed. Please see comments/questions.

@@ -394,8 +394,9 @@ def fft(self):
def perform_fft(fftholder):
fftholder = np.nan_to_num(fftholder)
size = list(fftholder.shape)
axes = list(range(len(size)))
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not very clear. In the comments, let's have a brief discussion of what is deprecated in numpy2 and how we are fixing it. Not too much, but presumably @Fil158 you googled something and found something out so it is helpful to share what you found out and a few words about how it affects us here and so your suggested fix. It builds more confidence that we understand what we are doing.

Also, please make your PR title more informative. Which warning does this PR fix? Not too long, but just enough.

I am not sure but there is almost certainly a more readable fix than list(range(len(size)))

Copy link
Author

@Fil158 Fil158 Nov 7, 2024

Choose a reason for hiding this comment

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

@sbillinge Here is the worning, please see the Numpy official documentation

image

To solve it I specify axes which is a list of integers with the same size of s
image

After the changes pytests run correctly and fourigui app works with test data.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @Fil158 this is very helpful. Next we need a quick discussion about what the shape of the arrays are and what th axes are and what our desired fft is.

Then finally, what code we think is best to accomplish that.

@cadenmyers13
Copy link
Contributor

@sbillinge @Fil158 fftholder is (101, 101, 101) and there are three axes, (0, 1, 2). Fourigui allows you to explore reciprocal space in 3D. The user specifies an axis (0,1, or 2) then the slider in the gui (which goes from 0 to 100 in the test case) allows you to look at a specific slice, hence the shape (101, 101, 101). This seems to me to be on the right track. Here's an image of the gui

Screenshot 2024-11-07 at 4 34 58 PM

@cadenmyers13
Copy link
Contributor

I don't know if my inline comments are showing to everyone... so I'm pasting them here. Sorry if you see duplicates.

@sbillinge Here's some info from the np.fft.fftn() documentation. If we specify s we must specify axes in numpy2. To make it more readable, maybe we can change it to axes = list(range(fftholder.ndim))?

Screenshot 2024-11-07 at 11 55 35 AM

@bobleesj
Copy link
Contributor

bobleesj commented Nov 8, 2024

@cadenmyers13 as we discussed, could you utilize the knowledge here to resolve the warnings in a new PR?

@bobleesj
Copy link
Contributor

bobleesj commented Nov 8, 2024

@Fil158 you may close this issue if @cadenmyers13 is willing to do so.

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.

Resolve Pytest 25 warnings
4 participants