[yt-svn] commit/yt: ngoldbaum: Merged in jzuhone/yt-3.x (pull request #1236)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Oct 24 11:26:46 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/840185d54851/
Changeset: 840185d54851
Branch: yt
User: ngoldbaum
Date: 2014-10-24 18:26:35+00:00
Summary: Merged in jzuhone/yt-3.x (pull request #1236)
[APICHANGE] Overriding code units
Affected #: 36 files
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d doc/source/analyzing/units/3)_Comoving_units_and_code_units.ipynb
--- a/doc/source/analyzing/units/3)_Comoving_units_and_code_units.ipynb
+++ b/doc/source/analyzing/units/3)_Comoving_units_and_code_units.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:8ba193cc3867e2185133bbf3952bd5834e6c63993208635c71cf55fa6f27b491"
+ "signature": "sha256:67eb4b2a3d1017bac09209ebc939e8c1fe154660fa15f76862019dfc8652ec32"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -305,9 +305,95 @@
"language": "python",
"metadata": {},
"outputs": []
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Overriding Code Unit Definitions"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "On occasion, you might have a dataset for a supported frontend that does not have the conversions to code units accessible (for example, Athena data) or you may want to change them outright. `yt` provides a mechanism so that one may provide their own code unit definitions to `load`, which override the default rules for a given frontend for defining code units. This is provided through the `units_override` dictionary. We'll use an example of an Athena dataset. First, a call to `load` without `units_override`:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "ds1 = yt.load(\"MHDSloshing/virgo_low_res.0054.vtk\")\n",
+ "print ds1.length_unit\n",
+ "print ds1.mass_unit\n",
+ "print ds1.time_unit\n",
+ "sp1 = ds1.sphere(\"c\",(0.1,\"unitary\"))\n",
+ "print sp1[\"density\"]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "This is a galaxy cluster dataset, so it is not likely that the units of density are correct. We happen to know that the unit definitions are different, so we can override the units:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "units_override = {\"length_unit\":(1.0,\"Mpc\"),\n",
+ " \"time_unit\":(1.0,\"Myr\"),\n",
+ " \"mass_unit\":(1.0e14,\"Msun\")}"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "`units_override` can take the following keys:\n",
+ "\n",
+ "* `length_unit`\n",
+ "* `time_unit`\n",
+ "* `mass_unit`\n",
+ "* `magnetic_unit`\n",
+ "* `temperature_unit`\n",
+ "\n",
+ "and the associated values can be (value, unit) tuples, `YTQuantities`, or floats (in the latter case they are assumed to have the corresponding cgs unit). "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "ds2 = yt.load(\"MHDSloshing/virgo_low_res.0054.vtk\", units_override=units_override)\n",
+ "print ds2.length_unit\n",
+ "print ds2.mass_unit\n",
+ "print ds2.time_unit\n",
+ "sp2 = ds2.sphere(\"c\",(0.1,\"unitary\"))\n",
+ "print sp2[\"density\"]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "This option should be used very carefully, and *only* if you know that the dataset does not provide units or that the unit definitions generated are incorrect for some reason. "
+ ]
}
],
"metadata": {}
}
]
-}
+}
\ No newline at end of file
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -113,29 +113,56 @@
yt works in cgs ("Gaussian") units by default, but Athena data is not
normally stored in these units. If you would like to convert data to
-cgs units, you may supply conversions for length, time, and mass to ``load``:
+cgs units, you may supply conversions for length, time, and mass to ``load`` using
+the ``units_override`` functionality:
.. code-block:: python
import yt
- ds = yt.load("id0/cluster_merger.0250.vtk",
- parameters={"length_unit":(1.0,"Mpc"),
- "time_unit"(1.0,"Myr"),
- "mass_unit":(1.0e14,"Msun")})
+
+ units_override = {"length_unit":(1.0,"Mpc"),
+ "time_unit"(1.0,"Myr"),
+ "mass_unit":(1.0e14,"Msun")}
+
+ ds = yt.load("id0/cluster_merger.0250.vtk", units_override=units_override)
This means that the yt fields, e.g. ``("gas","density")``, ``("gas","x-velocity")``,
``("gas","magnetic_field_x")``, will be in cgs units, but the Athena fields, e.g.,
``("athena","density")``, ``("athena","velocity_x")``, ``("athena","cell_centered_B_x")``, will be
in code units.
+Alternative values for the following simulation parameters may be specified using a ``parameters``
+dict, accepting the following keys:
+
+* ``Gamma``: ratio of specific heats, Type: Float
+* ``geometry``: Geometry type, currently accepts ``"cartesian"`` or ``"cylindrical"``
+* ``periodicity``: Is the domain periodic? Type: Tuple of boolean values corresponding to each dimension
+
+.. code-block:: python
+
+ import yt
+
+ parameters = {"gamma":4./3., "geometry":"cylindrical", "periodicity":(False,False,False)}
+
+ ds = yt.load("relativistic_jet_0000.vtk", parameters=parameters)
+
.. rubric:: Caveats
* yt primarily works with primitive variables. If the Athena
dataset contains conservative variables, the yt primitive fields will be generated from the
conserved variables on disk.
+* Special relativistic datasets may be loaded, but are not fully supported. In particular, the relationships between
+ quantities such as pressure and thermal energy will be incorrect, as it is currently assumed that their relationship
+ is that of an ideal a :math:`\gamma`-law equation of state.
* Domains may be visualized assuming periodicity.
* Particle list data is currently unsupported.
+.. note::
+
+ The old behavior of supplying unit conversions using a ``parameters``
+ dict supplied to ``load`` for Athena datasets is still supported, but is being deprecated in
+ favor of ``units_override``, which provides the same functionality.
+
.. _loading-orion-data:
BoxLib Data
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d doc/source/reference/configuration.rst
--- a/doc/source/reference/configuration.rst
+++ b/doc/source/reference/configuration.rst
@@ -95,3 +95,5 @@
quiet.
* ``stdoutStreamLogging`` (default: ``'False'``): If true, logging is directed
to stdout rather than stderr
+* ``skip_dataset_cache`` (default: ``'False'``): If true, automatic caching of datasets
+ is turned off.
\ No newline at end of file
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/config.py
--- a/yt/config.py
+++ b/yt/config.py
@@ -39,6 +39,7 @@
storeparameterfiles = 'False',
parameterfilestore = 'parameter_files.csv',
maximumstoreddatasets = '500',
+ skip_dataset_cache = 'False',
loadfieldplugins = 'True',
pluginfilename = 'my_plugins.py',
parallel_traceback = 'False',
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -134,7 +134,9 @@
return obj
apath = os.path.abspath(filename)
#if not os.path.exists(apath): raise IOError(filename)
- if apath not in _cached_datasets:
+ if ytcfg.getboolean("yt","skip_dataset_cache"):
+ obj = object.__new__(cls)
+ elif apath not in _cached_datasets:
obj = object.__new__(cls)
if obj._skip_cache is False:
_cached_datasets[apath] = obj
@@ -142,7 +144,7 @@
obj = _cached_datasets[apath]
return obj
- def __init__(self, filename, dataset_type=None, file_style=None):
+ def __init__(self, filename, dataset_type=None, file_style=None, units_override=None):
"""
Base class for generating new output types. Principally consists of
a *filename* and a *dataset_type* which will be passed on to children.
@@ -157,6 +159,9 @@
self.known_filters = self.known_filters or {}
self.particle_unions = self.particle_unions or {}
self.field_units = self.field_units or {}
+ if units_override is None:
+ units_override = {}
+ self.units_override = units_override
# path stuff
self.parameter_filename = str(filename)
@@ -667,6 +672,8 @@
def set_code_units(self):
self._set_code_unit_attributes()
+ # here we override units, if overrides have been provided.
+ self._override_code_units()
self.unit_registry.modify("code_length", self.length_unit)
self.unit_registry.modify("code_mass", self.mass_unit)
self.unit_registry.modify("code_time", self.time_unit)
@@ -679,6 +686,24 @@
self.unit_registry.add("unitary", float(DW.max() * DW.units.cgs_value),
DW.units.dimensions)
+ def _override_code_units(self):
+ if len(self.units_override) == 0:
+ return
+ mylog.warning("Overriding code units. This is an experimental and potentially "+
+ "dangerous option that may yield inconsistent results, and must be used "+
+ "very carefully, and only if you know what you want from it.")
+ for unit, cgs in [("length", "cm"), ("time", "s"), ("mass", "g"),
+ ("velocity","cm/s"), ("magnetic","gauss"), ("temperature","K")]:
+ val = self.units_override.get("%s_unit" % unit, None)
+ if val is not None:
+ if isinstance(val, YTQuantity):
+ val = (val.v, str(val.units))
+ elif not isinstance(val, tuple):
+ val = (val, cgs)
+ u = getattr(self, "%s_unit" % unit)
+ mylog.info("Overriding %s_unit: %g %s -> %g %s.", unit, u.v, u.units, val[0], val[1])
+ setattr(self, "%s_unit" % unit, self.quan(val[0], val[1]))
+
_arr = None
@property
def arr(self):
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/fields/magnetic_field.py
--- a/yt/fields/magnetic_field.py
+++ b/yt/fields/magnetic_field.py
@@ -55,7 +55,7 @@
def _plasma_beta(field,data):
"""This assumes that your front end has provided Bx, By, Bz in
units of Gauss. If you use MKS, make sure to write your own
- PlasmaBeta field to deal with non-unitary \mu_0.
+ plasma_beta field to deal with non-unitary \mu_0.
"""
return data[ftype,'pressure']/data[ftype,'magnetic_energy']
registry.add_field((ftype, "plasma_beta"),
@@ -69,6 +69,10 @@
units="erg / cm**3")
def _magnetic_field_strength(field,data):
+ """This assumes that your front end has provided Bx, By, Bz in
+ units of Gauss. If you use MKS, make sure to write your own
+ PlasmaBeta field to deal with non-unitary \mu_0.
+ """
return np.sqrt(8.*np.pi*data[ftype,"magnetic_energy"])
registry.add_field((ftype,"magnetic_field_strength"),
function=_magnetic_field_strength,
@@ -110,3 +114,17 @@
units="gauss",
validators=[ValidateParameter("normal")])
+ def _alfven_speed(field,data):
+ """This assumes that your front end has provided Bx, By, Bz in
+ units of Gauss. If you use MKS, make sure to write your own
+ alfven_speed field to deal with non-unitary \mu_0.
+ """
+ return data[ftype,'magnetic_field_strength']/np.sqrt(4.*np.pi*data[ftype,'density'])
+ registry.add_field((ftype, "alfven_speed"), function=_alfven_speed,
+ units="cm/s")
+
+ def _mach_alfven(field,data):
+ return data[ftype,'velocity_magnitude']/data[ftype,'alfven_speed']
+ registry.add_field((ftype, "mach_alfven"), function=_mach_alfven,
+ units="dimensionless")
+
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/_skeleton/data_structures.py
--- a/yt/frontends/_skeleton/data_structures.py
+++ b/yt/frontends/_skeleton/data_structures.py
@@ -85,9 +85,12 @@
_index_class = SkeletonHierarchy
_field_info_class = SkeletonFieldInfo
- def __init__(self, filename, dataset_type='skeleton'):
+ def __init__(self, filename, dataset_type='skeleton',
+ storage_filename=None,
+ units_override=None):
self.fluid_types += ('skeleton',)
- Dataset.__init__(self, filename, dataset_type)
+ Dataset.__init__(self, filename, dataset_type,
+ units_override=units_override)
self.storage_filename = storage_filename
def _set_code_unit_attributes(self):
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py
+++ b/yt/frontends/art/data_structures.py
@@ -166,7 +166,8 @@
skip_particles=False, skip_stars=False,
limit_level=None, spread_age=True,
force_max_level=None, file_particle_header=None,
- file_particle_data=None, file_particle_stars=None):
+ file_particle_data=None, file_particle_stars=None,
+ units_override=None):
self.fluid_types += ("art", )
if fields is None:
fields = fluid_fields
@@ -186,7 +187,8 @@
self.spread_age = spread_age
self.domain_left_edge = np.zeros(3, dtype='float')
self.domain_right_edge = np.zeros(3, dtype='float')+1.0
- Dataset.__init__(self, filename, dataset_type)
+ Dataset.__init__(self, filename, dataset_type,
+ units_override=units_override)
self.storage_filename = storage_filename
def _find_files(self, file_amr):
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/art/tests/test_outputs.py
--- a/yt/frontends/art/tests/test_outputs.py
+++ b/yt/frontends/art/tests/test_outputs.py
@@ -16,7 +16,8 @@
from yt.testing import \
requires_file, \
- assert_equal
+ assert_equal, \
+ units_override_check
from yt.utilities.answer_testing.framework import \
requires_ds, \
big_patch_amr, \
@@ -48,3 +49,9 @@
@requires_file(d9p)
def test_ARTDataset():
assert isinstance(data_dir_load(d9p), ARTDataset)
+
+ at requires_file(d9p)
+def test_units_override():
+ for test in units_override_check(d9p):
+ yield test
+
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/artio/data_structures.py
--- a/yt/frontends/artio/data_structures.py
+++ b/yt/frontends/artio/data_structures.py
@@ -314,7 +314,8 @@
_field_info_class = ARTIOFieldInfo
def __init__(self, filename, dataset_type='artio',
- storage_filename=None, max_range = 1024):
+ storage_filename=None, max_range = 1024,
+ units_override=None):
if self._handle is not None:
return
self.max_range = max_range
@@ -324,7 +325,8 @@
self._handle = artio_fileset(self._fileset_prefix)
self.artio_parameters = self._handle.parameters
# Here we want to initiate a traceback, if the reader is not built.
- Dataset.__init__(self, filename, dataset_type)
+ Dataset.__init__(self, filename, dataset_type,
+ units_override=units_override)
self.storage_filename = storage_filename
def _set_code_unit_attributes(self):
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/artio/tests/test_outputs.py
--- a/yt/frontends/artio/tests/test_outputs.py
+++ b/yt/frontends/artio/tests/test_outputs.py
@@ -50,3 +50,8 @@
@requires_file(sizmbhloz)
def test_ARTIODataset():
assert isinstance(data_dir_load(sizmbhloz), ARTIODataset)
+
+ at requires_file(sizmbhloz)
+def test_units_override():
+ for test in units_override_check(sizmbhloz):
+ yield test
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/athena/data_structures.py
--- a/yt/frontends/athena/data_structures.py
+++ b/yt/frontends/athena/data_structures.py
@@ -285,7 +285,8 @@
# Need to reset the units in the dataset based on the correct
# domain left/right/dimensions.
- self.dataset._set_code_unit_attributes()
+ # DEV: Is this really necessary?
+ #self.dataset._set_code_unit_attributes()
if self.dataset.dimensionality <= 2 :
self.dataset.domain_dimensions[2] = np.int(1)
@@ -352,12 +353,24 @@
_dataset_type = "athena"
def __init__(self, filename, dataset_type='athena',
- storage_filename=None, parameters=None):
+ storage_filename=None, parameters=None,
+ units_override=None):
self.fluid_types += ("athena",)
if parameters is None:
parameters = {}
self.specified_parameters = parameters
- Dataset.__init__(self, filename, dataset_type)
+ if units_override is None:
+ units_override = {}
+ # This is for backwards-compatibility
+ already_warned = False
+ for k,v in self.specified_parameters.items():
+ if k.endswith("_unit") and k not in units_override:
+ if not already_warned:
+ mylog.warning("Supplying unit conversions from the parameters dict is deprecated, "+
+ "and will be removed in a future release. Use units_override instead.")
+ already_warned = True
+ units_override[k] = self.specified_parameters.pop(k)
+ Dataset.__init__(self, filename, dataset_type, units_override=units_override)
self.filename = filename
if storage_filename is None:
storage_filename = '%s.yt' % filename.split('/')[-1]
@@ -372,23 +385,21 @@
"""
Generates the conversion to various physical _units based on the parameter file
"""
+ if "length_unit" not in self.units_override:
+ self.no_cgs_equiv_length = True
for unit, cgs in [("length", "cm"), ("time", "s"), ("mass", "g")]:
- val = self.specified_parameters.get("%s_unit" % unit, None)
- if val is None:
- if unit == "length": self.no_cgs_equiv_length = True
- mylog.warning("No %s conversion to cgs provided. " +
- "Assuming 1.0 = 1.0 %s", unit, cgs)
- val = 1.0
- if not isinstance(val, tuple):
- val = (val, cgs)
- setattr(self, "%s_unit" % unit, self.quan(val[0], val[1]))
- self.velocity_unit = self.length_unit/self.time_unit
- self.magnetic_unit = np.sqrt(4*np.pi * self.mass_unit /
- (self.time_unit**2 * self.length_unit))
- self.magnetic_unit.convert_to_units("gauss")
+ # We set these to cgs for now, but they may be overridden later.
+ mylog.warning("Assuming 1.0 = 1.0 %s", cgs)
+ setattr(self, "%s_unit" % unit, self.quan(1.0, cgs))
def set_code_units(self):
super(AthenaDataset, self).set_code_units()
+ mag_unit = getattr(self, "magnetic_unit", None)
+ if mag_unit is None:
+ self.magnetic_unit = np.sqrt(4*np.pi * self.mass_unit /
+ (self.time_unit**2 * self.length_unit))
+ self.magnetic_unit.convert_to_units("gauss")
+
self.unit_registry.modify("code_magnetic", self.magnetic_unit)
def _parse_parameter_file(self):
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/athena/tests/test_outputs.py
--- a/yt/frontends/athena/tests/test_outputs.py
+++ b/yt/frontends/athena/tests/test_outputs.py
@@ -43,16 +43,16 @@
test_blast.__name__ = test.description
yield test
-parameters_stripping = {"time_unit":3.086e14,
- "length_unit":8.0236e22,
- "mass_unit":9.999e-30*8.0236e22**3}
+uo_stripping = {"time_unit":3.086e14,
+ "length_unit":8.0236e22,
+ "mass_unit":9.999e-30*8.0236e22**3}
_fields_stripping = ("temperature", "density", "specific_scalar[0]")
stripping = "RamPressureStripping/id0/rps.0062.vtk"
@requires_ds(stripping, big_data=True)
def test_stripping():
- ds = data_dir_load(stripping, kwargs={"parameters":parameters_stripping})
+ ds = data_dir_load(stripping, kwargs={"units_override":uo_stripping})
yield assert_equal, str(ds), "rps.0062"
for test in small_patch_amr(stripping, _fields_stripping):
test_stripping.__name__ = test.description
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/boxlib/data_structures.py
--- a/yt/frontends/boxlib/data_structures.py
+++ b/yt/frontends/boxlib/data_structures.py
@@ -366,7 +366,8 @@
cparam_filename="inputs",
fparam_filename="probin",
dataset_type='boxlib_native',
- storage_filename=None):
+ storage_filename=None,
+ units_override=None):
"""
The paramfile is usually called "inputs"
and there may be a fortran inputs file usually called "probin"
@@ -380,7 +381,8 @@
self.fparam_filename = self._localize_check(fparam_filename)
self.storage_filename = storage_filename
- Dataset.__init__(self, output_dir, dataset_type)
+ Dataset.__init__(self, output_dir, dataset_type,
+ units_override=units_override)
# These are still used in a few places.
if "HydroMethod" not in self.parameters.keys():
@@ -721,10 +723,12 @@
cparam_filename="inputs",
fparam_filename="probin",
dataset_type='orion_native',
- storage_filename=None):
+ storage_filename=None,
+ units_override=None):
BoxlibDataset.__init__(self, output_dir,
- cparam_filename, fparam_filename, dataset_type)
+ cparam_filename, fparam_filename,
+ dataset_type, units_override=units_override)
@classmethod
def _is_valid(cls, *args, **kwargs):
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/boxlib/tests/test_orion.py
--- a/yt/frontends/boxlib/tests/test_orion.py
+++ b/yt/frontends/boxlib/tests/test_orion.py
@@ -47,3 +47,9 @@
@requires_file(rt)
def test_OrionDataset():
assert isinstance(data_dir_load(rt), OrionDataset)
+
+ at requires_file(rt)
+def test_units_override():
+ for test in units_override_check(rt):
+ yield test
+
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/chombo/data_structures.py
--- a/yt/frontends/chombo/data_structures.py
+++ b/yt/frontends/chombo/data_structures.py
@@ -250,7 +250,8 @@
_field_info_class = ChomboFieldInfo
def __init__(self, filename, dataset_type='chombo_hdf5',
- storage_filename = None, ini_filename = None):
+ storage_filename = None, ini_filename = None,
+ units_override=None):
self.fluid_types += ("chombo",)
self._handle = HDF5FileHandler(filename)
self.dataset_type = dataset_type
@@ -265,7 +266,8 @@
self.geometry = "cartesian"
self.ini_filename = ini_filename
self.fullplotdir = os.path.abspath(filename)
- Dataset.__init__(self,filename, self.dataset_type)
+ Dataset.__init__(self,filename, self.dataset_type,
+ units_override=units_override)
self.storage_filename = storage_filename
self.cosmological_simulation = False
@@ -454,10 +456,12 @@
_field_info_class = PlutoFieldInfo
def __init__(self, filename, dataset_type='pluto_chombo_native',
- storage_filename = None, ini_filename = None):
+ storage_filename = None, ini_filename = None,
+ units_override=None):
ChomboDataset.__init__(self, filename, dataset_type,
- storage_filename, ini_filename)
+ storage_filename, ini_filename,
+ units_override=units_override)
def _parse_parameter_file(self):
"""
@@ -586,10 +590,12 @@
_field_info_class = Orion2FieldInfo
def __init__(self, filename, dataset_type='orion_chombo_native',
- storage_filename = None, ini_filename = None):
+ storage_filename = None, ini_filename = None,
+ units_override=None):
ChomboDataset.__init__(self, filename, dataset_type,
- storage_filename, ini_filename)
+ storage_filename, ini_filename,
+ units_override=units_override)
def _parse_parameter_file(self):
"""
@@ -672,10 +678,12 @@
_field_info_class = ChomboPICFieldInfo3D
def __init__(self, filename, dataset_type='chombo_hdf5',
- storage_filename=None, ini_filename=None):
+ storage_filename=None, ini_filename=None,
+ units_override=None):
ChomboDataset.__init__(self, filename, dataset_type,
- storage_filename, ini_filename)
+ storage_filename, ini_filename,
+ units_override=units_override)
if self.dimensionality == 1:
self._field_info_class = ChomboPICFieldInfo1D
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/chombo/tests/test_outputs.py
--- a/yt/frontends/chombo/tests/test_outputs.py
+++ b/yt/frontends/chombo/tests/test_outputs.py
@@ -15,7 +15,8 @@
from yt.testing import \
requires_file, \
- assert_equal
+ assert_equal, \
+ units_override_check
from yt.utilities.answer_testing.framework import \
requires_ds, \
small_patch_amr, \
@@ -80,3 +81,18 @@
@requires_file(kho)
def test_PlutoDataset():
assert isinstance(data_dir_load(kho), PlutoDataset)
+
+ at requires_file(zp)
+def test_units_override_zp():
+ for test in units_override_check(zp):
+ yield test
+
+ at requires_file(gc)
+def test_units_override_gc():
+ for test in units_override_check(gc):
+ yield test
+
+ at requires_file(kho)
+def test_units_override_kho():
+ for test in units_override_check(kho):
+ yield test
\ No newline at end of file
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/enzo/data_structures.py
--- a/yt/frontends/enzo/data_structures.py
+++ b/yt/frontends/enzo/data_structures.py
@@ -665,7 +665,8 @@
file_style = None,
parameter_override = None,
conversion_override = None,
- storage_filename = None):
+ storage_filename = None,
+ units_override=None):
"""
This class is a stripped down class that simply reads and parses
*filename* without looking at the index. *dataset_type* gets passed
@@ -682,8 +683,8 @@
if conversion_override is None: conversion_override = {}
self._conversion_override = conversion_override
self.storage_filename = storage_filename
-
- Dataset.__init__(self, filename, dataset_type, file_style=file_style)
+ Dataset.__init__(self, filename, dataset_type, file_style=file_style,
+ units_override=units_override)
def _setup_1d(self):
self._index_class = EnzoHierarchy1D
@@ -926,6 +927,8 @@
magnetic_unit = np.float64(magnetic_unit.in_cgs())
self.magnetic_unit = self.quan(magnetic_unit, "gauss")
+ self._override_code_units()
+
self.unit_registry.modify("code_magnetic", self.magnetic_unit)
self.unit_registry.modify("code_length", self.length_unit)
self.unit_registry.modify("code_mass", self.mass_unit)
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/enzo/tests/test_outputs.py
--- a/yt/frontends/enzo/tests/test_outputs.py
+++ b/yt/frontends/enzo/tests/test_outputs.py
@@ -91,6 +91,11 @@
# Now we test our species fields
yield check_color_conservation(ds)
+ at requires_file(enzotiny)
+def test_units_override():
+ for test in units_override_check(enzotiny):
+ yield test
+
@requires_ds(ecp, big_data=True)
def test_nuclei_density_fields():
ds = data_dir_load(ecp)
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/fits/data_structures.py
--- a/yt/frontends/fits/data_structures.py
+++ b/yt/frontends/fits/data_structures.py
@@ -313,17 +313,18 @@
_handle = None
def __init__(self, filename,
- dataset_type = 'fits',
- auxiliary_files = [],
- nprocs = None,
- storage_filename = None,
- nan_mask = None,
- spectral_factor = 1.0,
- z_axis_decomp = False,
- line_database = None,
- line_width = None,
- suppress_astropy_warnings = True,
- parameters = None):
+ dataset_type='fits',
+ auxiliary_files=[],
+ nprocs=None,
+ storage_filename=None,
+ nan_mask=None,
+ spectral_factor=1.0,
+ z_axis_decomp=False,
+ line_database=None,
+ line_width=None,
+ suppress_astropy_warnings=True,
+ parameters=None,
+ units_override=None):
if parameters is None:
parameters = {}
@@ -434,7 +435,7 @@
self.refine_by = 2
- Dataset.__init__(self, fn, dataset_type)
+ Dataset.__init__(self, fn, dataset_type, units_override=units_override)
self.storage_filename = storage_filename
def _set_code_unit_attributes(self):
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/fits/tests/test_outputs.py
--- a/yt/frontends/fits/tests/test_outputs.py
+++ b/yt/frontends/fits/tests/test_outputs.py
@@ -41,3 +41,9 @@
for test in small_patch_amr(vf, _fields_vels, input_center="c", input_weight="ones"):
test_velocity_field.__name__ = test.description
yield test
+
+ at requires_file(vf)
+def test_units_override():
+ for test in units_override_check(vf):
+ yield test
+
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -73,7 +73,7 @@
def _detect_output_fields(self):
ncomp = self._handle["/unknown names"].shape[0]
self.field_list = [("flash", s) for s in self._handle["/unknown names"][:].flat]
- if ("/particle names" in self._particle_handle) :
+ if ("/particle names" in self._particle_handle):
self.field_list += [("io", "particle_" + s[0].strip()) for s
in self._particle_handle["/particle names"][:]]
@@ -113,10 +113,10 @@
except KeyError:
self.grid_particle_count[:] = 0.0
self._particle_indices = np.zeros(self.num_grids + 1, dtype='int64')
- if self.num_grids > 1 :
+ if self.num_grids > 1:
np.add.accumulate(self.grid_particle_count.squeeze(),
out=self._particle_indices[1:])
- else :
+ else:
self._particle_indices[1] = self.grid_particle_count.squeeze()
# This will become redundant, as _prepare_grid will reset it to its
# current value. Note that FLASH uses 1-based indexing for refinement
@@ -191,29 +191,27 @@
def __init__(self, filename, dataset_type='flash_hdf5',
storage_filename = None,
particle_filename = None,
- conversion_override = None):
+ units_override = None):
self.fluid_types += ("flash",)
if self._handle is not None: return
self._handle = HDF5FileHandler(filename)
- if conversion_override is None: conversion_override = {}
- self._conversion_override = conversion_override
-
+
self.particle_filename = particle_filename
- if self.particle_filename is None :
+ if self.particle_filename is None:
self._particle_handle = self._handle
- else :
+ else:
try:
self._particle_handle = HDF5FileHandler(self.particle_filename)
- except :
+ except:
raise IOError(self.particle_filename)
# These should be explicitly obtained from the file, but for now that
# will wait until a reorganization of the source tree and better
# generalization.
self.refine_by = 2
- Dataset.__init__(self, filename, dataset_type)
+ Dataset.__init__(self, filename, dataset_type, units_override=units_override)
self.storage_filename = storage_filename
self.parameters["HydroMethod"] = 'flash' # always PPM DE
@@ -311,9 +309,9 @@
zipover = zip(self._handle[hn][:,'name'],self._handle[hn][:,'value'])
for varname, val in zipover:
vn = varname.strip()
- if hn.startswith("string") :
+ if hn.startswith("string"):
pval = val.strip()
- else :
+ else:
pval = val
if vn in self.parameters and self.parameters[vn] != pval:
mylog.info("{0} {1} overwrites a simulation "
@@ -327,7 +325,7 @@
nzb = self.parameters["nzb"]
except KeyError:
nxb, nyb, nzb = [int(self._handle["/simulation parameters"]['n%sb' % ax])
- for ax in 'xyz'] # FLASH2 only!
+ for ax in 'xyz'] # FLASH2 only!
# Determine dimensionality
try:
@@ -343,18 +341,18 @@
self.geometry = self.parameters["geometry"]
# Determine base grid parameters
- if 'lrefine_min' in self.parameters.keys() : # PARAMESH
+ if 'lrefine_min' in self.parameters.keys(): # PARAMESH
nblockx = self.parameters["nblockx"]
nblocky = self.parameters["nblocky"]
nblockz = self.parameters["nblockz"]
- else : # Uniform Grid
+ else: # Uniform Grid
nblockx = self.parameters["iprocs"]
nblocky = self.parameters["jprocs"]
nblockz = self.parameters["kprocs"]
# In case the user wasn't careful
- if self.dimensionality <= 2 : nblockz = 1
- if self.dimensionality == 1 : nblocky = 1
+ if self.dimensionality <= 2: nblockz = 1
+ if self.dimensionality == 1: nblocky = 1
# Determine domain boundaries
self.domain_left_edge = np.array(
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/flash/tests/test_outputs.py
--- a/yt/frontends/flash/tests/test_outputs.py
+++ b/yt/frontends/flash/tests/test_outputs.py
@@ -47,3 +47,8 @@
@requires_file(wt)
def test_FLASHDataset():
assert isinstance(data_dir_load(wt), FLASHDataset)
+
+ at requires_file(sloshing)
+def test_units_override():
+ for test in units_override_check(sloshing):
+ yield test
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/gdf/data_structures.py
--- a/yt/frontends/gdf/data_structures.py
+++ b/yt/frontends/gdf/data_structures.py
@@ -172,10 +172,11 @@
_field_info_class = GDFFieldInfo
def __init__(self, filename, dataset_type='grid_data_format',
- storage_filename=None, geometry=None):
+ storage_filename=None, geometry=None,
+ units_override=None):
self.geometry = geometry
self.fluid_types += ("gdf",)
- Dataset.__init__(self, filename, dataset_type)
+ Dataset.__init__(self, filename, dataset_type, units_override=units_override)
self.storage_filename = storage_filename
self.filename = filename
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/halo_catalogs/halo_catalog/data_structures.py
--- a/yt/frontends/halo_catalogs/halo_catalog/data_structures.py
+++ b/yt/frontends/halo_catalogs/halo_catalog/data_structures.py
@@ -52,10 +52,11 @@
_suffix = ".h5"
def __init__(self, filename, dataset_type="halocatalog_hdf5",
- n_ref = 16, over_refine_factor = 1):
+ n_ref = 16, over_refine_factor = 1, units_override=None):
self.n_ref = n_ref
self.over_refine_factor = over_refine_factor
- super(HaloCatalogDataset, self).__init__(filename, dataset_type)
+ super(HaloCatalogDataset, self).__init__(filename, dataset_type,
+ units_override=units_override)
def _parse_parameter_file(self):
with h5py.File(self.parameter_filename, "r") as f:
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/halo_catalogs/owls_subfind/data_structures.py
--- a/yt/frontends/halo_catalogs/owls_subfind/data_structures.py
+++ b/yt/frontends/halo_catalogs/owls_subfind/data_structures.py
@@ -113,10 +113,11 @@
_suffix = ".hdf5"
def __init__(self, filename, dataset_type="subfind_hdf5",
- n_ref = 16, over_refine_factor = 1):
+ n_ref = 16, over_refine_factor = 1, units_override=None):
self.n_ref = n_ref
self.over_refine_factor = over_refine_factor
- super(OWLSSubfindDataset, self).__init__(filename, dataset_type)
+ super(OWLSSubfindDataset, self).__init__(filename, dataset_type,
+ units_override=units_override)
def _parse_parameter_file(self):
handle = h5py.File(self.parameter_filename, mode="r")
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/halo_catalogs/rockstar/data_structures.py
--- a/yt/frontends/halo_catalogs/rockstar/data_structures.py
+++ b/yt/frontends/halo_catalogs/rockstar/data_structures.py
@@ -56,10 +56,12 @@
_suffix = ".bin"
def __init__(self, filename, dataset_type="rockstar_binary",
- n_ref = 16, over_refine_factor = 1):
+ n_ref = 16, over_refine_factor = 1,
+ units_override=None):
self.n_ref = n_ref
self.over_refine_factor = over_refine_factor
- super(RockstarDataset, self).__init__(filename, dataset_type)
+ super(RockstarDataset, self).__init__(filename, dataset_type,
+ units_override=units_override)
def _parse_parameter_file(self):
with open(self.parameter_filename, "rb") as f:
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/moab/data_structures.py
--- a/yt/frontends/moab/data_structures.py
+++ b/yt/frontends/moab/data_structures.py
@@ -28,6 +28,7 @@
io_registry
from yt.utilities.definitions import \
mpc_conversion, sec_conversion
+from yt.utilities.file_handler import HDF5FileHandler
from .fields import MoabFieldInfo, PyneFieldInfo
@@ -69,12 +70,13 @@
periodicity = (False, False, False)
def __init__(self, filename, dataset_type='moab_hex8',
- storage_filename = None):
+ storage_filename = None, units_override=None):
self.fluid_types += ("moab",)
- Dataset.__init__(self, filename, dataset_type)
+ Dataset.__init__(self, filename, dataset_type,
+ units_override=units_override)
self.storage_filename = storage_filename
self.filename = filename
- self._handle = h5py.File(self.parameter_filename, "r")
+ self._handle = HDF5FileHandler(filename)
def _set_code_unit_attributes(self):
# Almost everything is regarded as dimensionless in MOAB, so these will
@@ -147,11 +149,12 @@
periodicity = (False, False, False)
def __init__(self, pyne_mesh, dataset_type='moab_hex8_pyne',
- storage_filename = None):
+ storage_filename = None, units_override=None):
self.fluid_types += ("pyne",)
filename = "pyne_mesh_" + str(id(pyne_mesh))
self.pyne_mesh = pyne_mesh
- Dataset.__init__(self, str(filename), dataset_type)
+ Dataset.__init__(self, str(filename), dataset_type,
+ units_override=units_override)
self.storage_filename = storage_filename
self.filename = filename
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/moab/tests/test_c5.py
--- a/yt/frontends/moab/tests/test_c5.py
+++ b/yt/frontends/moab/tests/test_c5.py
@@ -60,3 +60,8 @@
@requires_file(c5)
def test_MoabHex8Dataset():
assert isinstance(data_dir_load(c5), MoabHex8Dataset)
+
+ at requires_file(c5)
+def test_units_override():
+ for test in units_override_check(c5):
+ yield test
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -331,7 +331,6 @@
class RAMSESIndex(OctreeIndex):
def __init__(self, ds, dataset_type='ramses'):
- self._ds = ds # TODO: Figure out the class composition better!
self.fluid_field_list = ds._fields_in_file
self.dataset_type = dataset_type
self.dataset = weakref.proxy(ds)
@@ -370,12 +369,12 @@
# TODO: copy/pasted from DomainFile; needs refactoring!
- num = os.path.basename(self._ds.parameter_filename).split("."
+ num = os.path.basename(self.dataset.parameter_filename).split("."
)[0].split("_")[1]
testdomain = 1 # Just pick the first domain file to read
basename = "%s/%%s_%s.out%05i" % (
os.path.abspath(
- os.path.dirname(self._ds.parameter_filename)),
+ os.path.dirname(self.dataset.parameter_filename)),
num, testdomain)
hydro_fn = basename % "hydro"
# Do we have a hydro file?
@@ -462,7 +461,8 @@
gamma = 1.4 # This will get replaced on hydro_fn open
def __init__(self, filename, dataset_type='ramses',
- fields = None, storage_filename = None):
+ fields = None, storage_filename = None,
+ units_override=None):
# Here we want to initiate a traceback, if the reader is not built.
if isinstance(fields, types.StringTypes):
fields = field_aliases[fields]
@@ -472,7 +472,7 @@
'''
self.fluid_types += ("ramses",)
self._fields_in_file = fields
- Dataset.__init__(self, filename, dataset_type)
+ Dataset.__init__(self, filename, dataset_type, units_override=units_override)
self.storage_filename = storage_filename
def __repr__(self):
@@ -552,6 +552,7 @@
self.omega_matter = rheader["omega_m"]
self.hubble_constant = rheader["H0"] / 100.0 # This is H100
self.max_level = rheader['levelmax'] - self.min_level
+ f.close()
@classmethod
def _is_valid(self, *args, **kwargs):
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/ramses/tests/test_outputs.py
--- a/yt/frontends/ramses/tests/test_outputs.py
+++ b/yt/frontends/ramses/tests/test_outputs.py
@@ -49,3 +49,8 @@
@requires_file(output_00080)
def test_RAMSESDataset():
assert isinstance(data_dir_load(output_00080), RAMSESDataset)
+
+ at requires_file(output_00080)
+def test_units_override():
+ for test in units_override_check(output_00080):
+ yield test
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/sdf/data_structures.py
--- a/yt/frontends/sdf/data_structures.py
+++ b/yt/frontends/sdf/data_structures.py
@@ -77,7 +77,8 @@
midx_filename = None,
midx_header = None,
midx_level = None,
- field_map = None):
+ field_map = None,
+ units_override=None):
self.n_ref = n_ref
self.over_refine_factor = over_refine_factor
if bounding_box is not None:
@@ -102,7 +103,8 @@
if filename.startswith("http"):
prefix += 'http_'
dataset_type = prefix + 'sdf_particles'
- super(SDFDataset, self).__init__(filename, dataset_type)
+ super(SDFDataset, self).__init__(filename, dataset_type,
+ units_override=units_override)
def _parse_parameter_file(self):
if self.parameter_filename.startswith("http"):
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -96,7 +96,8 @@
bounding_box = None,
header_spec = "default",
field_spec = "default",
- ptype_spec = "default"):
+ ptype_spec = "default",
+ units_override=None):
if self._instantiated: return
self._header_spec = self._setup_binary_spec(
header_spec, gadget_header_specs)
@@ -120,6 +121,9 @@
self.domain_right_edge = bbox[:,1]
else:
self.domain_left_edge = self.domain_right_edge = None
+ if units_override is not None:
+ raise RuntimeError("units_override is not supported for GadgetDataset. "+
+ "Use unit_base instead.")
super(GadgetDataset, self).__init__(filename, dataset_type)
def _setup_binary_spec(self, spec, spec_dict):
@@ -269,9 +273,13 @@
def __init__(self, filename, dataset_type="gadget_hdf5",
unit_base = None, n_ref=64,
over_refine_factor=1,
- bounding_box = None):
+ bounding_box = None,
+ units_override=None):
self.storage_filename = None
filename = os.path.abspath(filename)
+ if units_override is not None:
+ raise RuntimeError("units_override is not supported for GadgetHDF5Dataset. "+
+ "Use unit_base instead.")
super(GadgetHDF5Dataset, self).__init__(
filename, dataset_type, unit_base=unit_base, n_ref=n_ref,
over_refine_factor=over_refine_factor,
@@ -505,7 +513,8 @@
unit_base=None,
parameter_file=None,
cosmology_parameters=None,
- n_ref=64, over_refine_factor=1):
+ n_ref=64, over_refine_factor=1,
+ units_override=None):
self.n_ref = n_ref
self.over_refine_factor = over_refine_factor
if field_dtypes is None:
@@ -534,6 +543,9 @@
parameter_file = os.path.abspath(parameter_file)
self._param_file = parameter_file
filename = os.path.abspath(filename)
+ if units_override is not None:
+ raise RuntimeError("units_override is not supported for TipsyDataset. "+
+ "Use unit_base instead.")
super(TipsyDataset, self).__init__(filename, dataset_type)
def __repr__(self):
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -292,8 +292,8 @@
_field_info_class = StreamFieldInfo
_dataset_type = 'stream'
- def __init__(self, stream_handler, storage_filename = None,
- geometry = "cartesian"):
+ def __init__(self, stream_handler, storage_filename=None,
+ geometry="cartesian"):
#if parameter_override is None: parameter_override = {}
#self._parameter_override = parameter_override
#if conversion_override is None: conversion_override = {}
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/testing.py
--- a/yt/testing.py
+++ b/yt/testing.py
@@ -26,6 +26,7 @@
assert_allclose, assert_raises
from yt.units.yt_array import uconcatenate
import yt.fields.api as field_api
+from yt.convenience import load
def assert_rel_equal(a1, a2, decimals, err_msg='', verbose=True):
# We have nan checks in here because occasionally we have fields that get
@@ -321,7 +322,30 @@
return ftrue
else:
return ffalse
-
+
+def units_override_check(fn):
+ ytcfg["yt","skip_dataset_cache"] = "True"
+ units_list = ["length","time","mass","velocity",
+ "magnetic","temperature"]
+ ds1 = load(fn)
+ units_override = {}
+ attrs1 = []
+ attrs2 = []
+ for u in units_list:
+ unit_attr = getattr(ds1, "%s_unit" % u, None)
+ if unit_attr is not None:
+ attrs1.append(unit_attr)
+ units_override["%s_unit" % u] = (unit_attr.v, str(unit_attr.units))
+ del ds1
+ ds2 = load(fn, units_override=units_override)
+ ytcfg["yt","skip_dataset_cache"] = "False"
+ assert(len(ds2.units_override) > 0)
+ for u in units_list:
+ unit_attr = getattr(ds2, "%s_unit" % u, None)
+ if unit_attr is not None:
+ attrs2.append(unit_attr)
+ yield assert_equal, attrs1, attrs2
+
# This is an export of the 40 grids in IsolatedGalaxy that are of level 4 or
# lower. It's just designed to give a sample AMR index to deal with.
_amr_grid_index = [
diff -r 96b14a15b10218f5dc7889b3c20821f1985ee048 -r 840185d54851673d51b494f973231d9926220a0d yt/utilities/tests/test_particle_generator.py
--- a/yt/utilities/tests/test_particle_generator.py
+++ b/yt/utilities/tests/test_particle_generator.py
@@ -5,7 +5,6 @@
from yt.frontends.stream.api import load_uniform_grid, refine_amr
import yt.utilities.initial_conditions as ic
import yt.utilities.flagging_methods as fm
-from IPython import embed
from yt.units.yt_array import uconcatenate
def setup() :
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