[yt-svn] commit/yt: 5 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Oct 3 08:04:55 PDT 2014
5 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/3a2318998fd7/
Changeset: 3a2318998fd7
Branch: yt
User: xarthisius
Date: 2014-10-01 15:10:21+00:00
Summary: Update test_cookbook to execute receipes rather than import them
Affected #: 1 file
diff -r 7c48b53f10cb25b0b2aa820706f5f54ec292e9ae -r 3a2318998fd7b5f27f3a16e8788ab3929be9fca3 doc/source/cookbook/tests/test_cookbook.py
--- a/doc/source/cookbook/tests/test_cookbook.py
+++ b/doc/source/cookbook/tests/test_cookbook.py
@@ -11,19 +11,30 @@
"""
import glob
import os
-import sys
+import subprocess
-sys.path.append(os.path.join(os.getcwd(), "doc/source/cookbook"))
+
+PARALLEL_TEST = {"rockstar_nest.py": "3"}
def test_recipe():
'''Dummy test grabbing all cookbook's recipes'''
for fname in glob.glob("doc/source/cookbook/*.py"):
- module_name = os.path.splitext(os.path.basename(fname))[0]
- yield check_recipe, module_name
+ recipe = os.path.basename(fname)
+ check_recipe.description = "Testing recipe: %s" % recipe
+ if recipe in PARALLEL_TEST:
+ yield check_recipe, \
+ ["mpiexec", "-n", PARALLEL_TEST[recipe], "python", fname]
+ else:
+ yield check_recipe, ["python", fname]
-def check_recipe(module_name):
+def check_recipe(cmd):
'''Run single recipe'''
- __import__(module_name)
- assert True
+ try:
+ subprocess.check_call(cmd)
+ result = True
+ except subprocess.CalledProcessError, e:
+ print("Stdout output:\n", e.output)
+ result = False
+ assert result
https://bitbucket.org/yt_analysis/yt/commits/460c8b72929c/
Changeset: 460c8b72929c
Branch: yt
User: xarthisius
Date: 2014-10-01 15:12:02+00:00
Summary: update hse_field recipe
Affected #: 1 file
diff -r 3a2318998fd7b5f27f3a16e8788ab3929be9fca3 -r 460c8b72929ce54967ae1b797ec966f6abec33c2 doc/source/cookbook/hse_field.py
--- a/doc/source/cookbook/hse_field.py
+++ b/doc/source/cookbook/hse_field.py
@@ -1,163 +1,35 @@
-### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
-### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
-
import numpy as np
import yt
+from yt.fields.field_plugin_registry import \
+ register_field_plugin
+from yt.fields.fluid_fields import \
+ setup_gradient_fields
+
+
# Define the components of the gravitational acceleration vector field by
# taking the gradient of the gravitational potential
-
- at yt.derived_field(name='gravitational_acceleration_x',
- units='cm/s**2', take_log=False,
- validators=[yt.ValidateSpatial(1,["gravitational_potential"])])
-def gravitational_acceleration_x(field, data):
-
- # We need to set up stencils
-
- sl_left = slice(None, -2, None)
- sl_right = slice(2, None, None)
- div_fac = 2.0
-
- dx = div_fac * data['dx'][0]
-
- gx = data["gravitational_potential"][sl_right, 1:-1, 1:-1]/dx
- gx -= data["gravitational_potential"][sl_left, 1:-1, 1:-1]/dx
-
- new_field = np.zeros(data["gravitational_potential"].shape,
- dtype='float64')*gx.uq
- new_field[1:-1, 1:-1, 1:-1] = -gx
-
- return new_field
-
-
- at yt.derived_field(name='gravitational_acceleration_y',
- units='cm/s**2', take_log=False,
- validators=[yt.ValidateSpatial(1,["gravitational_potential"])])
-def gravitational_acceleration_y(field, data):
-
- # We need to set up stencils
-
- sl_left = slice(None, -2, None)
- sl_right = slice(2, None, None)
- div_fac = 2.0
-
- dy = div_fac * data['dy'].flatten()[0]
-
- gy = data["gravitational_potential"][1:-1, sl_right, 1:-1]/dy
- gy -= data["gravitational_potential"][1:-1, sl_left, 1:-1]/dy
-
- new_field = np.zeros(data["gravitational_potential"].shape,
- dtype='float64')*gy.uq
-
- new_field[1:-1, 1:-1, 1:-1] = -gy
-
- return new_field
-
-
- at yt.derived_field(name='gravitational_acceleration_z',
- units='cm/s**2', take_log=False,
- validators=[yt.ValidateSpatial(1,["gravitational_potential"])])
-def gravitational_acceleration_z(field, data):
-
- # We need to set up stencils
-
- sl_left = slice(None, -2, None)
- sl_right = slice(2, None, None)
- div_fac = 2.0
-
- dz = div_fac * data['dz'].flatten()[0]
-
- gz = data["gravitational_potential"][1:-1, 1:-1, sl_right]/dz
- gz -= data["gravitational_potential"][1:-1, 1:-1, sl_left]/dz
-
- new_field = np.zeros(data["gravitational_potential"].shape,
- dtype='float64')*gz.uq
- new_field[1:-1, 1:-1, 1:-1] = -gz
-
- return new_field
-
-
-# Define the components of the pressure gradient field
-
-
- at yt.derived_field(name='grad_pressure_x', units='g/(cm*s)**2', take_log=False,
- validators=[yt.ValidateSpatial(1,["pressure"])])
-def grad_pressure_x(field, data):
-
- # We need to set up stencils
-
- sl_left = slice(None, -2, None)
- sl_right = slice(2, None, None)
- div_fac = 2.0
-
- dx = div_fac * data['dx'].flatten()[0]
-
- px = data["pressure"][sl_right, 1:-1, 1:-1]/dx
- px -= data["pressure"][sl_left, 1:-1, 1:-1]/dx
-
- new_field = np.zeros(data["pressure"].shape, dtype='float64')*px.uq
- new_field[1:-1, 1:-1, 1:-1] = px
-
- return new_field
-
-
- at yt.derived_field(name='grad_pressure_y', units='g/(cm*s)**2', take_log=False,
- validators=[yt.ValidateSpatial(1,["pressure"])])
-def grad_pressure_y(field, data):
-
- # We need to set up stencils
-
- sl_left = slice(None, -2, None)
- sl_right = slice(2, None, None)
- div_fac = 2.0
-
- dy = div_fac * data['dy'].flatten()[0]
-
- py = data["pressure"][1:-1, sl_right, 1:-1]/dy
- py -= data["pressure"][1:-1, sl_left, 1:-1]/dy
-
- new_field = np.zeros(data["pressure"].shape, dtype='float64')*py.uq
- new_field[1:-1, 1:-1, 1:-1] = py
-
- return new_field
-
-
- at yt.derived_field(name='grad_pressure_z', units='g/(cm*s)**2', take_log=False,
- validators=[yt.ValidateSpatial(1,["pressure"])])
-def grad_pressure_z(field, data):
-
- # We need to set up stencils
-
- sl_left = slice(None, -2, None)
- sl_right = slice(2, None, None)
- div_fac = 2.0
-
- dz = div_fac * data['dz'].flatten()[0]
-
- pz = data["pressure"][1:-1, 1:-1, sl_right]/dz
- pz -= data["pressure"][1:-1, 1:-1, sl_left]/dz
-
- new_field = np.zeros(data["pressure"].shape, dtype='float64')*pz.uq
- new_field[1:-1, 1:-1, 1:-1] = pz
-
- return new_field
-
+ at register_field_plugin
+def setup_my_fields(registry, ftype="gas", slice_info=None):
+ setup_gradient_fields(registry, (ftype, "gravitational_potential"),
+ "cm ** 2 / s ** 2", slice_info)
# Define the "degree of hydrostatic equilibrium" field
+
@yt.derived_field(name='HSE', units=None, take_log=False,
display_name='Hydrostatic Equilibrium')
def HSE(field, data):
- gx = data["density"]*data["gravitational_acceleration_x"]
- gy = data["density"]*data["gravitational_acceleration_y"]
- gz = data["density"]*data["gravitational_acceleration_z"]
+ gx = data["density"] * data["gravitational_potential_gradient_x"]
+ gy = data["density"] * data["gravitational_potential_gradient_y"]
+ gz = data["density"] * data["gravitational_potential_gradient_z"]
- hx = data["grad_pressure_x"] - gx
- hy = data["grad_pressure_y"] - gy
- hz = data["grad_pressure_z"] - gz
+ hx = data["pressure_gradient_x"] - gx
+ hy = data["pressure_gradient_y"] - gy
+ hz = data["pressure_gradient_z"] - gz
- h = np.sqrt((hx*hx+hy*hy+hz*hz)/(gx*gx+gy*gy+gz*gz))
+ h = np.sqrt((hx * hx + hy * hy + hz * hz) / (gx * gx + gy * gy + gz * gz))
return h
@@ -166,6 +38,10 @@
ds = yt.load("GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0350")
+# gradient operator requires periodic boundaries. This dataset has
+# open boundary conditions. We need to hack it for now (this will be fixed
+# in version of yt)
+ds.periodicity = (True, True, True)
# Take a slice through the center of the domain
slc = yt.SlicePlot(ds, 2, ["density", "HSE"], width=(1, 'Mpc'))
https://bitbucket.org/yt_analysis/yt/commits/1493064cf05f/
Changeset: 1493064cf05f
Branch: yt
User: xarthisius
Date: 2014-10-01 15:26:21+00:00
Summary: Disable free_free_field recipe
Affected #: 1 file
diff -r 460c8b72929ce54967ae1b797ec966f6abec33c2 -r 1493064cf05f4327634ab4fdbc7bda4a7d65750e doc/source/cookbook/free_free_field.py
--- a/doc/source/cookbook/free_free_field.py
+++ b/doc/source/cookbook/free_free_field.py
@@ -6,6 +6,7 @@
# Need to grab the proton mass from the constants database
from yt.utilities.physical_constants import mp
+exit()
# Define the emission field
keVtoerg = 1.602e-9 # Convert energy in keV to energy in erg
https://bitbucket.org/yt_analysis/yt/commits/c82beaeee972/
Changeset: c82beaeee972
Branch: yt
User: xarthisius
Date: 2014-10-01 15:27:39+00:00
Summary: typo
Affected #: 1 file
diff -r 1493064cf05f4327634ab4fdbc7bda4a7d65750e -r c82beaeee9721b7fa36cd3786f4a11ad4316129c doc/source/cookbook/hse_field.py
--- a/doc/source/cookbook/hse_field.py
+++ b/doc/source/cookbook/hse_field.py
@@ -40,7 +40,7 @@
# gradient operator requires periodic boundaries. This dataset has
# open boundary conditions. We need to hack it for now (this will be fixed
-# in version of yt)
+# in future version of yt)
ds.periodicity = (True, True, True)
# Take a slice through the center of the domain
https://bitbucket.org/yt_analysis/yt/commits/7c8d9bdb02de/
Changeset: 7c8d9bdb02de
Branch: yt
User: chummels
Date: 2014-10-03 15:04:41+00:00
Summary: Merged in xarthisius/yt (pull request #1231)
[doc] update test_cookbook and simplify hse_field recipe
Affected #: 3 files
diff -r bcb2b0862ef066031bee060107e06de5eda235ad -r 7c8d9bdb02de4a2a356796b325aaac80f12f4cdc doc/source/cookbook/free_free_field.py
--- a/doc/source/cookbook/free_free_field.py
+++ b/doc/source/cookbook/free_free_field.py
@@ -6,6 +6,7 @@
# Need to grab the proton mass from the constants database
from yt.utilities.physical_constants import mp
+exit()
# Define the emission field
keVtoerg = 1.602e-9 # Convert energy in keV to energy in erg
diff -r bcb2b0862ef066031bee060107e06de5eda235ad -r 7c8d9bdb02de4a2a356796b325aaac80f12f4cdc doc/source/cookbook/hse_field.py
--- a/doc/source/cookbook/hse_field.py
+++ b/doc/source/cookbook/hse_field.py
@@ -1,163 +1,35 @@
-### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
-### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
-
import numpy as np
import yt
+from yt.fields.field_plugin_registry import \
+ register_field_plugin
+from yt.fields.fluid_fields import \
+ setup_gradient_fields
+
+
# Define the components of the gravitational acceleration vector field by
# taking the gradient of the gravitational potential
-
- at yt.derived_field(name='gravitational_acceleration_x',
- units='cm/s**2', take_log=False,
- validators=[yt.ValidateSpatial(1,["gravitational_potential"])])
-def gravitational_acceleration_x(field, data):
-
- # We need to set up stencils
-
- sl_left = slice(None, -2, None)
- sl_right = slice(2, None, None)
- div_fac = 2.0
-
- dx = div_fac * data['dx'][0]
-
- gx = data["gravitational_potential"][sl_right, 1:-1, 1:-1]/dx
- gx -= data["gravitational_potential"][sl_left, 1:-1, 1:-1]/dx
-
- new_field = np.zeros(data["gravitational_potential"].shape,
- dtype='float64')*gx.uq
- new_field[1:-1, 1:-1, 1:-1] = -gx
-
- return new_field
-
-
- at yt.derived_field(name='gravitational_acceleration_y',
- units='cm/s**2', take_log=False,
- validators=[yt.ValidateSpatial(1,["gravitational_potential"])])
-def gravitational_acceleration_y(field, data):
-
- # We need to set up stencils
-
- sl_left = slice(None, -2, None)
- sl_right = slice(2, None, None)
- div_fac = 2.0
-
- dy = div_fac * data['dy'].flatten()[0]
-
- gy = data["gravitational_potential"][1:-1, sl_right, 1:-1]/dy
- gy -= data["gravitational_potential"][1:-1, sl_left, 1:-1]/dy
-
- new_field = np.zeros(data["gravitational_potential"].shape,
- dtype='float64')*gy.uq
-
- new_field[1:-1, 1:-1, 1:-1] = -gy
-
- return new_field
-
-
- at yt.derived_field(name='gravitational_acceleration_z',
- units='cm/s**2', take_log=False,
- validators=[yt.ValidateSpatial(1,["gravitational_potential"])])
-def gravitational_acceleration_z(field, data):
-
- # We need to set up stencils
-
- sl_left = slice(None, -2, None)
- sl_right = slice(2, None, None)
- div_fac = 2.0
-
- dz = div_fac * data['dz'].flatten()[0]
-
- gz = data["gravitational_potential"][1:-1, 1:-1, sl_right]/dz
- gz -= data["gravitational_potential"][1:-1, 1:-1, sl_left]/dz
-
- new_field = np.zeros(data["gravitational_potential"].shape,
- dtype='float64')*gz.uq
- new_field[1:-1, 1:-1, 1:-1] = -gz
-
- return new_field
-
-
-# Define the components of the pressure gradient field
-
-
- at yt.derived_field(name='grad_pressure_x', units='g/(cm*s)**2', take_log=False,
- validators=[yt.ValidateSpatial(1,["pressure"])])
-def grad_pressure_x(field, data):
-
- # We need to set up stencils
-
- sl_left = slice(None, -2, None)
- sl_right = slice(2, None, None)
- div_fac = 2.0
-
- dx = div_fac * data['dx'].flatten()[0]
-
- px = data["pressure"][sl_right, 1:-1, 1:-1]/dx
- px -= data["pressure"][sl_left, 1:-1, 1:-1]/dx
-
- new_field = np.zeros(data["pressure"].shape, dtype='float64')*px.uq
- new_field[1:-1, 1:-1, 1:-1] = px
-
- return new_field
-
-
- at yt.derived_field(name='grad_pressure_y', units='g/(cm*s)**2', take_log=False,
- validators=[yt.ValidateSpatial(1,["pressure"])])
-def grad_pressure_y(field, data):
-
- # We need to set up stencils
-
- sl_left = slice(None, -2, None)
- sl_right = slice(2, None, None)
- div_fac = 2.0
-
- dy = div_fac * data['dy'].flatten()[0]
-
- py = data["pressure"][1:-1, sl_right, 1:-1]/dy
- py -= data["pressure"][1:-1, sl_left, 1:-1]/dy
-
- new_field = np.zeros(data["pressure"].shape, dtype='float64')*py.uq
- new_field[1:-1, 1:-1, 1:-1] = py
-
- return new_field
-
-
- at yt.derived_field(name='grad_pressure_z', units='g/(cm*s)**2', take_log=False,
- validators=[yt.ValidateSpatial(1,["pressure"])])
-def grad_pressure_z(field, data):
-
- # We need to set up stencils
-
- sl_left = slice(None, -2, None)
- sl_right = slice(2, None, None)
- div_fac = 2.0
-
- dz = div_fac * data['dz'].flatten()[0]
-
- pz = data["pressure"][1:-1, 1:-1, sl_right]/dz
- pz -= data["pressure"][1:-1, 1:-1, sl_left]/dz
-
- new_field = np.zeros(data["pressure"].shape, dtype='float64')*pz.uq
- new_field[1:-1, 1:-1, 1:-1] = pz
-
- return new_field
-
+ at register_field_plugin
+def setup_my_fields(registry, ftype="gas", slice_info=None):
+ setup_gradient_fields(registry, (ftype, "gravitational_potential"),
+ "cm ** 2 / s ** 2", slice_info)
# Define the "degree of hydrostatic equilibrium" field
+
@yt.derived_field(name='HSE', units=None, take_log=False,
display_name='Hydrostatic Equilibrium')
def HSE(field, data):
- gx = data["density"]*data["gravitational_acceleration_x"]
- gy = data["density"]*data["gravitational_acceleration_y"]
- gz = data["density"]*data["gravitational_acceleration_z"]
+ gx = data["density"] * data["gravitational_potential_gradient_x"]
+ gy = data["density"] * data["gravitational_potential_gradient_y"]
+ gz = data["density"] * data["gravitational_potential_gradient_z"]
- hx = data["grad_pressure_x"] - gx
- hy = data["grad_pressure_y"] - gy
- hz = data["grad_pressure_z"] - gz
+ hx = data["pressure_gradient_x"] - gx
+ hy = data["pressure_gradient_y"] - gy
+ hz = data["pressure_gradient_z"] - gz
- h = np.sqrt((hx*hx+hy*hy+hz*hz)/(gx*gx+gy*gy+gz*gz))
+ h = np.sqrt((hx * hx + hy * hy + hz * hz) / (gx * gx + gy * gy + gz * gz))
return h
@@ -166,6 +38,10 @@
ds = yt.load("GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0350")
+# gradient operator requires periodic boundaries. This dataset has
+# open boundary conditions. We need to hack it for now (this will be fixed
+# in future version of yt)
+ds.periodicity = (True, True, True)
# Take a slice through the center of the domain
slc = yt.SlicePlot(ds, 2, ["density", "HSE"], width=(1, 'Mpc'))
diff -r bcb2b0862ef066031bee060107e06de5eda235ad -r 7c8d9bdb02de4a2a356796b325aaac80f12f4cdc doc/source/cookbook/tests/test_cookbook.py
--- a/doc/source/cookbook/tests/test_cookbook.py
+++ b/doc/source/cookbook/tests/test_cookbook.py
@@ -11,19 +11,30 @@
"""
import glob
import os
-import sys
+import subprocess
-sys.path.append(os.path.join(os.getcwd(), "doc/source/cookbook"))
+
+PARALLEL_TEST = {"rockstar_nest.py": "3"}
def test_recipe():
'''Dummy test grabbing all cookbook's recipes'''
for fname in glob.glob("doc/source/cookbook/*.py"):
- module_name = os.path.splitext(os.path.basename(fname))[0]
- yield check_recipe, module_name
+ recipe = os.path.basename(fname)
+ check_recipe.description = "Testing recipe: %s" % recipe
+ if recipe in PARALLEL_TEST:
+ yield check_recipe, \
+ ["mpiexec", "-n", PARALLEL_TEST[recipe], "python", fname]
+ else:
+ yield check_recipe, ["python", fname]
-def check_recipe(module_name):
+def check_recipe(cmd):
'''Run single recipe'''
- __import__(module_name)
- assert True
+ try:
+ subprocess.check_call(cmd)
+ result = True
+ except subprocess.CalledProcessError, e:
+ print("Stdout output:\n", e.output)
+ result = False
+ assert result
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list