Skip to content

Commit

Permalink
Flaking, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
convert-repo authored and cphyc committed Sep 1, 2020
1 parent c604635 commit 275ba01
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 22 deletions.
1 change: 1 addition & 0 deletions yt/utilities/on_demand_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ def ndimage(self):
self._ndimage = ndimage
return self._ndimage


_scipy = scipy_imports()


Expand Down
27 changes: 23 additions & 4 deletions yt/visualization/fixed_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,15 @@ class FixedResolutionBuffer:
("index", "dtheta"),
)

def __init__(self, data_source, bounds, buff_size, antialias=True, periodic=False, filters=None):
def __init__(
self,
data_source,
bounds,
buff_size,
antialias=True,
periodic=False,
filters=None,
):
self.data_source = data_source
self.ds = data_source.ds
self.bounds = bounds
Expand Down Expand Up @@ -585,7 +593,7 @@ class CylindricalFixedResolutionBuffer(FixedResolutionBuffer):
that supports non-aligned input data objects, primarily cutting planes.
"""

def __init__(self, data_source, radius, buff_size, antialias=True, filters=None) :
def __init__(self, data_source, radius, buff_size, antialias=True, filters=None):
self.data_source = data_source
self.ds = data_source.ds
self.radius = radius
Expand Down Expand Up @@ -667,8 +675,19 @@ class ParticleImageBuffer(FixedResolutionBuffer):
buffer.
"""
def __init__(self, data_source, radius, buff_size, antialias=True, periodic=False, filters=None):
super(ParticleImageBuffer, self).__init__(data_source, radius, buff_size, antialias, periodic, filters)

def __init__(
self,
data_source,
radius,
buff_size,
antialias=True,
periodic=False,
filters=None,
):
super(ParticleImageBuffer, self).__init__(
data_source, radius, buff_size, antialias, periodic, filters
)

# set up the axis field names
axis = self.axis
Expand Down
12 changes: 5 additions & 7 deletions yt/visualization/fixed_resolution_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,16 @@ def __init__(self, sigma=2.0, nbeam=None, **kwa):
if nbeam is not None:
issue_deprecation_warning(
"The `nbeam` argument has been deprecated and should be replaced by "
"the `truncate` argument where `truncate=nbeam/sigma`.")
kwa['truncate'] = nbeam / sigma
"the `truncate` argument where `truncate=nbeam/sigma`."
)
kwa["truncate"] = nbeam / sigma
self.sigma = sigma
self.extra_args = kwa

def apply(self, buff):
from yt.utilities.on_demand_imports import _scipy
spl = _scipy.ndimage.gaussian_filter(
buff,
self.sigma,
**self.extra_args
)

spl = _scipy.ndimage.gaussian_filter(buff, self.sigma, **self.extra_args)
return spl


Expand Down
2 changes: 1 addition & 1 deletion yt/visualization/plot_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def _switch_ds(self, new_ds, data_source=None):
new_object = getattr(new_ds, name)(**kwargs)

self.data_source = new_object

if self._frb is not None:
self._frb._data_valid = False
self._plot_valid = False
Expand Down
1 change: 1 addition & 0 deletions yt/visualization/plot_modifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ class GridBoundaryCallback(PlotCallback):
One can set min and maximum level of grids to display, and
can change the linewidth of the displayed grids.
"""

_type_name = "annotate_grids"
_supported_geometries = ("cartesian", "spectral_cube", "cylindrical")

Expand Down
2 changes: 1 addition & 1 deletion yt/visualization/plot_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def _recreate_frb(self):
self.buff_size,
self.antialias,
periodic=self._periodic,
filters=old_filders
filters=old_filters,
)

# At this point the frb has the valid bounds, size, aliasing, etc.
Expand Down
20 changes: 11 additions & 9 deletions yt/visualization/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"""

from yt.testing import fake_amr_ds, requires_module
import yt
import numpy as np

import yt
from yt.testing import fake_amr_ds, requires_module


@requires_module("scipy")
def test_white_noise_filter():
ds = fake_amr_ds(fields=("density",))
Expand All @@ -29,20 +31,21 @@ def test_gauss_beam_filter():
@requires_module("scipy")
def test_filter_wiring():
from scipy.ndimage import gaussian_filter
ds = fake_amr_ds(fields=("density", ))
p = yt.SlicePlot(ds, 'x', 'density')

ds = fake_amr_ds(fields=("density",))
p = yt.SlicePlot(ds, "x", "density")

frb1 = p.frb
data_orig = frb1['density'].value
data_orig = frb1["density"].value

sigma = 2
p.frb.apply_gauss_beam(sigma)
frb2 = p.frb
data_gauss = frb2['density'].value
data_gauss = frb2["density"].value

p.frb.apply_white_noise()
frb3 = p.frb
data_white = frb3['density'].value
data_white = frb3["density"].value

# We check the frb have changed
assert frb1 != frb2
Expand All @@ -55,5 +58,4 @@ def test_filter_wiring():
assert np.allclose(data_gauss, data_white) is False

# Check the gaussian filtering should is ok
assert np.allclose(gaussian_filter(data_orig, sigma),
data_gauss)
assert np.allclose(gaussian_filter(data_orig, sigma), data_gauss)

0 comments on commit 275ba01

Please sign in to comment.