Skip to content

Commit

Permalink
Merge pull request #2429 from cphyc/python3-prints
Browse files Browse the repository at this point in the history
Change py2-style print stmts to py3
  • Loading branch information
munkm authored Jan 28, 2020
2 parents 8dcc2fa + dbcf9c0 commit 816301c
Show file tree
Hide file tree
Showing 44 changed files with 199 additions and 199 deletions.
2 changes: 1 addition & 1 deletion doc/helper_scripts/parse_cb_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def write_docstring(f, name, cls):
sig = sig.replace("**kwargs", "**field_parameters")
clsproxy = "yt.visualization.plot_modifications.%s" % (cls.__name__)
#docstring = "\n".join([" %s" % line for line in docstring.split("\n")])
#print docstring
#print(docstring)
f.write(template % dict(clsname = clsname, sig = sig, clsproxy=clsproxy,
docstring = "\n".join(tw.wrap(docstring))))
#docstring = docstring))
Expand Down
10 changes: 5 additions & 5 deletions yt/data_objects/construction_data_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ class YTQuadTreeProj(YTProj):
>>> ds = load("RedshiftOutput0005")
>>> prj = ds.proj("density", 0)
>>> print proj["density"]
>>> print(proj["density"])
"""
_type_name = "quad_proj"
def __init__(self, field, axis, weight_field=None, center=None, ds=None,
Expand Down Expand Up @@ -1273,8 +1273,8 @@ class YTSurface(YTSelectionContainer3D):
>>> from yt.units import kpc
>>> sp = ds.sphere("max", (10, "kpc")
>>> surf = ds.surface(sp, "density", 5e-27)
>>> print surf["temperature"]
>>> print surf.vertices
>>> print(surf["temperature"])
>>> print(surf.vertices)
>>> bounds = [(sp.center[i] - 5.0*kpc,
... sp.center[i] + 5.0*kpc) for i in range(3)]
>>> surf.export_ply("my_galaxy.ply", bounds = bounds)
Expand Down Expand Up @@ -1908,8 +1908,8 @@ def export_ply(self, filename, bounds = None, color_field = None,
>>> from yt.units import kpc
>>> sp = ds.sphere("max", (10, "kpc")
>>> surf = ds.surface(sp, "density", 5e-27)
>>> print surf["temperature"]
>>> print surf.vertices
>>> print(surf["temperature"])
>>> print(surf.vertices)
>>> bounds = [(sp.center[i] - 5.0*kpc,
... sp.center[i] + 5.0*kpc) for i in range(3)]
>>> surf.export_ply("my_galaxy.ply", bounds = bounds)
Expand Down
6 changes: 3 additions & 3 deletions yt/data_objects/data_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,9 +1121,9 @@ def clone(self):
>>> sp = ds.sphere("c", 0.1)
>>> sp_clone = sp.clone()
>>> sp["density"]
>>> print sp.field_data.keys()
>>> print(sp.field_data.keys())
[("gas", "density")]
>>> print sp_clone.field_data.keys()
>>> print(sp_clone.field_data.keys())
[]
"""
args = self.__reduce__()
Expand Down Expand Up @@ -1842,7 +1842,7 @@ def cut_region(self, field_cuts, field_parameters=None):
>>> ds = yt.load("RedshiftOutput0005")
>>> ad = ds.all_data()
>>> cr = ad.cut_region(["obj['temperature'] > 1e6"])
>>> print cr.quantities.total_quantity("cell_mass").in_units('Msun')
>>> print(cr.quantities.total_quantity("cell_mass").in_units('Msun'))
"""
cr = self.ds.cut_region(self, field_cuts,
field_parameters=field_parameters)
Expand Down
38 changes: 19 additions & 19 deletions yt/data_objects/derived_quantities.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ class WeightedAverageQuantity(DerivedQuantity):
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.weighted_average_quantity([("gas", "density"),
>>> print(ad.quantities.weighted_average_quantity([("gas", "density"),
... ("gas", "temperature")],
... ("gas", "cell_mass"))
... ("gas", "cell_mass")))
"""
def count_values(self, fields, weight):
Expand Down Expand Up @@ -153,7 +153,7 @@ class TotalQuantity(DerivedQuantity):
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.total_quantity([("gas", "cell_mass")])
>>> print(ad.quantities.total_quantity([("gas", "cell_mass")]))
"""
def count_values(self, fields):
Expand Down Expand Up @@ -185,7 +185,7 @@ class TotalMass(TotalQuantity):
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.total_mass()
>>> print(ad.quantities.total_mass())
"""
def __call__(self):
Expand Down Expand Up @@ -228,7 +228,7 @@ class CenterOfMass(DerivedQuantity):
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.center_of_mass()
>>> print(ad.quantities.center_of_mass())
"""
def count_values(self, use_gas = True, use_particles = False, particle_type="nbody"):
Expand Down Expand Up @@ -302,7 +302,7 @@ class BulkVelocity(DerivedQuantity):
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.bulk_velocity()
>>> print(ad.quantities.bulk_velocity())
"""
def count_values(self, use_gas=True, use_particles=False, particle_type="nbody"):
Expand Down Expand Up @@ -370,9 +370,9 @@ class WeightedVariance(DerivedQuantity):
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.weighted_variance([("gas", "density"),
>>> print(ad.quantities.weighted_variance([("gas", "density"),
... ("gas", "temperature")],
... ("gas", "cell_mass"))
... ("gas", "cell_mass")))
"""
def count_values(self, fields, weight):
Expand Down Expand Up @@ -443,13 +443,13 @@ class AngularMomentumVector(DerivedQuantity):
# Find angular momentum vector of galaxy in grid-based isolated galaxy dataset
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.angular_momentum_vector()
>>> print(ad.quantities.angular_momentum_vector())
# Find angular momentum vector of gas disk in particle-based dataset
>>> ds = load("FIRE_M12i_ref11/snapshot_600.hdf5")
>>> _, c = ds.find_max(('gas', 'density'))
>>> sp = ds.sphere(c, (10, 'kpc'))
>>> print sp.quantities.angular_momentum_vector(use_gas=False, use_particles=True, particle_type='PartType0')
>>> print(sp.quantities.angular_momentum_vector(use_gas=False, use_particles=True, particle_type='PartType0'))
"""
def count_values(self, use_gas=True, use_particles=True, particle_type='all'):
Expand Down Expand Up @@ -517,8 +517,8 @@ class Extrema(DerivedQuantity):
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.extrema([("gas", "density"),
... ("gas", "temperature")])
>>> print(ad.quantities.extrema([("gas", "density"),
... ("gas", "temperature")]))
"""
def count_values(self, fields, non_zero):
Expand Down Expand Up @@ -566,8 +566,8 @@ class SampleAtMaxFieldValues(DerivedQuantity):
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.sample_at_max_field_values(("gas", "density"),
... ["temperature", "velocity_magnitude"])
>>> print(ad.quantities.sample_at_max_field_values(("gas", "density"),
... ["temperature", "velocity_magnitude"]))
"""
def count_values(self, field, sample_fields):
Expand Down Expand Up @@ -612,7 +612,7 @@ class MaxLocation(SampleAtMaxFieldValues):
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.max_location(("gas", "density"))
>>> print(ad.quantities.max_location(("gas", "density")))
"""
def __call__(self, field):
Expand Down Expand Up @@ -642,8 +642,8 @@ class SampleAtMinFieldValues(SampleAtMaxFieldValues):
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.sample_at_min_field_values(("gas", "density"),
... ["temperature", "velocity_magnitude"])
>>> print(ad.quantities.sample_at_min_field_values(("gas", "density"),
... ["temperature", "velocity_magnitude"]))
"""
def _func(self, arr):
Expand All @@ -664,7 +664,7 @@ class MinLocation(SampleAtMinFieldValues):
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.min_location(("gas", "density"))
>>> print(ad.quantities.min_location(("gas", "density")))
"""
def __call__(self, field):
Expand Down Expand Up @@ -710,7 +710,7 @@ class SpinParameter(DerivedQuantity):
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.spin_parameter()
>>> print(ad.quantities.spin_parameter())
"""
def count_values(self, **kwargs):
Expand Down
10 changes: 5 additions & 5 deletions yt/data_objects/level_sets/clump_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,17 @@ def save_as_dataset(self, filename=None, fields=None):
>>> new_ds = yt.load(fn)
>>> print (ds.tree["clump", "cell_mass"])
1296926163.91 Msun
>>> print ds.tree["grid", "density"]
>>> print(ds.tree["grid", "density"])
[ 2.54398434e-26 2.46620353e-26 2.25120154e-26 ..., 1.12879234e-25
1.59561490e-25 1.09824903e-24] g/cm**3
>>> print ds.tree["all", "particle_mass"]
>>> print(ds.tree["all", "particle_mass"])
[ 4.25472446e+38 4.25472446e+38 4.25472446e+38 ..., 2.04238266e+38
2.04523901e+38 2.04770938e+38] g
>>> print ds.tree.children[0]["clump", "cell_mass"]
>>> print(ds.tree.children[0]["clump", "cell_mass"])
909636495.312 Msun
>>> print ds.leaves[0]["clump", "cell_mass"]
>>> print(ds.leaves[0]["clump", "cell_mass"])
3756566.99809 Msun
>>> print ds.leaves[0]["grid", "density"]
>>> print(ds.leaves[0]["grid", "density"])
[ 6.97820274e-24 6.58117370e-24 7.32046082e-24 6.76202430e-24
7.41184837e-24 6.76981480e-24 6.94287213e-24 6.56149658e-24
6.76584569e-24 6.94073710e-24 7.06713082e-24 7.22556526e-24
Expand Down
2 changes: 1 addition & 1 deletion yt/data_objects/particle_trajectories.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ParticleTrajectories(object):
>>> ts = DatasetSeries(my_fns)
>>> trajs = ts.particle_trajectories(indices, fields=fields)
>>> for t in trajs :
>>> print t["particle_velocity_x"].max(), t["particle_velocity_x"].min()
>>> print(t["particle_velocity_x"].max(), t["particle_velocity_x"].min())
"""
def __init__(self, outputs, indices, fields=None, suppress_logging=False, ptype=None):

Expand Down
8 changes: 4 additions & 4 deletions yt/data_objects/selection_data_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class YTOrthoRay(YTSelectionContainer1D):
>>> import yt
>>> ds = yt.load("RedshiftOutput0005")
>>> oray = ds.ortho_ray(0, (0.2, 0.74))
>>> print oray["Density"]
>>> print(oray["Density"])
Note: The low-level data representation for rays are not guaranteed to be
spatially ordered. In particular, with AMR datasets, higher resolution
Expand Down Expand Up @@ -197,7 +197,7 @@ class YTRay(YTSelectionContainer1D):
>>> import yt
>>> ds = yt.load("RedshiftOutput0005")
>>> ray = ds.ray((0.2, 0.74, 0.11), (0.4, 0.91, 0.31))
>>> print ray["Density"], ray["t"], ray["dts"]
>>> print(ray["Density"], ray["t"], ray["dts"])
Note: The low-level data representation for rays are not guaranteed to be
spatially ordered. In particular, with AMR datasets, higher resolution
Expand Down Expand Up @@ -323,7 +323,7 @@ class YTSlice(YTSelectionContainer2D):
>>> import yt
>>> ds = yt.load("RedshiftOutput0005")
>>> slice = ds.slice(0, 0.25)
>>> print slice["Density"]
>>> print(slice["Density"])
"""
_top_node = "/Slices"
_type_name = "slice"
Expand Down Expand Up @@ -446,7 +446,7 @@ class YTCuttingPlane(YTSelectionContainer2D):
>>> import yt
>>> ds = yt.load("RedshiftOutput0005")
>>> cp = ds.cutting([0.1, 0.2, -0.9], [0.5, 0.42, 0.6])
>>> print cp["Density"]
>>> print(cp["Density"])
"""
_plane = None
_top_node = "/CuttingPlanes"
Expand Down
10 changes: 5 additions & 5 deletions yt/data_objects/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class DatasetSeries(object):
... SlicePlot(ds, "x", "Density").save()
...
>>> def print_time(ds):
... print ds.current_time
... print(ds.current_time)
...
>>> ts = DatasetSeries(
... "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0[0-6][0-9]0",
Expand Down Expand Up @@ -235,7 +235,7 @@ def piter(self, storage = None):
This demonstrates how one might store results:
>>> def print_time(ds):
... print ds.current_time
... print(ds.current_time)
...
>>> ts = DatasetSeries("DD*/DD*.index",
... setup_function = print_time )
Expand All @@ -246,7 +246,7 @@ def piter(self, storage = None):
... sto.result = (v, c)
...
>>> for i, (v, c) in sorted(my_storage.items()):
... print "% 4i %0.3e" % (i, v)
... print("% 4i %0.3e" % (i, v))
...
This shows how to dispatch 4 processors to each dataset:
Expand Down Expand Up @@ -341,7 +341,7 @@ def from_filenames(cls, filenames, parallel = True, setup_function = None,
--------
>>> def print_time(ds):
... print ds.current_time
... print(ds.current_time)
...
>>> ts = DatasetSeries.from_filenames(
... "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0[0-6][0-9]0",
Expand Down Expand Up @@ -422,7 +422,7 @@ def particle_trajectories(self, indices, fields=None, suppress_logging=False, pt
>>> ts = DatasetSeries(my_fns)
>>> trajs = ts.particle_trajectories(indices, fields=fields)
>>> for t in trajs :
>>> print t["particle_velocity_x"].max(), t["particle_velocity_x"].min()
>>> print(t["particle_velocity_x"].max(), t["particle_velocity_x"].min())
Note
----
Expand Down
8 changes: 4 additions & 4 deletions yt/frontends/art/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,11 +788,11 @@ def _count_art_octs(self, f, offset, MinLev, MaxLevelNow):
level_oct_offsets.append(f.tell())

# Get the info for this level, skip the rest
# print "Reading oct tree data for level", Lev
# print 'offset:',f.tell()
# print("Reading oct tree data for level", Lev)
# print('offset:',f.tell())
Level[Lev], iNOLL[Lev], iHOLL[Lev] = fpu.read_vector(f, 'i', '>')
# print 'Level %i : '%Lev, iNOLL
# print 'offset after level record:',f.tell()
# print('Level %i : '%Lev, iNOLL)
# print('offset after level record:',f.tell())
nLevel = iNOLL[Lev]
ntot = ntot + nLevel

Expand Down
4 changes: 2 additions & 2 deletions yt/frontends/enzo/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _read_particle_fields(self, chunks, ptf, selector):
for g in chunk.objs:
if g.filename is None: continue
if f is None:
#print "Opening (read) %s" % g.filename
#print("Opening (read) %s" % g.filename)
f = h5py.File(g.filename, "r")
nap = sum(g.NumberOfActiveParticles.values())
if g.NumberOfParticles == 0 and nap == 0:
Expand Down Expand Up @@ -307,7 +307,7 @@ def _read_fluid_selection(self, chunks, selector, fields, size):
f = None
for g in chunk.objs:
if f is None:
#print "Opening (count) %s" % g.filename
#print("Opening (count) %s" % g.filename)
f = h5py.File(g.filename, "r")
gds = f.get("/Grid%08i" % g.id)
if gds is None:
Expand Down
2 changes: 1 addition & 1 deletion yt/frontends/exodus_ii/simulation_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ExodusIISimulation(DatasetSeries, metaclass = RegisteredSimulationTimeSeri
>>> sim = yt.simulation("demo_second", "ExodusII")
>>> sim.get_time_series()
>>> for ds in sim:
... print ds.current_time
... print(ds.current_time)
"""

Expand Down
2 changes: 1 addition & 1 deletion yt/frontends/fits/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def ds9_region(ds, reg, obj=None, field_parameters=None):
>>> ds = yt.load("m33_hi.fits")
>>> circle_region = ds9_region(ds, "circle.reg")
>>> print circle_region.quantities.extrema("flux")
>>> print(circle_region.quantities.extrema("flux"))
"""
import pyregion
from yt.frontends.fits.api import EventsFITSDataset
Expand Down
4 changes: 2 additions & 2 deletions yt/frontends/gadget/simulation_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class GadgetSimulation(SimulationTimeSeries):
>>> gs = yt.simulation("my_simulation.par", "Gadget")
>>> gs.get_time_series()
>>> for ds in gs:
... print ds.current_time
... print(ds.current_time)
"""

Expand Down Expand Up @@ -189,7 +189,7 @@ def get_time_series(self, initial_time=None, final_time=None,
>>> # An example using the setup_function keyword
>>> def print_time(ds):
... print ds.current_time
... print(ds.current_time)
>>> gs.get_time_series(setup_function=print_time)
>>> for ds in gs:
... SlicePlot(ds, "x", "Density").save()
Expand Down
Loading

0 comments on commit 816301c

Please sign in to comment.