Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Clip soundfield into float64 range for plotting #57

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

Merged
merged 3 commits into from
Mar 14, 2018
Merged

Conversation

trettberg
Copy link
Collaborator

closes #50

(This may become obsolete in matplotlib 2.2 or not.
Since it's easy enough, I propose to fix it now anyway.)

@hagenw
Copy link
Member

hagenw commented Feb 26, 2018

I'm also in favor of including a fix for this.
An alternative solution would be to restrict matplotlib to <=2.0.2 in the dependencies of sfs and change this to >=2.2 when they have fixed matplotlib. I'm not sure what would be the better option.

@mgeier
Copy link
Member

mgeier commented Feb 27, 2018

I wouldn't restrict the matplotlib version, as this could be an unnecessary inconvenience for users.
BTW, currently we don't even officially depend on matplotlib (according to setup.py).

The fix suggested by @trettberg seems less intrusive, but what about limiting the fix to the affected versions (since it looks like it'll be fixed in 2.2.0)?
Something like:

import matplotlib
if matplotlib.__version__.startswith('2.1'):
    p = np.clip(p, -1e15, 1e15)

sfs/plot.py Outdated
@@ -284,6 +285,9 @@ def soundfield(p, grid, xnorm=None, cmap='coolwarm_clip', vmin=-2.0, vmax=2.0,
if ax is None:
ax = plt.gca()

if matplotlib_version.startswith('2.1.'):
p = np.clip(p, -1e15, 1e15) # clip to float64 range
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we add a link to the matplotlib bug (matplotlib/matplotlib#10567) on the line before to highlight why we are doing this?

Copy link
Member

Choose a reason for hiding this comment

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

Otherwise this implementation is fine with me.

Copy link
Member

@mgeier mgeier left a comment

Choose a reason for hiding this comment

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

Great, thanks, LGTM!

@hagenw hagenw merged commit 8023d6e into master Mar 14, 2018
@hagenw hagenw deleted the fix_soundfield_plot branch March 14, 2018 10:07
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.

Monofrequent dipole source example plot
3 participants