[yt-svn] commit/yt: 10 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Sep 14 20:54:54 PDT 2015


10 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/8590c171cfa2/
Changeset:   8590c171cfa2
Branch:      yt
User:        nmearl
Date:        2015-07-30 20:27:56+00:00
Summary:     Generalizing Tipsy reader to accept cosmological Gadget outputs
Affected #:  1 file

diff -r b35ac81530d482ef95fd62caec0c018207a41b47 -r 8590c171cfa252bf631362621e0becc13b0b7a94 yt/frontends/tipsy/data_structures.py
--- a/yt/frontends/tipsy/data_structures.py
+++ b/yt/frontends/tipsy/data_structures.py
@@ -167,9 +167,9 @@
         self.domain_dimensions = np.ones(3, "int32") * nz
         periodic = self.parameters.get('bPeriodic', True)
         period = self.parameters.get('dPeriod', None)
-        comoving = self.parameters.get('bComove', False)
         self.periodicity = (periodic, periodic, periodic)
-        if comoving and period is None:
+        self.comoving = self.parameters.get('bComove', False)
+        if self.comoving and period is None:
             period = 1.0
         if self.bounding_box is None:
             if periodic and period is not None:
@@ -186,7 +186,9 @@
             self.domain_left_edge = bbox[:,0]
             self.domain_right_edge = bbox[:,1]
 
-        if comoving:
+        # If the cosmology parameters dictionary got set when data is
+        # loaded, we can assume it's a cosmological data set
+        if self.comoving or self._cosmology_parameters is not None:
             cosm = self._cosmology_parameters or {}
             self.scale_factor = hvals["time"]#In comoving simulations, time stores the scale factor a
             self.cosmological_simulation = 1
@@ -224,8 +226,12 @@
             self.length_unit = self.quan(lu, 'kpc')*self.scale_factor
             self.mass_unit = self.quan(mu, 'Msun')
             density_unit = self.mass_unit/ (self.length_unit/self.scale_factor)**3
-            # Gasoline's hubble constant, dHubble0, is stored units of proper code time.
-            self.hubble_constant *= np.sqrt(G.in_units('kpc**3*Msun**-1*s**-2')*density_unit).value/(3.2407793e-18)  
+
+            # If self.comoving is set, we know this is a gasoline data set,
+            # and we do the conversion on the hubble constant.
+            if self.comoving:
+                # Gasoline's hubble constant, dHubble0, is stored units of proper code time.
+                self.hubble_constant *= np.sqrt(G.in_units('kpc**3*Msun**-1*s**-2')*density_unit).value/(3.2407793e-18)
             cosmo = Cosmology(self.hubble_constant,
                               self.omega_matter, self.omega_lambda)
             self.current_time = cosmo.hubble_time(self.current_redshift)


https://bitbucket.org/yt_analysis/yt/commits/8c9cac3876f9/
Changeset:   8c9cac3876f9
Branch:      yt
User:        nmearl
Date:        2015-07-31 14:42:41+00:00
Summary:     Fixed bug wherein unit_base was not working for Tipsy frontend
Affected #:  1 file

diff -r 8590c171cfa252bf631362621e0becc13b0b7a94 -r 8c9cac3876f977a94c3c64ef8195a64f81d06d5f yt/frontends/tipsy/data_structures.py
--- a/yt/frontends/tipsy/data_structures.py
+++ b/yt/frontends/tipsy/data_structures.py
@@ -32,6 +32,7 @@
 from yt.utilities.physical_constants import \
     G, \
     cm_per_kpc
+from yt import YTQuantity
 
 from .fields import \
     TipsyFieldInfo
@@ -230,8 +231,11 @@
             # If self.comoving is set, we know this is a gasoline data set,
             # and we do the conversion on the hubble constant.
             if self.comoving:
-                # Gasoline's hubble constant, dHubble0, is stored units of proper code time.
-                self.hubble_constant *= np.sqrt(G.in_units('kpc**3*Msun**-1*s**-2')*density_unit).value/(3.2407793e-18)
+                # Gasoline's hubble constant, dHubble0, is stored units of
+                # proper code time.
+                self.hubble_constant *= np.sqrt(G.in_units(
+                    'kpc**3*Msun**-1*s**-2') * density_unit).value / (
+                    3.2407793e-18)
             cosmo = Cosmology(self.hubble_constant,
                               self.omega_matter, self.omega_lambda)
             self.current_time = cosmo.hubble_time(self.current_redshift)
@@ -243,6 +247,32 @@
             density_unit = self.mass_unit / self.length_unit**3
         self.time_unit = 1.0 / np.sqrt(G * density_unit)
 
+        # If unit base is defined by the user, override all relevant units
+        if self._unit_base is not None:
+            if 'time' in self._unit_base.keys():
+                time = self._unit_base['time']
+
+                if not isinstance(time, YTQuantity):
+                    time = self.quan(*time)
+
+                self.time_unit = time
+
+            if 'length' in self._unit_base.keys():
+                length = self._unit_base['length']
+
+                if not isinstance(length, YTQuantity):
+                    length = self.quan(*length)
+
+                self.length_unit = length
+
+            if 'mass' in self._unit_base.keys():
+                mass = self._unit_base['mass']
+
+                if not isinstance(mass, YTQuantity):
+                    mass = self.quan(*mass)
+
+                self.mass_unit = mass
+
     @staticmethod
     def _validate_header(filename):
         '''


https://bitbucket.org/yt_analysis/yt/commits/fdf5b1060ff4/
Changeset:   fdf5b1060ff4
Branch:      yt
User:        nmearl
Date:        2015-07-31 14:44:28+00:00
Summary:     Updated documentation for Tipsy frontend
Affected #:  1 file

diff -r 8c9cac3876f977a94c3c64ef8195a64f81d06d5f -r fdf5b1060ff48f7815e6627491bcf40113d57d5a doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -1257,8 +1257,8 @@
 
 .. _specifying-cosmology-tipsy:
 
-Specifying Tipsy Cosmological Parameters
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Specifying Tipsy Cosmological Parameters and Setting Default Units
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 Cosmological parameters can be specified to Tipsy to enable computation of
 default units.  The parameters recognized are of this form:
@@ -1270,5 +1270,25 @@
                            'omega_matter': 0.272,
                            'hubble_constant': 0.702}
 
-These will be used set the units, if they are specified.
+If you wish to set the default units directly, you can do so by using the ``unit_base`` keyword in the load statement.
 
+ .. code-block:: python
+
+    import yt
+    ds = yt.load(filename, unit_base={'length', (1.0, 'Mpc')})
+
+
+Loading Cosmological Simulations
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If you are not using a parameter file (i.e. non-Gasoline users), then you must use keyword ``cosmology_parameters``
+when loading your data set to indicate to yt that it is a cosmological data set. If you do not wish to set any
+non-default cosmological parameters, you may pass an empty dictionary.
+
+ .. code-block:: python
+
+    import yt
+    ds = yt.load(filename, cosmology_parameters={})
+
+
+


https://bitbucket.org/yt_analysis/yt/commits/0c5ceb9c7ea0/
Changeset:   0c5ceb9c7ea0
Branch:      yt
User:        nmearl
Date:        2015-07-31 14:51:29+00:00
Summary:     Merging
Affected #:  2 files

diff -r fdf5b1060ff48f7815e6627491bcf40113d57d5a -r 0c5ceb9c7ea0ed164bff2ba41ef00f97820615f8 yt/units/tests/test_ytarray.py
--- a/yt/units/tests/test_ytarray.py
+++ b/yt/units/tests/test_ytarray.py
@@ -631,7 +631,7 @@
         # In-place copies do not drop units.
         assert_true(hasattr(out, 'units'))
         assert_true(not hasattr(ret, 'units'))
-    elif ufunc in (np.absolute, np.conjugate, np.floor, np.ceil,
+    elif ufunc in (np.absolute, np.fabs, np.conjugate, np.floor, np.ceil,
                    np.trunc, np.negative):
         ret = ufunc(a, out=out)
 

diff -r fdf5b1060ff48f7815e6627491bcf40113d57d5a -r 0c5ceb9c7ea0ed164bff2ba41ef00f97820615f8 yt/units/yt_array.py
--- a/yt/units/yt_array.py
+++ b/yt/units/yt_array.py
@@ -26,7 +26,7 @@
     greater, greater_equal, less, less_equal, not_equal, equal, logical_and, \
     logical_or, logical_xor, logical_not, maximum, minimum, isreal, iscomplex, \
     isfinite, isinf, isnan, signbit, copysign, nextafter, modf, frexp, \
-    floor, ceil, trunc, fmax, fmin
+    floor, ceil, trunc, fmax, fmin, fabs
 
 from yt.units.unit_object import Unit, UnitParseError
 from yt.units.unit_registry import UnitRegistry
@@ -139,7 +139,7 @@
     log10, expm1, log1p, sqrt, square, reciprocal, sin, cos, tan, arcsin,
     arccos, arctan, sinh, cosh, tanh, arcsinh, arccosh, arctanh, deg2rad,
     rad2deg, logical_not, isreal, iscomplex, isfinite, isinf, isnan,
-    signbit, floor, ceil, trunc, modf, frexp,
+    signbit, floor, ceil, trunc, modf, frexp, fabs
 )
 
 binary_operators = (
@@ -223,6 +223,7 @@
         mod: preserve_units,
         fmod: preserve_units,
         absolute: passthrough_unit,
+        fabs: passthrough_unit,
         rint: return_without_unit,
         sign: return_without_unit,
         conj: passthrough_unit,
@@ -1072,7 +1073,8 @@
                                         unit.base_value, out=out_arr)
                             unit = Unit(registry=unit.registry)
         else:
-            raise RuntimeError("Operation is not defined.")
+            raise RuntimeError("Support for the %s ufunc has not been added "
+                               "to YTArray." % str(context[0]))
         if unit is None:
             out_arr = np.array(out_arr, copy=False)
             return out_arr


https://bitbucket.org/yt_analysis/yt/commits/8d11841d8d22/
Changeset:   8d11841d8d22
Branch:      yt
User:        nmearl
Date:        2015-07-31 17:38:46+00:00
Summary:     Fixed issue wherein time_unit was not accounting for unit_base values
Affected #:  1 file

diff -r 0c5ceb9c7ea0ed164bff2ba41ef00f97820615f8 -r 8d11841d8d22dcc01a69fb4da87512748b76ccf4 yt/frontends/tipsy/data_structures.py
--- a/yt/frontends/tipsy/data_structures.py
+++ b/yt/frontends/tipsy/data_structures.py
@@ -249,14 +249,6 @@
 
         # If unit base is defined by the user, override all relevant units
         if self._unit_base is not None:
-            if 'time' in self._unit_base.keys():
-                time = self._unit_base['time']
-
-                if not isinstance(time, YTQuantity):
-                    time = self.quan(*time)
-
-                self.time_unit = time
-
             if 'length' in self._unit_base.keys():
                 length = self._unit_base['length']
 
@@ -273,6 +265,18 @@
 
                 self.mass_unit = mass
 
+            density_unit = self.mass_unit / self.length_unit**3
+            self.time_unit = 1.0 / np.sqrt(G * density_unit)
+
+            if 'time' in self._unit_base.keys():
+                time = self._unit_base['time']
+
+                if not isinstance(time, YTQuantity):
+                    time = self.quan(*time)
+
+                self.time_unit = time
+
+
     @staticmethod
     def _validate_header(filename):
         '''


https://bitbucket.org/yt_analysis/yt/commits/6ac625090a8d/
Changeset:   6ac625090a8d
Branch:      yt
User:        nmearl
Date:        2015-08-14 17:26:44+00:00
Summary:     Condensed unit override; cosmological runs now indicated explicity in parameters dictionary
Affected #:  2 files

diff -r 8d11841d8d22dcc01a69fb4da87512748b76ccf4 -r 6ac625090a8d42e18b624e6b70a4b56cad4095cf doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -1270,7 +1270,8 @@
                            'omega_matter': 0.272,
                            'hubble_constant': 0.702}
 
-If you wish to set the default units directly, you can do so by using the ``unit_base`` keyword in the load statement.
+If you wish to set the default units directly, you can do so by using the
+``unit_base`` keyword in the load statement.
 
  .. code-block:: python
 
@@ -1281,14 +1282,15 @@
 Loading Cosmological Simulations
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-If you are not using a parameter file (i.e. non-Gasoline users), then you must use keyword ``cosmology_parameters``
-when loading your data set to indicate to yt that it is a cosmological data set. If you do not wish to set any
-non-default cosmological parameters, you may pass an empty dictionary.
+If you are not using a parameter file (i.e. non-Gasoline users), then you must
+use keyword ``cosmology_parameters`` when loading your data set to indicate to
+yt that it is a cosmological data set. In addition, you must supply the
+``cosmology_parameters`` dictionary with the key ``'cosmological'`` set to ``True``.
 
  .. code-block:: python
 
     import yt
-    ds = yt.load(filename, cosmology_parameters={})
+    ds = yt.load(filename, cosmology_parameters={'cosmological': True})
 
 
 

diff -r 8d11841d8d22dcc01a69fb4da87512748b76ccf4 -r 6ac625090a8d42e18b624e6b70a4b56cad4095cf yt/frontends/tipsy/data_structures.py
--- a/yt/frontends/tipsy/data_structures.py
+++ b/yt/frontends/tipsy/data_structures.py
@@ -189,7 +189,8 @@
 
         # If the cosmology parameters dictionary got set when data is
         # loaded, we can assume it's a cosmological data set
-        if self.comoving or self._cosmology_parameters is not None:
+        if self.comoving or self._cosmology_parameters is not None and \
+                self._cosmology_parameters.get('cosmological', None) is True:
             cosm = self._cosmology_parameters or {}
             self.scale_factor = hvals["time"]#In comoving simulations, time stores the scale factor a
             self.cosmological_simulation = 1
@@ -249,32 +250,20 @@
 
         # If unit base is defined by the user, override all relevant units
         if self._unit_base is not None:
-            if 'length' in self._unit_base.keys():
-                length = self._unit_base['length']
+            length = self._unit_base.get('length', self.length_unit)
+            length = self.quan(*length) if isinstance(length, tuple) else self.quan(length)
+            self.length_unit = length
 
-                if not isinstance(length, YTQuantity):
-                    length = self.quan(*length)
-
-                self.length_unit = length
-
-            if 'mass' in self._unit_base.keys():
-                mass = self._unit_base['mass']
-
-                if not isinstance(mass, YTQuantity):
-                    mass = self.quan(*mass)
-
-                self.mass_unit = mass
+            mass = self._unit_base.get('mass', self.mass_unit)
+            mass = self.quan(*mass) if isinstance(mass, tuple) else self.quan(mass)
+            self.mass_unit = mass
 
             density_unit = self.mass_unit / self.length_unit**3
             self.time_unit = 1.0 / np.sqrt(G * density_unit)
 
-            if 'time' in self._unit_base.keys():
-                time = self._unit_base['time']
-
-                if not isinstance(time, YTQuantity):
-                    time = self.quan(*time)
-
-                self.time_unit = time
+            time = self._unit_base.get('time', self.time_unit)
+            time = self.quan(*time) if isinstance(time, tuple) else self.quan(time)
+            self.time_unit = time
 
 
     @staticmethod


https://bitbucket.org/yt_analysis/yt/commits/c165ab2c6417/
Changeset:   c165ab2c6417
Branch:      yt
User:        nmearl
Date:        2015-08-28 15:18:28+00:00
Summary:     Made the logical operation more obvious
Affected #:  1 file

diff -r 6ac625090a8d42e18b624e6b70a4b56cad4095cf -r c165ab2c641752b435f500afaa45948848aca024 yt/frontends/tipsy/data_structures.py
--- a/yt/frontends/tipsy/data_structures.py
+++ b/yt/frontends/tipsy/data_structures.py
@@ -189,8 +189,8 @@
 
         # If the cosmology parameters dictionary got set when data is
         # loaded, we can assume it's a cosmological data set
-        if self.comoving or self._cosmology_parameters is not None and \
-                self._cosmology_parameters.get('cosmological', None) is True:
+        if self.comoving or (self._cosmology_parameters is not None and
+                self._cosmology_parameters.get('cosmological', False)):
             cosm = self._cosmology_parameters or {}
             self.scale_factor = hvals["time"]#In comoving simulations, time stores the scale factor a
             self.cosmological_simulation = 1


https://bitbucket.org/yt_analysis/yt/commits/424b369ccc99/
Changeset:   424b369ccc99
Branch:      yt
User:        nmearl
Date:        2015-09-03 13:52:00+00:00
Summary:     Revert back to previous behavior in recognizing cosmological data
Affected #:  2 files

diff -r c165ab2c641752b435f500afaa45948848aca024 -r 424b369ccc99454977e755169c9df233a7f647d2 doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -1287,10 +1287,15 @@
 yt that it is a cosmological data set. In addition, you must supply the
 ``cosmology_parameters`` dictionary with the key ``'cosmological'`` set to ``True``.
 
+If you are not using a parameter file (i.e. non-Gasoline users), then you must
+use keyword ``cosmology_parameters`` when loading your data set to indicate to
+yt that it is a cosmological data set. If you do not wish to set any
+non-default cosmological parameters, you may pass an empty dictionary.
+
  .. code-block:: python
 
     import yt
-    ds = yt.load(filename, cosmology_parameters={'cosmological': True})
+    ds = yt.load(filename, cosmology_parameters={})
 
 
 

diff -r c165ab2c641752b435f500afaa45948848aca024 -r 424b369ccc99454977e755169c9df233a7f647d2 yt/frontends/tipsy/data_structures.py
--- a/yt/frontends/tipsy/data_structures.py
+++ b/yt/frontends/tipsy/data_structures.py
@@ -189,8 +189,7 @@
 
         # If the cosmology parameters dictionary got set when data is
         # loaded, we can assume it's a cosmological data set
-        if self.comoving or (self._cosmology_parameters is not None and
-                self._cosmology_parameters.get('cosmological', False)):
+        if self.comoving or self._cosmology_parameters is not None:
             cosm = self._cosmology_parameters or {}
             self.scale_factor = hvals["time"]#In comoving simulations, time stores the scale factor a
             self.cosmological_simulation = 1


https://bitbucket.org/yt_analysis/yt/commits/4012042d1eca/
Changeset:   4012042d1eca
Branch:      yt
User:        nmearl
Date:        2015-09-03 13:55:28+00:00
Summary:     Removed redundant doc statement
Affected #:  1 file

diff -r 424b369ccc99454977e755169c9df233a7f647d2 -r 4012042d1eca7d1de4b0043a3978704a304e4de3 doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -1284,11 +1284,6 @@
 
 If you are not using a parameter file (i.e. non-Gasoline users), then you must
 use keyword ``cosmology_parameters`` when loading your data set to indicate to
-yt that it is a cosmological data set. In addition, you must supply the
-``cosmology_parameters`` dictionary with the key ``'cosmological'`` set to ``True``.
-
-If you are not using a parameter file (i.e. non-Gasoline users), then you must
-use keyword ``cosmology_parameters`` when loading your data set to indicate to
 yt that it is a cosmological data set. If you do not wish to set any
 non-default cosmological parameters, you may pass an empty dictionary.
 


https://bitbucket.org/yt_analysis/yt/commits/4979406431c6/
Changeset:   4979406431c6
Branch:      yt
User:        xarthisius
Date:        2015-09-15 03:54:46+00:00
Summary:     Merged in nmearl/yt (pull request #1668)

Fixing Tipsy frontend
Affected #:  2 files

diff -r 43e11e9fc943815fd62611e5a0626a27982e24db -r 4979406431c662b038db914287ae227092199b78 doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -1257,8 +1257,8 @@
 
 .. _specifying-cosmology-tipsy:
 
-Specifying Tipsy Cosmological Parameters
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Specifying Tipsy Cosmological Parameters and Setting Default Units
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 Cosmological parameters can be specified to Tipsy to enable computation of
 default units.  The parameters recognized are of this form:
@@ -1270,5 +1270,27 @@
                            'omega_matter': 0.272,
                            'hubble_constant': 0.702}
 
-These will be used set the units, if they are specified.
+If you wish to set the default units directly, you can do so by using the
+``unit_base`` keyword in the load statement.
 
+ .. code-block:: python
+
+    import yt
+    ds = yt.load(filename, unit_base={'length', (1.0, 'Mpc')})
+
+
+Loading Cosmological Simulations
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If you are not using a parameter file (i.e. non-Gasoline users), then you must
+use keyword ``cosmology_parameters`` when loading your data set to indicate to
+yt that it is a cosmological data set. If you do not wish to set any
+non-default cosmological parameters, you may pass an empty dictionary.
+
+ .. code-block:: python
+
+    import yt
+    ds = yt.load(filename, cosmology_parameters={})
+
+
+

diff -r 43e11e9fc943815fd62611e5a0626a27982e24db -r 4979406431c662b038db914287ae227092199b78 yt/frontends/tipsy/data_structures.py
--- a/yt/frontends/tipsy/data_structures.py
+++ b/yt/frontends/tipsy/data_structures.py
@@ -32,6 +32,7 @@
 from yt.utilities.physical_constants import \
     G, \
     cm_per_kpc
+from yt import YTQuantity
 
 from .fields import \
     TipsyFieldInfo
@@ -167,9 +168,9 @@
         self.domain_dimensions = np.ones(3, "int32") * nz
         periodic = self.parameters.get('bPeriodic', True)
         period = self.parameters.get('dPeriod', None)
-        comoving = self.parameters.get('bComove', False)
         self.periodicity = (periodic, periodic, periodic)
-        if comoving and period is None:
+        self.comoving = self.parameters.get('bComove', False)
+        if self.comoving and period is None:
             period = 1.0
         if self.bounding_box is None:
             if periodic and period is not None:
@@ -186,7 +187,9 @@
             self.domain_left_edge = bbox[:,0]
             self.domain_right_edge = bbox[:,1]
 
-        if comoving:
+        # If the cosmology parameters dictionary got set when data is
+        # loaded, we can assume it's a cosmological data set
+        if self.comoving or self._cosmology_parameters is not None:
             cosm = self._cosmology_parameters or {}
             self.scale_factor = hvals["time"]#In comoving simulations, time stores the scale factor a
             self.cosmological_simulation = 1
@@ -224,8 +227,15 @@
             self.length_unit = self.quan(lu, 'kpc')*self.scale_factor
             self.mass_unit = self.quan(mu, 'Msun')
             density_unit = self.mass_unit/ (self.length_unit/self.scale_factor)**3
-            # Gasoline's hubble constant, dHubble0, is stored units of proper code time.
-            self.hubble_constant *= np.sqrt(G.in_units('kpc**3*Msun**-1*s**-2')*density_unit).value/(3.2407793e-18)  
+
+            # If self.comoving is set, we know this is a gasoline data set,
+            # and we do the conversion on the hubble constant.
+            if self.comoving:
+                # Gasoline's hubble constant, dHubble0, is stored units of
+                # proper code time.
+                self.hubble_constant *= np.sqrt(G.in_units(
+                    'kpc**3*Msun**-1*s**-2') * density_unit).value / (
+                    3.2407793e-18)
             cosmo = Cosmology(self.hubble_constant,
                               self.omega_matter, self.omega_lambda)
             self.current_time = cosmo.hubble_time(self.current_redshift)
@@ -237,6 +247,24 @@
             density_unit = self.mass_unit / self.length_unit**3
         self.time_unit = 1.0 / np.sqrt(G * density_unit)
 
+        # If unit base is defined by the user, override all relevant units
+        if self._unit_base is not None:
+            length = self._unit_base.get('length', self.length_unit)
+            length = self.quan(*length) if isinstance(length, tuple) else self.quan(length)
+            self.length_unit = length
+
+            mass = self._unit_base.get('mass', self.mass_unit)
+            mass = self.quan(*mass) if isinstance(mass, tuple) else self.quan(mass)
+            self.mass_unit = mass
+
+            density_unit = self.mass_unit / self.length_unit**3
+            self.time_unit = 1.0 / np.sqrt(G * density_unit)
+
+            time = self._unit_base.get('time', self.time_unit)
+            time = self.quan(*time) if isinstance(time, tuple) else self.quan(time)
+            self.time_unit = time
+
+
     @staticmethod
     def _validate_header(filename):
         '''

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