From bf6748d26a88a67441c77c203672032ab8b43001 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Fri, 19 May 2017 12:06:24 -0500 Subject: [PATCH] Set field parameters on blocks. Closes #1407 --- yt/data_objects/data_containers.py | 3 +++ yt/data_objects/tests/test_fluxes.py | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/yt/data_objects/data_containers.py b/yt/data_objects/data_containers.py index 792dc5a3fac..86f4d5c1712 100644 --- a/yt/data_objects/data_containers.py +++ b/yt/data_objects/data_containers.py @@ -1166,9 +1166,12 @@ def blocks(self): # For grids this will be a grid object, and for octrees it will # be an OctreeSubset. Note that we delegate to the sub-object. o = self._current_chunk.objs[0] + cache_fp = o.field_parameters.copy() + o.field_parameters.update(self.field_parameters) for b, m in o.select_blocks(self.selector): if m is None: continue yield b, m + o.field_parameters = cache_fp class GenerationInProgress(Exception): def __init__(self, fields): diff --git a/yt/data_objects/tests/test_fluxes.py b/yt/data_objects/tests/test_fluxes.py index 113880f3000..e96195b0b35 100644 --- a/yt/data_objects/tests/test_fluxes.py +++ b/yt/data_objects/tests/test_fluxes.py @@ -111,3 +111,21 @@ def test_correct_output_unit(): Nmax = sp1.max('HI_Density') sur = ds.surface(sp1,"HI_Density", .5*Nmax) sur['x'][0] + +@requires_file(ISOGAL) +def test_radius_surface(): + # see #1407 + ds = load(ISOGAL) + reg = ds.all_data() + sp = ds.sphere(ds.domain_center, (0.5, 'code_length')) + for obj in [reg, sp]: + for rad in [0.05, .1, .4]: + surface = ds.surface(obj, 'radius', (rad, 'code_length')) + assert_almost_equal( + surface.surface_area.v, 4*np.pi*rad**2, decimal=2) + verts = surface.vertices + for i in range(3): + assert_almost_equal( + verts[i, :].min().v, 0.5-rad, decimal=2) + assert_almost_equal( + verts[i, :].max().v, 0.5+rad, decimal=2)