[yt-svn] commit/yt: 11 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Feb 9 09:19:19 PST 2017
11 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/a02ae7d8b3c8/
Changeset: a02ae7d8b3c8
Branch: stable
User: ngoldbaum
Date: 2016-12-19 19:59:20+00:00
Summary: Backporting PR #2467 https://bitbucket.org/yt_analysis/yt/pull-requests/2467
Affected #: 6 files
diff -r f96a417cff480be88f51d9051d9443e82ab5515b -r a02ae7d8b3c8ac0c696ecd67f49099767de7d721 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -13,15 +13,18 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import matplotlib
+import numpy as np
+
+from distutils.version import LooseVersion
from io import BytesIO
-import matplotlib
+
from yt.funcs import \
get_image_suffix, \
mylog, \
iterable, \
get_brewer_cmap, \
matplotlib_style_context
-import numpy as np
class CallbackWrapper(object):
@@ -73,7 +76,9 @@
self.canvas = FigureCanvasAgg(self.figure)
for which in ['major', 'minor']:
for axis in 'xy':
- self.axes.tick_params(which=which, axis=axis, direction='in')
+ self.axes.tick_params(
+ which=which, axis=axis, direction='in', top=True, right=True
+ )
def save(self, name, mpl_kwargs=None, canvas=None):
"""Choose backend and save image to disk"""
@@ -161,8 +166,14 @@
aspect=aspect, vmax=self.zmax, cmap=cmap,
interpolation='nearest')
if (cbnorm == 'symlog'):
- formatter = matplotlib.ticker.LogFormatterMathtext()
- self.cb = self.figure.colorbar(self.image, self.cax, format=formatter)
+ if LooseVersion(matplotlib.__version__) < LooseVersion("2.0.0"):
+ formatter_kwargs = {}
+ else:
+ formatter_kwargs = dict(linthresh=cblinthresh)
+ formatter = matplotlib.ticker.LogFormatterMathtext(
+ **formatter_kwargs)
+ self.cb = self.figure.colorbar(
+ self.image, self.cax, format=formatter)
yticks = list(-10**np.arange(np.floor(np.log10(-data.min())),\
np.rint(np.log10(cblinthresh))-1, -1)) + [0] + \
list(10**np.arange(np.rint(np.log10(cblinthresh)),\
diff -r f96a417cff480be88f51d9051d9443e82ab5515b -r a02ae7d8b3c8ac0c696ecd67f49099767de7d721 yt/visualization/fixed_resolution_filters.py
--- a/yt/visualization/fixed_resolution_filters.py
+++ b/yt/visualization/fixed_resolution_filters.py
@@ -64,7 +64,7 @@
def apply(self, buff):
from yt.utilities.on_demand_imports import _scipy
- hnbeam = self.nbeam / 2
+ hnbeam = self.nbeam // 2
sigma = self.sigma
l = np.linspace(-hnbeam, hnbeam, num=self.nbeam + 1)
diff -r f96a417cff480be88f51d9051d9443e82ab5515b -r a02ae7d8b3c8ac0c696ecd67f49099767de7d721 yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -21,6 +21,7 @@
import matplotlib
import os
+from distutils.version import LooseVersion
from collections import defaultdict
from functools import wraps
diff -r f96a417cff480be88f51d9051d9443e82ab5515b -r a02ae7d8b3c8ac0c696ecd67f49099767de7d721 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -391,7 +391,6 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
nx = plot.image._A.shape[0] / self.factor
ny = plot.image._A.shape[1] / self.factor
# periodicity
@@ -431,7 +430,6 @@
plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale, scale_units=self.scale_units)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class ContourCallback(PlotCallback):
"""
@@ -479,8 +477,6 @@
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
-
numPoints_x = plot.image._A.shape[0]
numPoints_y = plot.image._A.shape[1]
@@ -554,7 +550,6 @@
cset = plot._axes.contour(xi,yi,zi,self.ncont, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
if self.label:
plot._axes.clabel(cset, **self.text_args)
@@ -671,7 +666,6 @@
grid_collection = matplotlib.collections.PolyCollection(
verts, facecolors="none", edgecolors=edgecolors,
linewidth=self.linewidth)
- plot._axes.hold(True)
plot._axes.add_collection(grid_collection)
if self.draw_ids:
@@ -684,7 +678,6 @@
left_edge_x[i] + (2 * (xx1 - xx0) / xpix),
left_edge_y[i] + (2 * (yy1 - yy0) / ypix),
"%d" % block_ids[i], clip_on=True)
- plot._axes.hold(False)
class StreamlineCallback(PlotCallback):
"""
@@ -715,7 +708,6 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
nx = plot.image._A.shape[0] / self.factor
ny = plot.image._A.shape[1] / self.factor
pixX = pixelize_cartesian(plot.data['px'], plot.data['py'],
@@ -743,7 +735,6 @@
plot._axes.streamplot(**streamplot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class LinePlotCallback(PlotCallback):
"""
@@ -821,12 +812,10 @@
coord_system=self.coord_system)
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
plot._axes.plot([p1[0], p2[0]], [p1[1], p2[1]], transform=self.transform,
**self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class ImageLineCallback(LinePlotCallback):
"""
@@ -876,7 +865,6 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
nx = plot.image._A.shape[0] / self.factor
ny = plot.image._A.shape[1] / self.factor
indices = np.argsort(plot.data['dx'])[::-1]
@@ -908,7 +896,6 @@
plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale, scale_units=self.scale_units)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class ClumpContourCallback(PlotCallback):
"""
@@ -931,8 +918,6 @@
extent = [xx0,xx1,yy0,yy1]
- plot._axes.hold(True)
-
ax = plot.data.axis
px_index = plot.data.ds.coordinates.x_axis[ax]
py_index = plot.data.ds.coordinates.y_axis[ax]
@@ -959,7 +944,6 @@
buff = np.maximum(temp, buff)
self.rv = plot._axes.contour(buff, np.unique(buff),
extent=extent, **self.plot_args)
- plot._axes.hold(False)
class ArrowCallback(PlotCallback):
"""
@@ -1098,7 +1082,6 @@
if dx == dy == 0:
warnings.warn("The arrow has zero length. Not annotating.")
return
- plot._axes.hold(True)
plot._axes.arrow(x-dx, y-dy, dx, dy, width=self.width,
head_width=self.head_width,
head_length=self.head_length,
@@ -1106,7 +1089,6 @@
length_includes_head=True, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class MarkerAnnotateCallback(PlotCallback):
"""
@@ -1177,12 +1159,10 @@
coord_system=self.coord_system)
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
plot._axes.scatter(x, y, marker = self.marker,
transform=self.transform, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class SphereCallback(PlotCallback):
"""
@@ -1275,7 +1255,6 @@
**self.circle_args)
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
plot._axes.add_patch(cir)
if self.text is not None:
@@ -1285,7 +1264,6 @@
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class TextLabelCallback(PlotCallback):
@@ -1378,13 +1356,11 @@
# consistent with other text labels in this figure
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
label = plot._axes.text(x, y, self.text, transform=self.transform,
bbox=self.inset_box_args, **kwargs)
self._set_font_properties(plot, [label], **kwargs)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class PointAnnotateCallback(TextLabelCallback):
"""
@@ -1481,7 +1457,6 @@
field_x = "particle_position_%s" % axis_names[xax]
field_y = "particle_position_%s" % axis_names[yax]
field_z = "particle_position_%s" % axis_names[data.axis]
- plot._axes.hold(True)
# Set up scales for pixel size and original data
pixel_scale = self.pixel_scale(plot)[0]
@@ -1519,7 +1494,6 @@
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
if self.annotate_field:
annotate_dat = halo_data[self.annotate_field]
@@ -1598,7 +1572,6 @@
if self.minimum_mass is not None:
gg &= (reg[pt, "particle_mass"] >= self.minimum_mass)
if gg.sum() == 0: return
- plot._axes.hold(True)
px, py = self.convert_to_plot(plot,
[np.array(particle_x[gg][::self.stride]),
np.array(particle_y[gg][::self.stride])])
@@ -1606,7 +1579,6 @@
s=self.p_size, c=self.color,alpha=self.alpha)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
def _enforce_periodic(self,
particle_x,
@@ -1762,7 +1734,6 @@
self.vertices = triangle_vertices
def __call__(self, plot):
- plot._axes.hold(True)
ax = plot.data.axis
xax = plot.data.ds.coordinates.x_axis[ax]
yax = plot.data.ds.coordinates.y_axis[ax]
@@ -1784,7 +1755,6 @@
# create line collection and add it to the plot
lc = matplotlib.collections.LineCollection(l_cy, **self.plot_args)
plot._axes.add_collection(lc)
- plot._axes.hold(False)
class TimestampCallback(PlotCallback):
"""
@@ -2411,7 +2381,6 @@
bounds = [x0,x1,y0,y1]
extent = [xx0,xx1,yy0,yy1]
- plot._axes.hold(True)
nx = plot.image._A.shape[0]
ny = plot.image._A.shape[1]
pixX = plot.data.ds.coordinates.pixelize(plot.data.axis,
@@ -2451,7 +2420,6 @@
/ (self.lim[1] - self.lim[0])
lic_data_rgba[...,3] = lic_data_clip_rescale * self.alpha
plot._axes.imshow(lic_data_rgba, extent=extent, cmap=self.cmap)
- plot._axes.hold(False)
return plot
@@ -2500,7 +2468,6 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
nx = plot.image._A.shape[0]
ny = plot.image._A.shape[1]
aspect = float((y1 - y0) / (x1 - x0))
@@ -2539,4 +2506,3 @@
alpha=self.alpha)
plot._axes.set_xlim(xx0, xx1)
plot._axes.set_ylim(yy0, yy1)
- plot._axes.hold(False)
diff -r f96a417cff480be88f51d9051d9443e82ab5515b -r a02ae7d8b3c8ac0c696ecd67f49099767de7d721 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -13,12 +13,16 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
import itertools
+import matplotlib
import numpy as np
import os
-import tempfile
import shutil
+import tempfile
import unittest
+
+from distutils.version import LooseVersion
from nose.tools import assert_true
+
from yt.extern.parameterized import parameterized, param
from yt.testing import \
fake_random_ds, assert_equal, assert_rel_equal, assert_array_equal, \
diff -r f96a417cff480be88f51d9051d9443e82ab5515b -r a02ae7d8b3c8ac0c696ecd67f49099767de7d721 yt/visualization/volume_rendering/transfer_function_helper.py
--- a/yt/visualization/volume_rendering/transfer_function_helper.py
+++ b/yt/visualization/volume_rendering/transfer_function_helper.py
@@ -14,12 +14,16 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import matplotlib
+import numpy as np
+
+from distutils.version import LooseVersion
+
from yt.funcs import mylog
from yt.data_objects.profiles import create_profile
from yt.visualization.volume_rendering.transfer_functions import \
ColorTransferFunction
from yt.extern.six import BytesIO
-import numpy as np
class TransferFunctionHelper(object):
@@ -138,7 +142,11 @@
transfer function to produce a natural contrast ratio.
"""
- self.tf.add_layers(10, colormap='spectral')
+ if LooseVersion(matplotlib.__version__) < LooseVersion('2.0.0'):
+ colormap_name = 'spectral'
+ else:
+ colormap_name = 'nipy_spectral'
+ self.tf.add_layers(10, colormap=colormap_name)
factor = self.tf.funcs[-1].y.size / self.tf.funcs[-1].y.sum()
self.tf.funcs[-1].y *= 2*factor
https://bitbucket.org/yt_analysis/yt/commits/747047921c41/
Changeset: 747047921c41
Branch: stable
User: ngoldbaum
Date: 2016-12-12 04:49:38+00:00
Summary: Update description of the yt package in setup.py
Affected #: 1 file
diff -r a02ae7d8b3c8ac0c696ecd67f49099767de7d721 -r 747047921c415a9600ad329b623bb2c39b208a6d setup.py
--- a/setup.py
+++ b/setup.py
@@ -322,9 +322,7 @@
setup(
name="yt",
version=VERSION,
- description="An analysis and visualization toolkit for Astrophysical "
- + "simulations, focusing on Adaptive Mesh Refinement data "
- "from Enzo, Orion, FLASH, and others.",
+ description="An analysis and visualization toolkit for volumetric data",
classifiers=["Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Science/Research",
https://bitbucket.org/yt_analysis/yt/commits/25cb58ee2806/
Changeset: 25cb58ee2806
Branch: stable
User: ngoldbaum
Date: 2016-12-20 01:28:46+00:00
Summary: Explicitly use integer division in absorption spectrum and ramses IO
Affected #: 2 files
diff -r 747047921c415a9600ad329b623bb2c39b208a6d -r 25cb58ee280631c8df6ab4a5aa82089feafc3e99 yt/analysis_modules/absorption_spectrum/absorption_spectrum.py
--- a/yt/analysis_modules/absorption_spectrum/absorption_spectrum.py
+++ b/yt/analysis_modules/absorption_spectrum/absorption_spectrum.py
@@ -495,8 +495,8 @@
window_width_in_bins = 2
while True:
- left_index = (center_index[i] - window_width_in_bins/2)
- right_index = (center_index[i] + window_width_in_bins/2)
+ left_index = (center_index[i] - window_width_in_bins//2)
+ right_index = (center_index[i] + window_width_in_bins//2)
n_vbins = (right_index - left_index) * n_vbins_per_bin[i]
# the array of virtual bins in lambda space
diff -r 747047921c415a9600ad329b623bb2c39b208a6d -r 25cb58ee280631c8df6ab4a5aa82089feafc3e99 yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -121,7 +121,7 @@
if var.size == n1*n2:
tvals[tname] = var.reshape((n1, n2), order='F')
else:
- var = var.reshape((n1, n2, var.size / (n1*n2)), order='F')
+ var = var.reshape((n1, n2, var.size // (n1*n2)), order='F')
for i in range(var.shape[-1]):
tvals[_cool_species[i]] = var[:,:,i]
https://bitbucket.org/yt_analysis/yt/commits/388922e3c7c9/
Changeset: 388922e3c7c9
Branch: stable
User: cphyc
Date: 2017-01-19 13:42:39+00:00
Summary: Backporting PR #2491 https://bitbucket.org/yt_analysis/yt/pull-requests/2491
Affected #: 2 files
diff -r 25cb58ee280631c8df6ab4a5aa82089feafc3e99 -r 388922e3c7c90ed76b9ec6b7467d506e7116c4b0 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -630,7 +630,7 @@
# This is likely not true, but it's not clear how to determine the boundary conditions
self.periodicity = (True, True, True)
# These conditions seem to always be true for non-cosmological datasets
- if rheader["time"] > 0 and rheader["H0"] == 1 and rheader["aexp"] == 1:
+ if rheader["time"] >= 0 and rheader["H0"] == 1 and rheader["aexp"] == 1:
self.cosmological_simulation = 0
self.current_redshift = 0
self.hubble_constant = 0
diff -r 25cb58ee280631c8df6ab4a5aa82089feafc3e99 -r 388922e3c7c90ed76b9ec6b7467d506e7116c4b0 yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -106,9 +106,10 @@
d = {'lognH': np.log10(_X*data["density"]/mh).ravel(),
'logT' : np.log10(data["temperature"]).ravel()}
rv = 10**interp_object(d).reshape(shape)
- return rv
+ # Return array in unit 'per volume' consistently with line below
+ return rv.in_units('code_length**-3')
self.add_field(name = name, function=_func,
- units = "code_length**-3")
+ units = "code_length**-3")
avals = {}
tvals = {}
with open(filename, "rb") as f:
https://bitbucket.org/yt_analysis/yt/commits/00097404cb8f/
Changeset: 00097404cb8f
Branch: stable
User: ngoldbaum
Date: 2017-01-31 17:26:59+00:00
Summary: Backporting PR #2492 https://bitbucket.org/yt_analysis/yt/pull-requests/2492
Affected #: 1 file
diff -r 388922e3c7c90ed76b9ec6b7467d506e7116c4b0 -r 00097404cb8f340db2edf3a1a1c53ba1e81ea606 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -152,11 +152,11 @@
# We need a special case for when we are only given one coordinate.
if ccoord.shape == (2,):
- return ((ccoord[0]-x0)/(x1-x0)*(xx1-xx0) + xx0,
- (ccoord[1]-y0)/(y1-y0)*(yy1-yy0) + yy0)
+ return (np.mod((ccoord[0]-x0)/(x1-x0), 1.0)*(xx1-xx0) + xx0,
+ np.mod((ccoord[1]-y0)/(y1-y0), 1.0)*(yy1-yy0) + yy0)
else:
- return ((ccoord[0][:]-x0)/(x1-x0)*(xx1-xx0) + xx0,
- (ccoord[1][:]-y0)/(y1-y0)*(yy1-yy0) + yy0)
+ return (np.mod((ccoord[0][:]-x0)/(x1-x0), 1.0)*(xx1-xx0) + xx0,
+ np.mod((ccoord[1][:]-y0)/(y1-y0), 1.0)*(yy1-yy0) + yy0)
def sanitize_coord_system(self, plot, coord, coord_system):
"""
@@ -1460,22 +1460,21 @@
# Set up scales for pixel size and original data
pixel_scale = self.pixel_scale(plot)[0]
- data_scale = data.ds.length_unit
- units = data_scale.units
+ units = plot.xlim[0].units
# Convert halo positions to code units of the plotted data
# and then to units of the plotted window
- px = halo_data[field_x][:].in_units(units) / data_scale
- py = halo_data[field_y][:].in_units(units) / data_scale
+ px = halo_data[field_x][:].in_units(units)
+ py = halo_data[field_y][:].in_units(units)
+
px, py = self.convert_to_plot(plot,[px,py])
# Convert halo radii to a radius in pixels
- radius = halo_data['virial_radius'][:].in_units(units)
- radius = np.array(radius*pixel_scale*self.factor/data_scale)
+ radius = halo_data[self.radius_field][:].in_units(units)
+ radius = np.array(radius*pixel_scale*self.factor)
if self.width:
- pz = halo_data[field_z][:].in_units(units)/data_scale
- pz = data.ds.arr(pz, 'code_length')
+ pz = halo_data[field_z][:].in_units('code_length')
c = data.center[data.axis]
# I should catch an error here if width isn't in this form
https://bitbucket.org/yt_analysis/yt/commits/5e576819fc8f/
Changeset: 5e576819fc8f
Branch: stable
User: ngoldbaum
Date: 2017-01-22 16:23:36+00:00
Summary: Ensure fields are contiguous arrays before being passed to process_octree.
Closes #1312
Affected #: 1 file
diff -r 00097404cb8f340db2edf3a1a1c53ba1e81ea606 -r 5e576819fc8fbd76d92498a461c6a65a85011dd2 yt/data_objects/octree_subset.py
--- a/yt/data_objects/octree_subset.py
+++ b/yt/data_objects/octree_subset.py
@@ -189,7 +189,7 @@
dtype="float64")
# We should not need the following if we know in advance all our fields
# need no casting.
- fields = [np.asarray(f, dtype="float64") for f in fields]
+ fields = [np.ascontiguousarray(f, dtype="float64") for f in fields]
op.process_octree(self.oct_handler, self.domain_ind, pos, fields,
self.domain_id, self._domain_offset)
vals = op.finalize()
https://bitbucket.org/yt_analysis/yt/commits/80189b12327d/
Changeset: 80189b12327d
Branch: stable
User: ngoldbaum
Date: 2017-01-25 17:32:45+00:00
Summary: Mutate MutableAttribute instances via attribute setting rather than indexing
This fixes an issue reported by Jonathan Slavin on the mailing list.
Since PR 2251 (https://bitbucket.org/yt_analysis/yt/pull-requests/2251), dataset
attributes that contain ndarray data are not managed using the
`MutableAttribute` descriptor. This ensures that it's impossible for a user to
accidentally overwrite simulation metadata, which can happen unintentionally if
(say) someone creates a reference to the attribute and then mutates
*that*. Unfortunately this also makes it more difficult to mutate these
attributes when we *want* to, like when we are setting them in the various
frontends. Unfortunately this design leads to silent brokenness when we *do* try
to mutate a MutableAttribute via indexing in a frontend - since we are only
mutating a copy and not the original data stored in the MutableAttribute.
I think I've found all of the places in frontends where we try to mutate a
MutableAttribute via indexing rather than attribute setting.
If someone has ideas about how to do this in a way that's less surprising to
frontend authors, I'd very much appreciate some advice.
Affected #: 4 files
diff -r 5e576819fc8fbd76d92498a461c6a65a85011dd2 -r 80189b12327d28682a7e028516fac28bfaedc9da yt/frontends/boxlib/data_structures.py
--- a/yt/frontends/boxlib/data_structures.py
+++ b/yt/frontends/boxlib/data_structures.py
@@ -635,7 +635,9 @@
self.domain_right_edge = \
np.concatenate([self.domain_right_edge, [1.0]])
if self.geometry == "cylindrical":
- self.domain_right_edge[2] = 2.0 * np.pi
+ dre = self.domain_right_edge
+ dre[2] = 2.0 * np.pi
+ self.domain_right_edge = dre
tmp = self.domain_dimensions.tolist()
tmp.append(1)
self.domain_dimensions = np.array(tmp)
diff -r 5e576819fc8fbd76d92498a461c6a65a85011dd2 -r 80189b12327d28682a7e028516fac28bfaedc9da yt/frontends/fits/data_structures.py
--- a/yt/frontends/fits/data_structures.py
+++ b/yt/frontends/fits/data_structures.py
@@ -489,12 +489,15 @@
self.domain_dimensions = np.append(self.domain_dimensions,
[int(1)])
- self.domain_left_edge = np.array([0.5]*3)
- self.domain_right_edge = np.array([float(dim)+0.5 for dim in self.domain_dimensions])
+ domain_left_edge = np.array([0.5]*3)
+ domain_right_edge = np.array([float(dim)+0.5 for dim in self.domain_dimensions])
if self.dimensionality == 2:
- self.domain_left_edge[-1] = 0.5
- self.domain_right_edge[-1] = 1.5
+ domain_left_edge[-1] = 0.5
+ domain_right_edge[-1] = 1.5
+
+ self.domain_left_edge = domain_left_edge
+ self.domain_right_edge = domain_right_edge
# Get the simulation time
try:
@@ -611,8 +614,10 @@
self.spectral_factor /= self.domain_dimensions[self.spec_axis]
mylog.info("Setting the spectral factor to %f" % (self.spectral_factor))
Dz = self.domain_right_edge[self.spec_axis]-self.domain_left_edge[self.spec_axis]
- self.domain_right_edge[self.spec_axis] = self.domain_left_edge[self.spec_axis] + \
- self.spectral_factor*Dz
+ dre = self.domain_right_edge
+ dre[self.spec_axis] = (self.domain_left_edge[self.spec_axis] +
+ self.spectral_factor*Dz)
+ self.domain_right_edge = dre
self._dz /= self.spectral_factor
self._p0 = (self._p0-0.5)*self.spectral_factor + 0.5
diff -r 5e576819fc8fbd76d92498a461c6a65a85011dd2 -r 80189b12327d28682a7e028516fac28bfaedc9da yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -377,28 +377,32 @@
if self.dimensionality == 1: nblocky = 1
# Determine domain boundaries
- self.domain_left_edge = np.array(
+ dle = np.array(
[self.parameters["%smin" % ax] for ax in 'xyz']).astype("float64")
- self.domain_right_edge = np.array(
+ dre = np.array(
[self.parameters["%smax" % ax] for ax in 'xyz']).astype("float64")
if self.dimensionality < 3:
for d in [dimensionality]+list(range(3-dimensionality)):
- if self.domain_left_edge[d] == self.domain_right_edge[d]:
- mylog.warning('Identical domain left edge and right edges '
- 'along dummy dimension (%i), attempting to read anyway' % d)
- self.domain_right_edge[d] = self.domain_left_edge[d]+1.0
+ if dle[d] == dre[d]:
+ mylog.warning(
+ 'Identical domain left edge and right edges '
+ 'along dummy dimension (%i), attempting to read anyway'
+ % d)
+ dre[d] = dle[d]+1.0
if self.dimensionality < 3 and self.geometry == "cylindrical":
mylog.warning("Extending theta dimension to 2PI + left edge.")
- self.domain_right_edge[2] = self.domain_left_edge[2] + 2*np.pi
+ dre[2] = dle[2] + 2*np.pi
elif self.dimensionality < 3 and self.geometry == "polar":
mylog.warning("Extending theta dimension to 2PI + left edge.")
- self.domain_right_edge[1] = self.domain_left_edge[1] + 2*np.pi
+ dre[1] = dle[1] + 2*np.pi
elif self.dimensionality < 3 and self.geometry == "spherical":
mylog.warning("Extending phi dimension to 2PI + left edge.")
- self.domain_right_edge[2] = self.domain_left_edge[2] + 2*np.pi
+ dre[2] = dle[2] + 2*np.pi
if self.dimensionality == 1 and self.geometry == "spherical":
mylog.warning("Extending theta dimension to PI + left edge.")
- self.domain_right_edge[1] = self.domain_left_edge[1] + np.pi
+ dre[1] = dle[1] + np.pi
+ self.domain_left_edge = dle
+ self.domain_right_edge = dre
self.domain_dimensions = \
np.array([nblockx*nxb,nblocky*nyb,nblockz*nzb])
diff -r 5e576819fc8fbd76d92498a461c6a65a85011dd2 -r 80189b12327d28682a7e028516fac28bfaedc9da yt/frontends/ytdata/data_structures.py
--- a/yt/frontends/ytdata/data_structures.py
+++ b/yt/frontends/ytdata/data_structures.py
@@ -668,18 +668,19 @@
self.base_domain_right_edge = self.domain_right_edge
self.base_domain_dimensions = self.domain_dimensions
- self.domain_dimensions = np.ones(3, dtype="int")
- self.domain_dimensions[:self.dimensionality] = \
+ domain_dimensions = np.ones(3, dtype="int")
+ domain_dimensions[:self.dimensionality] = \
self.profile_dimensions
- self.domain_left_edge = np.zeros(3)
- self.domain_right_edge = np.ones(3)
+ self.domain_dimensions = domain_dimensions
+ domain_left_edge = np.zeros(3)
+ domain_right_edge = np.ones(3)
for i, ax in enumerate("xyz"[:self.dimensionality]):
range_name = "%s_range" % ax
my_range = self.parameters[range_name]
if getattr(self, "%s_log" % ax, False):
my_range = np.log10(my_range)
- self.domain_left_edge[i] = my_range[0]
- self.domain_right_edge[i] = my_range[1]
+ domain_left_edge[i] = my_range[0]
+ domain_right_edge[i] = my_range[1]
setattr(self, range_name,
self.arr(self.parameters[range_name],
self.parameters[range_name+"_units"]))
@@ -692,6 +693,8 @@
self.parameters[bin_field] = \
tuple(self.parameters[bin_field].astype(str))
setattr(self, bin_field, self.parameters[bin_field])
+ self.domain_left_edge = domain_left_edge
+ self.domain_right_edge = domain_right_edge
def _setup_gas_alias(self):
"Alias the grid type to gas with a field alias."
https://bitbucket.org/yt_analysis/yt/commits/6f0ceecc13d0/
Changeset: 6f0ceecc13d0
Branch: stable
User: ngoldbaum
Date: 2017-01-27 21:57:11+00:00
Summary: Backporting PR #2508 https://bitbucket.org/yt_analysis/yt/pull-requests/2508
Affected #: 3 files
diff -r 80189b12327d28682a7e028516fac28bfaedc9da -r 6f0ceecc13d0bd8dd174356ff92b8a37a492c656 yt/data_objects/selection_data_containers.py
--- a/yt/data_objects/selection_data_containers.py
+++ b/yt/data_objects/selection_data_containers.py
@@ -609,11 +609,13 @@
if not isinstance(left_edge, YTArray):
self.left_edge = self.ds.arr(left_edge, 'code_length')
else:
- self.left_edge = left_edge
+ # need to assign this dataset's unit registry to the YTArray
+ self.left_edge = self.ds.arr(left_edge.copy())
if not isinstance(right_edge, YTArray):
self.right_edge = self.ds.arr(right_edge, 'code_length')
else:
- self.right_edge = right_edge
+ # need to assign this dataset's unit registry to the YTArray
+ self.right_edge = self.ds.arr(right_edge.copy())
class YTDataCollection(YTSelectionContainer3D):
"""
diff -r 80189b12327d28682a7e028516fac28bfaedc9da -r 6f0ceecc13d0bd8dd174356ff92b8a37a492c656 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -785,9 +785,9 @@
# list or other non-array iterable before calculating
# the center
if not isinstance(left_edge, np.ndarray):
- left_edge = np.array(left_edge)
+ left_edge = np.array(left_edge, dtype='float64')
if not isinstance(right_edge, np.ndarray):
- right_edge = np.array(right_edge)
+ right_edge = np.array(right_edge, dtype='float64')
c = (left_edge + right_edge)/2.0
return self.region(c, left_edge, right_edge, **kwargs)
diff -r 80189b12327d28682a7e028516fac28bfaedc9da -r 6f0ceecc13d0bd8dd174356ff92b8a37a492c656 yt/data_objects/tests/test_regions.py
--- /dev/null
+++ b/yt/data_objects/tests/test_regions.py
@@ -0,0 +1,17 @@
+from yt.testing import \
+ assert_array_equal, \
+ fake_random_ds
+from yt.units import cm
+
+def test_box_creation():
+
+ # test that creating a region with left and right edge
+ # with units works
+ ds = fake_random_ds(32, length_unit=2)
+ reg = ds.box([0, 0, 0]*cm, [2, 2, 2]*cm)
+ dens_units = reg['density']
+
+ reg = ds.box([0, 0, 0], [1, 1, 1])
+ dens_no_units = reg['density']
+
+ assert_array_equal(dens_units, dens_no_units)
https://bitbucket.org/yt_analysis/yt/commits/023597ffa3ea/
Changeset: 023597ffa3ea
Branch: stable
User: xarthisius
Date: 2016-11-23 00:12:56+00:00
Summary: Register '__hg_version__.py' as an output of build command. Fixes #1296
Affected #: 1 file
diff -r 6f0ceecc13d0bd8dd174356ff92b8a37a492c656 -r 023597ffa3ea5ac3be6135cbb9a0408cff7f19f7 setup.py
--- a/setup.py
+++ b/setup.py
@@ -295,6 +295,15 @@
fobj.write("hg_version = '%s'\n" % changeset)
_build_py.run(self)
+ def get_outputs(self):
+ # http://bitbucket.org/yt_analysis/yt/issues/1296
+ outputs = _build_py.get_outputs(self)
+ outputs.append(
+ os.path.join(self.build_lib, 'yt', '__hg_version__.py')
+ )
+ return outputs
+
+
class build_ext(_build_ext):
# subclass setuptools extension builder to avoid importing cython and numpy
# at top level in setup.py. See http://stackoverflow.com/a/21621689/1382869
https://bitbucket.org/yt_analysis/yt/commits/fcb5ff3c3f59/
Changeset: fcb5ff3c3f59
Branch: stable
User: ngoldbaum
Date: 2017-02-03 19:39:56+00:00
Summary: remove unused import
Affected #: 1 file
diff -r 023597ffa3ea5ac3be6135cbb9a0408cff7f19f7 -r fcb5ff3c3f59d20352934a00153cb01f670f782d yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -21,7 +21,6 @@
import matplotlib
import os
-from distutils.version import LooseVersion
from collections import defaultdict
from functools import wraps
https://bitbucket.org/yt_analysis/yt/commits/a093285f437c/
Changeset: a093285f437c
Branch: stable
User: ngoldbaum
Date: 2017-02-07 17:00:42+00:00
Summary: Use contiguous arrays for deposit fields. Fixes #1319
Affected #: 1 file
diff -r fcb5ff3c3f59d20352934a00153cb01f670f782d -r a093285f437c5fb40ebcf6f0b766fc7614f73c7d yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -1148,16 +1148,15 @@
Create a grid field for particle quantities using given method.
"""
pos = data[ptype, "particle_position"]
+ fields = [data[ptype, deposit_field]]
if method == 'weighted_mean':
- d = data.ds.arr(data.deposit(pos, [data[ptype, deposit_field],
- data[ptype, weight_field]],
- method=method, kernel_name=kernel_name),
- input_units=units)
+ fields.append(data[ptype, weight_field])
+ fields = [np.ascontiguousarray(f) for f in fields]
+ d = data.deposit(pos, fields, method=method,
+ kernel_name=kernel_name)
+ d = data.ds.arr(d, input_units=units)
+ if method == 'weighted_mean':
d[np.isnan(d)] = 0.0
- else:
- d = data.ds.arr(data.deposit(pos, [data[ptype, deposit_field]],
- method=method, kernel_name=kernel_name),
- input_units=units)
return d
self.add_field(
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