Skip to content

Commit

Permalink
Set field parameters on blocks. Closes #1407
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Goldbaum committed May 19, 2017
1 parent 9d1374f commit bf6748d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions yt/data_objects/data_containers.py
Expand Up @@ -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):
Expand Down
18 changes: 18 additions & 0 deletions yt/data_objects/tests/test_fluxes.py
Expand Up @@ -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)

0 comments on commit bf6748d

Please sign in to comment.