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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Nov 13 13:00:25 PST 2015


13 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/99a1ea93f348/
Changeset:   99a1ea93f348
Branch:      stable
User:        ngoldbaum
Date:        2015-10-05 01:56:03+00:00
Summary:     Backporting PR #1782 https://bitbucket.org/yt_analysis/yt/pull-requests/1782
Affected #:  2 files

diff -r 831567c08d6b1caa6055ddc59d096518edcb30f7 -r 99a1ea93f348a2afbf25a8215d23f6c171ad0647 yt/units/tests/test_ytarray.py
--- a/yt/units/tests/test_ytarray.py
+++ b/yt/units/tests/test_ytarray.py
@@ -467,6 +467,13 @@
     yield assert_equal, str(em3.in_mks().units), 'kg/(m*s**2)'
     yield assert_equal, str(em3.in_cgs().units), 'g/(cm*s**2)'
 
+    dimless = YTQuantity(1.0, "")
+    yield assert_equal, dimless.in_cgs(), dimless
+    yield assert_equal, dimless.in_cgs(), 1.0
+    yield assert_equal, dimless.in_mks(), dimless
+    yield assert_equal, dimless.in_mks(), 1.0
+    yield assert_equal, str(dimless.in_cgs().units), "dimensionless"
+
 def test_temperature_conversions():
     """
     Test conversions between various supported temperatue scales.

diff -r 831567c08d6b1caa6055ddc59d096518edcb30f7 -r 99a1ea93f348a2afbf25a8215d23f6c171ad0647 yt/units/unit_object.py
--- a/yt/units/unit_object.py
+++ b/yt/units/unit_object.py
@@ -373,9 +373,15 @@
         # Use sympy to factor the dimensions into base CGS unit symbols.
         units = []
         my_dims = self.dimensions.expand()
-        for dim in base_units:
+        if my_dims is dimensionless:
+            return ""
+        for factor in my_dims.as_ordered_factors():
+            dim = list(factor.free_symbols)[0]
             unit_string = base_units[dim]
-            power_string = "**(%s)" % my_dims.as_coeff_exponent(dim)[1]
+            if factor.is_Pow:
+                power_string = "**(%s)" % factor.as_base_exp()[1]
+            else:
+                power_string = ""
             units.append("".join([unit_string, power_string]))
         return " * ".join(units)
 


https://bitbucket.org/yt_analysis/yt/commits/e1632740d87f/
Changeset:   e1632740d87f
Branch:      stable
User:        jzuhone
Date:        2015-10-12 23:22:27+00:00
Summary:     Set these to zero to avoid problems with newest versions of SIMX. Should not change behavior at all for old versions.
Affected #:  1 file

diff -r 99a1ea93f348a2afbf25a8215d23f6c171ad0647 -r e1632740d87f037d952cda949712db56472ade4a yt/analysis_modules/photon_simulator/photon_simulator.py
--- a/yt/analysis_modules/photon_simulator/photon_simulator.py
+++ b/yt/analysis_modules/photon_simulator/photon_simulator.py
@@ -1092,8 +1092,8 @@
         tbhdu.writeto(phfile, clobber=clobber)
 
         col1 = pyfits.Column(name='SRC_ID', format='J', array=np.array([1]).astype("int32"))
-        col2 = pyfits.Column(name='RA', format='D', array=np.array([float(self.parameters["sky_center"][0])]))
-        col3 = pyfits.Column(name='DEC', format='D', array=np.array([float(self.parameters["sky_center"][1])]))
+        col2 = pyfits.Column(name='RA', format='D', array=np.array([0.0]))
+        col3 = pyfits.Column(name='DEC', format='D', array=np.array([0.0]))
         col4 = pyfits.Column(name='E_MIN', format='D', array=np.array([float(emin)]))
         col5 = pyfits.Column(name='E_MAX', format='D', array=np.array([float(emax)]))
         col6 = pyfits.Column(name='FLUX', format='D', array=np.array([flux.value]))


https://bitbucket.org/yt_analysis/yt/commits/cd373e05374e/
Changeset:   cd373e05374e
Branch:      stable
User:        ngoldbaum
Date:        2015-10-18 14:18:17+00:00
Summary:     Backporting PR #1821 https://bitbucket.org/yt_analysis/yt/pull-requests/1821
Affected #:  2 files

diff -r e1632740d87f037d952cda949712db56472ade4a -r cd373e05374ebc73c0c20af9c6048ea94510e14f yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -713,6 +713,8 @@
     plot_title = None
     _plot_valid = False
     _plot_type = 'Phase'
+    _xlim = (None, None)
+    _ylim = (None, None)
 
     def __init__(self, data_source, x_field, y_field, z_fields,
                  weight_field="cell_mass", x_bins=128, y_bins=128,
@@ -817,6 +819,8 @@
             draw_colorbar = True
             draw_axes = True
             zlim = (None, None)
+            xlim = self._xlim
+            ylim = self._ylim
             if f in self.plots:
                 draw_colorbar = self.plots[f]._draw_colorbar
                 draw_axes = self.plots[f]._draw_axes
@@ -872,6 +876,9 @@
             self.plots[f].axes.yaxis.set_label_text(y_title)
             self.plots[f].cax.yaxis.set_label_text(z_title)
 
+            self.plots[f].axes.set_xlim(xlim)
+            self.plots[f].axes.set_ylim(ylim)
+
             if f in self._plot_text:
                 self.plots[f].axes.text(self._text_xpos[f], self._text_ypos[f],
                                         self._plot_text[f],
@@ -1177,6 +1184,7 @@
             **additional_kwargs)
         for field in zunits:
             self.profile.set_field_unit(field, zunits[field])
+        self._xlim = (xmin, xmax)
         return self
 
     @invalidate_plot
@@ -1241,6 +1249,7 @@
             **additional_kwargs)
         for field in zunits:
             self.profile.set_field_unit(field, zunits[field])
+        self._ylim = (ymin, ymax)
         return self
 
 

diff -r e1632740d87f037d952cda949712db56472ade4a -r cd373e05374ebc73c0c20af9c6048ea94510e14f yt/visualization/tests/test_profile_plots.py
--- a/yt/visualization/tests/test_profile_plots.py
+++ b/yt/visualization/tests/test_profile_plots.py
@@ -20,7 +20,9 @@
 from yt.data_objects.profiles import create_profile
 from yt.extern.parameterized import\
     parameterized, param
-from yt.testing import fake_random_ds
+from yt.testing import \
+    fake_random_ds, \
+    assert_array_almost_equal
 from yt.visualization.profile_plotter import \
     ProfilePlot, PhasePlot
 from yt.visualization.tests.test_plotwindow import \
@@ -61,6 +63,15 @@
                 p2d = create_profile(reg, [x_field, y_field], z_field,
                                      n_bins=[16, 16])
                 phases.append(PhasePlot.from_profile(p2d))
+        pp = PhasePlot(test_ds.all_data(), 'density', 'temperature', 'cell_mass')
+        pp.set_xlim(0.3, 0.8)
+        pp.set_ylim(0.4, 0.6)
+        pp._setup_plots()
+        xlim = pp.plots['cell_mass'].axes.get_xlim()
+        ylim = pp.plots['cell_mass'].axes.get_ylim()
+        assert_array_almost_equal(xlim, (0.3, 0.8))
+        assert_array_almost_equal(ylim, (0.4, 0.6))
+        phases.append(pp)
         cls.profiles = profiles
         cls.phases = phases
         cls.ds = test_ds


https://bitbucket.org/yt_analysis/yt/commits/23987b26fe29/
Changeset:   23987b26fe29
Branch:      stable
User:        jzuhone
Date:        2015-10-28 04:06:47+00:00
Summary:     Fixing width for off-axis SZ projections. Adding units when writing the SZ images to HDF5. Adding no_ghost and north_vector to the off_axis method.
Affected #:  1 file

diff -r cd373e05374ebc73c0c20af9c6048ea94510e14f -r 23987b26fe2916f34e1be5881cab10cb8e383250 yt/analysis_modules/sunyaev_zeldovich/projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/projection.py
@@ -106,7 +106,7 @@
         self.display_names["Tau"] = r"$\mathrm{\tau}$"
 
         for f, field in zip(self.freqs, self.freq_fields):
-            self.display_names[field] = r"$\mathrm{\Delta{I}_{%d\ GHz}}$" % (int(f))
+            self.display_names[field] = r"$\mathrm{\Delta{I}_{%d\ GHz}}$" % int(f)
 
     def on_axis(self, axis, center="c", width=(1, "unitary"), nx=800, source=None):
         r""" Make an on-axis projection of the SZ signal.
@@ -125,9 +125,26 @@
             as a tuple containing a coordinate and string unit name or by passing
             in a YTArray. If a list or unitless array is supplied, code units are
             assumed.
-        width : float, tuple, or YTQuantity.
-            The width of the projection. A float will assume the width is in code units.
-            A (value, unit) tuple or YTQuantity allows for the units of the width to be specified.
+        width : tuple or a float.
+            Width can have four different formats to support windows with variable
+            x and y widths.  They are:
+
+            ==================================     =======================
+            format                                 example
+            ==================================     =======================
+            (float, string)                        (10,'kpc')
+            ((float, string), (float, string))     ((10,'kpc'),(15,'kpc'))
+            float                                  0.2
+            (float, float)                         (0.2, 0.3)
+            ==================================     =======================
+
+            For example, (10, 'kpc') requests a plot window that is 10 kiloparsecs
+            wide in the x and y directions, ((10,'kpc'),(15,'kpc')) requests a
+            window that is 10 kiloparsecs wide along the x axis and 15
+            kiloparsecs wide along the y axis.  In the other two examples, code
+            units are assumed, for example (0.2, 0.3) requests a plot that has an
+            x width of 0.2 and a y width of 0.3 in code units.  If units are
+            provided the resulting plot axis labels will use the supplied units.
         nx : integer, optional
             The dimensions on a side of the projection image.
         source : yt.data_objects.data_containers.YTSelectionContainer, optional
@@ -141,7 +158,7 @@
         ctr, dctr = self.ds.coordinates.sanitize_center(center, axis)
         width = self.ds.coordinates.sanitize_width(axis, width, None)
 
-        L = np.zeros((3))
+        L = np.zeros(3)
         L[axis] = 1.0
 
         beta_par = generate_beta_par(L)
@@ -174,7 +191,8 @@
 
         self.ds.field_info.pop(("gas","beta_par"))
 
-    def off_axis(self, L, center="c", width=(1, "unitary"), nx=800, source=None):
+    def off_axis(self, L, center="c", width=(1.0, "unitary"), depth=(1.0,"unitary"),
+                 nx=800, nz=800, north_vector=None, no_ghost=False, source=None):
         r""" Make an off-axis projection of the SZ signal.
 
         Parameters
@@ -191,11 +209,46 @@
             as a tuple containing a coordinate and string unit name or by passing
             in a YTArray. If a list or unitless array is supplied, code units are
             assumed.
-        width : float, tuple, or YTQuantity.
-            The width of the projection. A float will assume the width is in code units.
-            A (value, unit) tuple or YTQuantity allows for the units of the width to be specified.
+        width : tuple or a float.
+            Width can have four different formats to support windows with variable
+            x and y widths.  They are:
+
+            ==================================     =======================
+            format                                 example
+            ==================================     =======================
+            (float, string)                        (10,'kpc')
+            ((float, string), (float, string))     ((10,'kpc'),(15,'kpc'))
+            float                                  0.2
+            (float, float)                         (0.2, 0.3)
+            ==================================     =======================
+
+            For example, (10, 'kpc') requests a plot window that is 10 kiloparsecs
+            wide in the x and y directions, ((10,'kpc'),(15,'kpc')) requests a
+            window that is 10 kiloparsecs wide along the x axis and 15
+            kiloparsecs wide along the y axis.  In the other two examples, code
+            units are assumed, for example (0.2, 0.3) requests a plot that has an
+            x width of 0.2 and a y width of 0.3 in code units.  If units are
+            provided the resulting plot axis labels will use the supplied units.
+        depth : A tuple or a float
+            A tuple containing the depth to project through and the string
+            key of the unit: (width, 'unit').  If set to a float, code units
+            are assumed
         nx : integer, optional
             The dimensions on a side of the projection image.
+        nz : integer, optional
+            The number of elements along the integration path length.
+        north_vector : a sequence of floats
+            A vector defining the 'up' direction in the plot.  This
+            option sets the orientation of the slicing plane.  If not
+            set, an arbitrary grid-aligned north-vector is chosen.
+        no_ghost: bool, optional
+            Optimization option for off-axis cases. If True, homogenized bricks will
+            extrapolate out from grid instead of interpolating from
+            ghost zones that have to first be calculated.  This can
+            lead to large speed improvements, but at a loss of
+            accuracy/smoothness in resulting image.  The effects are
+            less notable when the transfer function is smooth and
+            broad. Default: True
         source : yt.data_objects.data_containers.YTSelectionContainer, optional
             If specified, this will be the data source used for selecting regions to project.
             Currently unsupported in yt 2.x.
@@ -205,13 +258,10 @@
         >>> L = np.array([0.5, 1.0, 0.75])
         >>> szprj.off_axis(L, center="c", width=(2.0, "Mpc"))
         """
-        if iterable(width):
-            w = self.ds.quan(width[0], width[1]).in_units("code_length").value
-        elif isinstance(width, YTQuantity):
-            w = width.in_units("code_length").value
-        else:
-            w = width
+        wd = self.ds.coordinates.sanitize_width(L, width, depth)
+        w = tuple(el.in_units('code_length').v for el in wd)
         ctr, dctr = self.ds.coordinates.sanitize_center(center, L)
+        res = (nx, nx, nz)
 
         if source is not None:
             mylog.error("Source argument is not currently supported for off-axis S-Z projections.")
@@ -221,16 +271,23 @@
         self.ds.add_field(("gas","beta_par"), function=beta_par, units="g/cm**3")
         setup_sunyaev_zeldovich_fields(self.ds)
 
-        dens    = off_axis_projection(self.ds, ctr, L, w, nx, "density")
-        Te      = off_axis_projection(self.ds, ctr, L, w, nx, "t_sz")/dens
-        bpar    = off_axis_projection(self.ds, ctr, L, w, nx, "beta_par")/dens
-        omega1  = off_axis_projection(self.ds, ctr, L, w, nx, "t_squared")/dens
-        omega1  = omega1/(Te*Te) - 1.
+        dens = off_axis_projection(self.ds, ctr, L, w, res, "density",
+                                   north_vector=north_vector, no_ghost=no_ghost)
+        Te = off_axis_projection(self.ds, ctr, L, w, res, "t_sz",
+                                 north_vector=north_vector, no_ghost=no_ghost)/dens
+        bpar = off_axis_projection(self.ds, ctr, L, w, res, "beta_par",
+                                   north_vector=north_vector, no_ghost=no_ghost)/dens
+        omega1 = off_axis_projection(self.ds, ctr, L, w, res, "t_squared",
+                                     north_vector=north_vector, no_ghost=no_ghost)/dens
+        omega1 = omega1/(Te*Te) - 1.
         if self.high_order:
-            bperp2  = off_axis_projection(self.ds, ctr, L, w, nx, "beta_perp_squared")/dens
-            sigma1  = off_axis_projection(self.ds, ctr, L, w, nx, "t_beta_par")/dens
-            sigma1  = sigma1/Te - bpar
-            kappa1  = off_axis_projection(self.ds, ctr, L, w, nx, "beta_par_squared")/dens
+            bperp2 = off_axis_projection(self.ds, ctr, L, w, res, "beta_perp_squared", 
+                                         north_vector=north_vector, no_ghost=no_ghost)/dens
+            sigma1 = off_axis_projection(self.ds, ctr, L, w, res, "t_beta_par", 
+                                         north_vector=north_vector, no_ghost=no_ghost)/dens
+            sigma1 = sigma1/Te - bpar
+            kappa1 = off_axis_projection(self.ds, ctr, L, w, res, "beta_par_squared", 
+                                         north_vector=north_vector, no_ghost=no_ghost)/dens
             kappa1 -= bpar
         else:
             bperp2 = np.zeros((nx,nx))
@@ -238,9 +295,9 @@
             kappa1 = np.zeros((nx,nx))
         tau = sigma_thompson*dens*self.mueinv/mh
 
-        self.bounds = np.array([-0.5*w, 0.5*w, -0.5*w, 0.5*w])
-        self.dx = w/nx
-        self.dy = w/nx
+        self.bounds = (-0.5*wd[0], 0.5*wd[0], -0.5*wd[1], 0.5*wd[1])
+        self.dx = wd[0]/nx
+        self.dy = wd[1]/nx
         self.nx = nx
 
         self._compute_intensity(np.array(tau), np.array(Te), np.array(bpar),
@@ -332,7 +389,7 @@
         if sky_scale is not None and sky_center is not None:
             fib.create_sky_wcs(sky_center, sky_scale)
         fib.writeto(filename, clobber=clobber)
-        
+
     @parallel_root_only
     def write_png(self, filename_prefix, cmap_name="algae",
                   axes_units="kpc", log_fields=None):
@@ -362,13 +419,13 @@
             crossover = False
             if vmin < 0 and vmax < 0:
                 data *= -1
-                negative = True                                        
+                negative = True
             if field in log_fields:
                 log_field = log_fields[field]
             else:
                 log_field = True
             if log_field:
-                formatter = matplotlib.ticker.LogFormatterMathtext()        
+                formatter = matplotlib.ticker.LogFormatterMathtext()
                 norm = matplotlib.colors.LogNorm()
                 if vmin < 0 and vmax > 0:
                     crossover = True
@@ -385,13 +442,13 @@
                 cbar_label += r'$\ \ ('+units+r')$'
             fig = plt.figure(figsize=(10.0,8.0))
             ax = fig.add_subplot(111)
-            cax = ax.imshow(data.ndarray_view(), norm=norm, extent=extent, cmap=cmap_name, origin="lower")
+            cax = ax.imshow(data.d, norm=norm, extent=extent, cmap=cmap_name, origin="lower")
             for label in ax.get_xticklabels():
                 label.set_fontproperties(ticks_font)
             for label in ax.get_yticklabels():
-                label.set_fontproperties(ticks_font)                      
-            ax.set_xlabel(r"$\mathrm{x\ (%s)}$" % (axes_units), fontsize=16)
-            ax.set_ylabel(r"$\mathrm{y\ (%s)}$" % (axes_units), fontsize=16)
+                label.set_fontproperties(ticks_font)
+            ax.set_xlabel(r"$\mathrm{x\ (%s)}$" % axes_units, fontsize=16)
+            ax.set_ylabel(r"$\mathrm{y\ (%s)}$" % axes_units, fontsize=16)
             cbar = fig.colorbar(cax, format=formatter)
             cbar.ax.set_ylabel(cbar_label, fontsize=16)
             if negative:
@@ -404,10 +461,10 @@
                                             np.ceil(np.log10(vmax))+1))
                 cbar.set_ticks(yticks)
             for label in cbar.ax.get_yticklabels():
-                label.set_fontproperties(ticks_font)                 
+                label.set_fontproperties(ticks_font)
             fig.tight_layout()
             plt.savefig(filename)
-            
+
     @parallel_root_only
     def write_hdf5(self, filename):
         r"""Export the set of S-Z fields to a set of HDF5 datasets.
@@ -421,11 +478,8 @@
         --------
         >>> szprj.write_hdf5("SZsloshing.h5")
         """
-        import h5py
-        f = h5py.File(filename, "w")
         for field, data in self.items():
-            f.create_dataset(field,data=data.ndarray_view())
-        f.close()
+            data.write_hdf5(filename, dataset_name=field)
 
     def keys(self):
         return self.data.keys()


https://bitbucket.org/yt_analysis/yt/commits/5fa1fa81adae/
Changeset:   5fa1fa81adae
Branch:      stable
User:        ngoldbaum
Date:        2015-10-31 13:30:20+00:00
Summary:     Stop referring to the requirements file in the installation docs
Affected #:  1 file

diff -r 23987b26fe2916f34e1be5881cab10cb8e383250 -r 5fa1fa81adaee8cd6e5196f1169021d4f63a9327 doc/source/installing.rst
--- a/doc/source/installing.rst
+++ b/doc/source/installing.rst
@@ -290,14 +290,14 @@
 
 .. code-block:: bash
 
-  $ pip install -r requirements.txt
+  $ pip install numpy matplotlib cython cython h5py nose sympy
 
 If you're using IPython notebooks, you can install its dependencies
 with ``pip`` as well:
 
 .. code-block:: bash
 
-  $ pip install -r optional-requirements.txt
+  $ pip install ipython[notebook]
 
 From here, you can use ``pip`` (which comes with ``Python``) to install the latest
 stable version of yt:


https://bitbucket.org/yt_analysis/yt/commits/a19b16be876f/
Changeset:   a19b16be876f
Branch:      stable
User:        ngoldbaum
Date:        2015-10-31 15:01:37+00:00
Summary:     Provide nice error message when triggering nose issue 701
Affected #:  1 file

diff -r 5fa1fa81adaee8cd6e5196f1169021d4f63a9327 -r a19b16be876f2927328863cb0747ce03824bbb6f yt/testing.py
--- a/yt/testing.py
+++ b/yt/testing.py
@@ -745,6 +745,20 @@
     initial_dir = os.getcwd()
     yt_file = os.path.abspath(yt.__file__)
     yt_dir = os.path.dirname(yt_file)
+    if os.path.samefile(os.path.dirname(yt_dir), initial_dir):
+        # Provide a nice error message to work around nose bug
+        # see https://github.com/nose-devs/nose/issues/701
+        raise RuntimeError(
+            """
+    The yt.run_nose function does not work correctly when invoked in
+    the same directory as the installed yt package. Try starting
+    a python session in a different directory before invoking yt.run_nose
+    again. Alternatively, you can also run the "nosetests" executable in
+    the current directory like so:
+
+        $ nosetests
+            """
+            )
     os.chdir(yt_dir)
     try:
         nose.run(argv=nose_argv)


https://bitbucket.org/yt_analysis/yt/commits/a6334372ba3a/
Changeset:   a6334372ba3a
Branch:      stable
User:        ngoldbaum
Date:        2015-11-02 22:15:58+00:00
Summary:     Fix issue with parsing gadget data in python3
Affected #:  1 file

diff -r a19b16be876f2927328863cb0747ce03824bbb6f -r a6334372ba3aa34c7c721ff8889db3ab1c8e1765 yt/frontends/gadget/data_structures.py
--- a/yt/frontends/gadget/data_structures.py
+++ b/yt/frontends/gadget/data_structures.py
@@ -132,7 +132,7 @@
         # The entries in this header are capitalized and named to match Table 4
         # in the GADGET-2 user guide.
 
-        f = open(self.parameter_filename)
+        f = open(self.parameter_filename, 'rb')
         hvals = read_record(f, self._header_spec)
         for i in hvals:
             if len(hvals[i]) == 1:


https://bitbucket.org/yt_analysis/yt/commits/d61c8332dca1/
Changeset:   d61c8332dca1
Branch:      stable
User:        ngoldbaum
Date:        2015-11-02 22:31:33+00:00
Summary:     Fix issues with loading tipsy files in python3
Affected #:  1 file

diff -r a6334372ba3aa34c7c721ff8889db3ab1c8e1765 -r d61c8332dca1333c70ad85459d8e569c5bea695b yt/frontends/tipsy/io.py
--- a/yt/frontends/tipsy/io.py
+++ b/yt/frontends/tipsy/io.py
@@ -241,7 +241,7 @@
 
     def _initialize_index(self, data_file, regions):
         ds = data_file.ds
-        morton = np.empty(sum(data_file.total_particles.values()),
+        morton = np.empty(sum(list(data_file.total_particles.values())),
                           dtype="uint64")
         ind = 0
         DLE, DRE = ds.domain_left_edge, ds.domain_right_edge
@@ -318,7 +318,7 @@
             self._field_list.append((ptype, field))
 
         # Find out which auxiliaries we have and what is their format
-        tot_parts = np.sum(data_file.total_particles.values())
+        tot_parts = np.sum(list(data_file.total_particles.values()))
         endian = data_file.ds.endian
         self._aux_pdtypes = {}
         self._aux_fields = [f.rsplit('.')[-1]
@@ -332,8 +332,9 @@
             filesize = os.stat(filename).st_size
             if np.fromfile(filename, np.dtype(endian + 'i4'),
                            count=1) != tot_parts:
-                with open(filename) as f:
-                    if int(f.readline()) != tot_parts:
+                with open(filename, 'rb') as f:
+                    header_nparts = f.readline()
+                    if int(header_nparts) != tot_parts:
                         raise RuntimeError
                 self._aux_pdtypes[afield] = "ascii"
             elif (filesize - 4) / 8 == tot_parts:


https://bitbucket.org/yt_analysis/yt/commits/93faf93c724b/
Changeset:   93faf93c724b
Branch:      stable
User:        ngoldbaum
Date:        2015-11-09 05:16:19+00:00
Summary:     Backporting PR #1845 https://bitbucket.org/yt_analysis/yt/pull-requests/1845
Affected #:  1 file

diff -r d61c8332dca1333c70ad85459d8e569c5bea695b -r 93faf93c724b34d404daa6bb42e9aef2823d5cbe yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -42,6 +42,16 @@
 cdef np.float64_t grid_eps = np.finfo(np.float64).eps
 grid_eps = 0.0
 
+cdef np.int64_t fnv_hash(unsigned char[:] octets):
+    # https://bitbucket.org/yt_analysis/yt/issues/1052/field-access-tests-fail-under-python3
+    # FNV hash cf. http://www.isthe.com/chongo/tech/comp/fnv/index.html
+    cdef np.int64_t hash_val = 2166136261
+    cdef char octet
+    for octet in octets:
+        hash_val = hash_val ^ octet
+        hash_val = hash_val * 16777619
+    return hash_val
+
 # These routines are separated into a couple different categories:
 #
 #   * Routines for identifying intersections of an object with a bounding box
@@ -605,13 +615,15 @@
         return mask.view("bool")
 
     def __hash__(self):
-        # https://bitbucket.org/yt_analysis/yt/issues/1052/field-access-tests-fail-under-python3
-        # http://www.eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx
-        cdef np.int64_t hash_val = 2166136261
+        # convert data to be hashed to a byte array, which FNV algorithm expects
+        hash_data = bytearray()
         for v in self._hash_vals() + self._base_hash():
-            # FNV hash cf. http://www.isthe.com/chongo/tech/comp/fnv/index.html
-            hash_val = (hash_val * 16777619) ^ hash(v)
-        return hash_val
+            if isinstance(v, tuple):
+                hash_data.extend(v[0].encode('ascii'))
+                hash_data.extend(repr(v[1]).encode('ascii'))
+            else:
+                hash_data.extend(repr(v).encode('ascii'))
+        return fnv_hash(hash_data)
 
     def _hash_vals(self):
         raise NotImplementedError


https://bitbucket.org/yt_analysis/yt/commits/f405ab0e52ac/
Changeset:   f405ab0e52ac
Branch:      stable
User:        brittonsmith
Date:        2015-11-04 21:12:53+00:00
Summary:     Backporting PR #1846 https://bitbucket.org/yt_analysis/yt/pull-requests/1846
Affected #:  1 file

diff -r 93faf93c724b34d404daa6bb42e9aef2823d5cbe -r f405ab0e52ac6da44138df263ce4e9e216e8a27d yt/geometry/geometry_handler.py
--- a/yt/geometry/geometry_handler.py
+++ b/yt/geometry/geometry_handler.py
@@ -396,7 +396,7 @@
         ind = 0
         for obj in self._fast_index or self.objs:
             gdt, gt = obj.select_tcoords(self.dobj)
-            if gt.shape == 0: continue
+            if gt.size == 0: continue
             ct[ind:ind+gt.size] = gt
             cdt[ind:ind+gdt.size] = gdt
             ind += gt.size


https://bitbucket.org/yt_analysis/yt/commits/7a83c81ea5a6/
Changeset:   7a83c81ea5a6
Branch:      stable
User:        brittonsmith
Date:        2015-11-05 16:05:25+00:00
Summary:     Backporting PR #1847 https://bitbucket.org/yt_analysis/yt/pull-requests/1847
Affected #:  2 files

diff -r f405ab0e52ac6da44138df263ce4e9e216e8a27d -r 7a83c81ea5a6af7a9f81b7618f62f7d64c498644 yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -7,7 +7,11 @@
 from yt.frontends.stream.fields import \
     StreamFieldInfo
 from yt.units.yt_array import \
-     YTArray, YTQuantity
+    array_like_field, \
+    YTArray, YTQuantity
+from yt.utilities.exceptions import \
+    YTFieldUnitError, \
+    YTFieldUnitParseError
 
 def setup():
     global base_ds
@@ -257,9 +261,17 @@
     assert_equal(str(ad['dimensionless_explicit'].units), 'dimensionless')
     assert_raises(YTFieldUnitError, get_data, ds, 'dimensionful')
 
+def test_array_like_field():
+    ds = fake_random_ds(4, particles=64)
+    ad = ds.all_data()
+    u1 = ad["particle_mass"].units
+    u2 = array_like_field(ad, 1., ("all", "particle_mass")).units
+    assert u1 == u2
+
 if __name__ == "__main__":
     setup()
     for t in test_all_fields():
         t()
     test_add_deposited_particle_field()
     test_add_field_unit_semantics()
+    test_array_like_field()

diff -r f405ab0e52ac6da44138df263ce4e9e216e8a27d -r 7a83c81ea5a6af7a9f81b7618f62f7d64c498644 yt/units/yt_array.py
--- a/yt/units/yt_array.py
+++ b/yt/units/yt_array.py
@@ -1281,9 +1281,9 @@
 def array_like_field(data, x, field):
     field = data._determine_fields(field)[0]
     if isinstance(field, tuple):
-        units = data.ds._get_field_info(field[0],field[1]).units
+        units = data.ds._get_field_info(field[0],field[1]).output_units
     else:
-        units = data.ds._get_field_info(field).units
+        units = data.ds._get_field_info(field).output_units
     if isinstance(x, YTArray):
         arr = copy.deepcopy(x)
         arr.convert_to_units(units)


https://bitbucket.org/yt_analysis/yt/commits/c86357b67c06/
Changeset:   c86357b67c06
Branch:      stable
User:        ngoldbaum
Date:        2015-11-09 21:48:42+00:00
Summary:     Backporting PR #1851 https://bitbucket.org/yt_analysis/yt/pull-requests/1851
Affected #:  1 file

diff -r 7a83c81ea5a6af7a9f81b7618f62f7d64c498644 -r c86357b67c06d5cafbd620ecf63dbc980ba212b9 yt/utilities/parallel_tools/parallel_analysis_interface.py
--- a/yt/utilities/parallel_tools/parallel_analysis_interface.py
+++ b/yt/utilities/parallel_tools/parallel_analysis_interface.py
@@ -471,7 +471,7 @@
     ...     sto.result = sp.quantities["AngularMomentumVector"]()
     ...
     >>> for sphere_id, L in sorted(storage.items()):
-    ...     print c[sphere_id], L
+    ...     print centers[sphere_id], L
     ...
 
     """
@@ -504,8 +504,7 @@
     # If our objects object is slice-aware, like time series data objects are,
     # this will prevent intermediate objects from being created.
     oiter = itertools.islice(enumerate(objects), my_new_id, None, njobs)
-    for obj_id, obj in oiter:
-        result_id = obj_id * njobs + my_new_id
+    for result_id, obj in oiter:
         if storage is not None:
             rstore = ResultsStorage()
             rstore.result_id = result_id


https://bitbucket.org/yt_analysis/yt/commits/164af1cd5540/
Changeset:   164af1cd5540
Branch:      stable
User:        MatthewTurk
Date:        2015-11-10 00:48:08+00:00
Summary:     Changing author name and email
Affected #:  1 file

diff -r c86357b67c06d5cafbd620ecf63dbc980ba212b9 -r 164af1cd5540d5d0841fcb9b1e3824d4db1cfa14 setup.py
--- a/setup.py
+++ b/setup.py
@@ -211,8 +211,8 @@
                 'answer-testing = yt.utilities.answer_testing.framework:AnswerTesting'
             ]
         },
-        author="Matthew J. Turk",
-        author_email="matthewturk at gmail.com",
+        author="The yt project",
+        author_email="yt-dev at lists.spacepope.org",
         url="http://yt-project.org/",
         license="BSD",
         configuration=configuration,

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