[yt-svn] commit/yt: 15 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Dec 14 11:18:38 PST 2015
15 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/8c10b8ac8f41/
Changeset: 8c10b8ac8f41
Branch: yt
User: xarthisius
Date: 2015-12-09 00:09:58+00:00
Summary: Sort OWLSSubfindHDF5Files using filename attribute
Affected #: 1 file
diff -r 81762aa466f368a730c369e7841f7234a06579b2 -r 8c10b8ac8f4130242cec0efdb6a02b77b06b4551 yt/frontends/owls_subfind/io.py
--- a/yt/frontends/owls_subfind/io.py
+++ b/yt/frontends/owls_subfind/io.py
@@ -42,7 +42,7 @@
for chunk in chunks:
for obj in chunk.objs:
data_files.update(obj.data_files)
- for data_file in sorted(data_files):
+ for data_file in sorted(data_files, key=lambda f: f.filename):
with h5py.File(data_file.filename, "r") as f:
for ptype, field_list in sorted(ptf.items()):
pcount = data_file.total_particles[ptype]
@@ -76,7 +76,7 @@
for chunk in chunks:
for obj in chunk.objs:
data_files.update(obj.data_files)
- for data_file in sorted(data_files):
+ for data_file in sorted(data_files, key=lambda f: f.filename):
with h5py.File(data_file.filename, "r") as f:
for ptype, field_list in sorted(ptf.items()):
pcount = data_file.total_particles[ptype]
https://bitbucket.org/yt_analysis/yt/commits/76541a5190bf/
Changeset: 76541a5190bf
Branch: yt
User: xarthisius
Date: 2015-12-09 00:20:17+00:00
Summary: Use six.string_types instead of types.StringTypes
Affected #: 1 file
diff -r 8c10b8ac8f4130242cec0efdb6a02b77b06b4551 -r 76541a5190bf0d5dff85fa78b0dff65c59c53297 yt/data_objects/region_expression.py
--- a/yt/data_objects/region_expression.py
+++ b/yt/data_objects/region_expression.py
@@ -12,8 +12,8 @@
#-----------------------------------------------------------------------------
import weakref
-import types
+from yt.extern.six import string_types
from yt.utilities.exceptions import YTDimensionalityError
class RegionExpression(object):
@@ -31,11 +31,11 @@
# At first, we will only implement this as accepting a slice that is
# (optionally) unitful corresponding to a specific set of coordinates
# that result in a rectangular prism or a slice.
- if isinstance(item, types.StringTypes):
+ if isinstance(item, string_types):
# This is some field; we will instead pass this back to the
# all_data object.
return self.all_data[item]
- if isinstance(item, tuple) and isinstance(item[1], types.StringTypes):
+ if isinstance(item, tuple) and isinstance(item[1], string_types):
return self.all_data[item]
if len(item) != self.ds.dimensionality:
# Not the right specification, and we don't want to do anything
https://bitbucket.org/yt_analysis/yt/commits/32f7b4859ce4/
Changeset: 32f7b4859ce4
Branch: yt
User: xarthisius
Date: 2015-12-09 16:03:02+00:00
Summary: Use six.moves.input instead of raw_input
Affected #: 2 files
diff -r 76541a5190bf0d5dff85fa78b0dff65c59c53297 -r 32f7b4859ce40bcd6bd15dcdb7868948baf89818 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -16,6 +16,7 @@
import errno
from yt.extern.six import string_types
+from yt.extern.moves import input
import time
import inspect
import traceback
@@ -586,7 +587,7 @@
data = urllib.parse.urlencode(data)
req = urllib.request.Request(uri, data)
if use_pass:
- username = raw_input("Bitbucket Username? ")
+ username = input("Bitbucket Username? ")
password = getpass.getpass()
upw = '%s:%s' % (username, password)
req.add_header('Authorization', 'Basic %s' % base64.b64encode(upw).strip())
@@ -604,7 +605,7 @@
print("*** is a delicate act, I require you to respond ***")
print("*** to the prompt with the word 'yes'. ***")
print()
- response = raw_input("Do you want me to try to check it out? ")
+ response = input("Do you want me to try to check it out? ")
if response != "yes":
print()
print("Okay, I understand. You can check it out yourself.")
diff -r 76541a5190bf0d5dff85fa78b0dff65c59c53297 -r 32f7b4859ce40bcd6bd15dcdb7868948baf89818 yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -38,7 +38,7 @@
update_hg, \
enable_plugins
from yt.extern.six import add_metaclass, string_types
-from yt.extern.six.moves import urllib
+from yt.extern.six.moves import urllib, input
from yt.convenience import load
from yt.visualization.plot_window import \
SlicePlot, \
@@ -345,7 +345,7 @@
print()
print("[hit enter to continue or Ctrl-C to stop]")
try:
- raw_input()
+ input()
except:
sys.exit(0)
os.environ["REINST_YT"] = "1"
@@ -381,7 +381,7 @@
data = urllib.parse.urlencode(data)
req = urllib.request.Request(uri, data)
if use_pass:
- username = raw_input("Bitbucket Username? ")
+ username = input("Bitbucket Username? ")
password = getpass.getpass()
upw = '%s:%s' % (username, password)
req.add_header('Authorization', 'Basic %s' % base64.b64encode(upw).strip())
@@ -419,7 +419,7 @@
print(" http://yt-project.org/irc.html")
print(" http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org")
print()
- summary = raw_input("Press <enter> if you remain firm in your conviction to continue.")
+ summary = input("Press <enter> if you remain firm in your conviction to continue.")
print()
print()
print("Okay, sorry about that. How about a nice, pithy ( < 12 words )")
@@ -430,7 +430,7 @@
current_version = get_yt_version()
except:
current_version = "Unavailable"
- summary = raw_input("Summary? ")
+ summary = input("Summary? ")
bugtype = "bug"
data = dict(title = summary, type=bugtype)
print()
@@ -442,7 +442,7 @@
if "EDITOR" in os.environ:
print()
print("Press enter to spawn your editor, %s" % os.environ["EDITOR"])
- raw_input()
+ input()
tf = tempfile.NamedTemporaryFile(delete=False)
fn = tf.name
tf.close()
@@ -463,7 +463,7 @@
print()
lines = []
while 1:
- line = raw_input()
+ line = input()
if line.strip() == "---": break
lines.append(line)
content = "\n".join(lines)
@@ -487,7 +487,7 @@
print("'submit'. Next we'll ask for your Bitbucket Username.")
print("If you don't have one, run the 'yt bootstrap_dev' command.")
print()
- raw_input()
+ input()
retval = bb_apicall(endpoint, data, use_pass=True)
import json
retval = json.loads(retval)
@@ -528,17 +528,17 @@
print()
print("What username would you like to go by?")
print()
- username = raw_input("Username? ")
+ username = input("Username? ")
if len(username) == 0: sys.exit(1)
print()
print("To start out, what's your name?")
print()
- name = raw_input("Name? ")
+ name = input("Name? ")
if len(name) == 0: sys.exit(1)
print()
print("And your email address?")
print()
- email = raw_input("Email? ")
+ email = input("Email? ")
if len(email) == 0: sys.exit(1)
print()
print("Please choose a password:")
@@ -554,12 +554,12 @@
print("Would you like a URL displayed for your user?")
print("Leave blank if no.")
print()
- url = raw_input("URL? ")
+ url = input("URL? ")
print()
print("Okay, press enter to register. You should receive a welcome")
print("message at %s when this is complete." % email)
print()
- raw_input()
+ input()
data = dict(name = name, email = email, username = username,
password = password1, password2 = password2,
url = url, zap = "rowsdower")
https://bitbucket.org/yt_analysis/yt/commits/9dc7ebf7d047/
Changeset: 9dc7ebf7d047
Branch: yt
User: xarthisius
Date: 2015-12-09 16:05:19+00:00
Summary: Use range() instead of xrange()
Affected #: 1 file
diff -r 32f7b4859ce40bcd6bd15dcdb7868948baf89818 -r 9dc7ebf7d0471994f00dc89b744aec00b328ce87 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -520,7 +520,7 @@
"""
dtheta = (1.0*theta)/n_steps
- for i in xrange(n_steps):
+ for i in range(n_steps):
self.rotate(dtheta, rot_vector=rot_vector, rot_center=rot_center)
yield i
@@ -561,7 +561,7 @@
dx = position_diff**(1.0/n_steps)
else:
dx = (final - self.position)*1.0/n_steps
- for i in xrange(n_steps):
+ for i in range(n_steps):
if exponential:
self.set_position(self.position * dx)
else:
@@ -621,7 +621,7 @@
"""
f = final**(1.0/n_steps)
- for i in xrange(n_steps):
+ for i in range(n_steps):
self.zoom(f)
yield i
https://bitbucket.org/yt_analysis/yt/commits/91ce1f9cd0c8/
Changeset: 91ce1f9cd0c8
Branch: yt
User: xarthisius
Date: 2015-12-09 16:07:36+00:00
Summary: long() no longer exists in py3
Affected #: 1 file
diff -r 9dc7ebf7d0471994f00dc89b744aec00b328ce87 -r 91ce1f9cd0c84a26cca42b153931b00d1d7551b5 yt/frontends/tipsy/data_structures.py
--- a/yt/frontends/tipsy/data_structures.py
+++ b/yt/frontends/tipsy/data_structures.py
@@ -38,6 +38,10 @@
from .fields import \
TipsyFieldInfo
+import sys
+if sys.version_info > (3,):
+ long = int
+
class TipsyFile(ParticleFile):
def __init__(self, ds, io, filename, file_id):
# To go above 1 domain, we need to include an indexing step in the
https://bitbucket.org/yt_analysis/yt/commits/c14239b13168/
Changeset: c14239b13168
Branch: yt
User: xarthisius
Date: 2015-12-09 16:17:49+00:00
Summary: Use open() instead of file()
Affected #: 2 files
diff -r 91ce1f9cd0c84a26cca42b153931b00d1d7551b5 -r c14239b131686c09502afee5c90110b816c523e8 yt/frontends/athena/data_structures.py
--- a/yt/frontends/athena/data_structures.py
+++ b/yt/frontends/athena/data_structures.py
@@ -152,10 +152,7 @@
self.dataset_type = dataset_type
# for now, the index file is the dataset!
self.index_filename = os.path.join(os.getcwd(), self.dataset.filename)
- if PY2:
- self._fhandle = file(self.index_filename,'rb')
- else:
- self._fhandle = open(self.index_filename,'rb')
+ self._fhandle = open(self.index_filename,'rb')
GridIndex.__init__(self, ds, dataset_type)
self._fhandle.close()
diff -r 91ce1f9cd0c84a26cca42b153931b00d1d7551b5 -r c14239b131686c09502afee5c90110b816c523e8 yt/frontends/gadget/simulation_handling.py
--- a/yt/frontends/gadget/simulation_handling.py
+++ b/yt/frontends/gadget/simulation_handling.py
@@ -375,7 +375,7 @@
else:
if self.parameters["OutputListOn"]:
a_values = [float(a) for a in
- file(self.parameters["OutputListFilename"], "r").readlines()]
+ open(self.parameters["OutputListFilename"], "r").readlines()]
else:
a_values = [float(self.parameters["TimeOfFirstSnapshot"])]
time_max = float(self.parameters["TimeMax"])
https://bitbucket.org/yt_analysis/yt/commits/0d2b8815f6d8/
Changeset: 0d2b8815f6d8
Branch: yt
User: xarthisius
Date: 2015-12-09 16:18:09+00:00
Summary: Check for python version using sys.version_info
Affected #: 1 file
diff -r c14239b131686c09502afee5c90110b816c523e8 -r 0d2b8815f6d8d8c1bb7fa575400aa2a44d2baece yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -20,6 +20,7 @@
from re import finditer
from tempfile import TemporaryFile
import os
+import sys
import zipfile
from yt.config import ytcfg
@@ -1278,14 +1279,13 @@
def _color_samples_obj(self, cs, em, color_log, emit_log, color_map, arr,
color_field_max, color_field_min, color_field,
emit_field_max, emit_field_min, emit_field): # this now holds for obj files
- from sys import version
if color_field is not None:
if color_log: cs = np.log10(cs)
if emit_field is not None:
if emit_log: em = np.log10(em)
if color_field is not None:
if color_field_min is None:
- if version >= '3':
+ if sys.version_info > (3, ):
cs = [float(field) for field in cs]
cs = np.array(cs)
mi = cs.min()
@@ -1293,7 +1293,7 @@
mi = color_field_min
if color_log: mi = np.log10(mi)
if color_field_max is None:
- if version >= '3':
+ if sys.version_info > (3, ):
cs = [float(field) for field in cs]
cs = np.array(cs)
ma = cs.max()
@@ -1311,7 +1311,7 @@
# now, get emission
if emit_field is not None:
if emit_field_min is None:
- if version >= '3':
+ if sys.version_info > (3, ):
em = [float(field) for field in em]
em = np.array(em)
emi = em.min()
@@ -1319,7 +1319,7 @@
emi = emit_field_min
if emit_log: emi = np.log10(emi)
if emit_field_max is None:
- if version >= '3':
+ if sys.version_info > (3, ):
em = [float(field) for field in em]
em = np.array(em)
ema = em.max()
@@ -1339,12 +1339,11 @@
color_log = True, emit_log = True, plot_index = None,
color_field_max = None, color_field_min = None,
emit_field_max = None, emit_field_min = None):
- from sys import version
from io import IOBase
if plot_index is None:
plot_index = 0
- if version < '3':
- checker = file
+ if sys.version_info < (3, ):
+ checker = file # noqa
else:
checker = IOBase
if isinstance(filename, checker):
https://bitbucket.org/yt_analysis/yt/commits/73a3f9eb8aed/
Changeset: 73a3f9eb8aed
Branch: yt
User: xarthisius
Date: 2015-12-09 16:24:11+00:00
Summary: Use open() instead of file()
Affected #: 1 file
diff -r 0d2b8815f6d8d8c1bb7fa575400aa2a44d2baece -r 73a3f9eb8aed7ba8c988527201e7a351f3e5620b yt/utilities/pyparselibconfig/libconfig.py
--- a/yt/utilities/pyparselibconfig/libconfig.py
+++ b/yt/utilities/pyparselibconfig/libconfig.py
@@ -74,7 +74,7 @@
return eval(v)
def write(self, filename):
- f = file(filename, 'w')
+ f = open(filename, 'w')
self.write_dict(f, self, 0)
https://bitbucket.org/yt_analysis/yt/commits/05a929d2bf87/
Changeset: 05a929d2bf87
Branch: yt
User: xarthisius
Date: 2015-12-09 16:28:02+00:00
Summary: Use open() instead of file()
Affected #: 1 file
diff -r 73a3f9eb8aed7ba8c988527201e7a351f3e5620b -r 05a929d2bf8776a1360d9e4de8b9b74955a31d7c yt/analysis_modules/halo_finding/halo_objects.py
--- a/yt/analysis_modules/halo_finding/halo_objects.py
+++ b/yt/analysis_modules/halo_finding/halo_objects.py
@@ -1344,7 +1344,8 @@
def _retrieve_halos(self):
# First get the halo particulars.
- lines = file("%s.out" % self.basename)
+ with open("%s.out" % self.basename, 'r') as fh:
+ lines = fh.readlines()
# The location of particle data for each halo.
locations = self._collect_halo_data_locations()
halo = 0
@@ -1395,7 +1396,8 @@
def _collect_halo_data_locations(self):
# The halos are listed in order in the file.
- lines = file("%s.txt" % self.basename)
+ with open("%s.txt" % self.basename, 'r') as fh:
+ lines = fh.readlines()
locations = []
realpath = path.realpath("%s.txt" % self.basename)
for line in lines:
@@ -1408,7 +1410,6 @@
item = item.split("/")
temp.append(path.join(path.dirname(realpath), item[-1]))
locations.append(temp)
- lines.close()
return locations
class TextHaloList(HaloList):
@@ -1422,7 +1423,8 @@
def _retrieve_halos(self, fname, columns, comment):
# First get the halo particulars.
- lines = file(fname)
+ with open(fname, 'r') as fh:
+ lines = fh.readlines()
halo = 0
base_set = ['x', 'y', 'z', 'r']
keys = columns.keys()
https://bitbucket.org/yt_analysis/yt/commits/07c3e13dcb8b/
Changeset: 07c3e13dcb8b
Branch: yt
User: xarthisius
Date: 2015-12-09 16:29:45+00:00
Summary: Fix indent
Affected #: 1 file
diff -r 05a929d2bf8776a1360d9e4de8b9b74955a31d7c -r 07c3e13dcb8b5c61e0c888209bc9635a4488fc0f yt/frontends/gadget/simulation_handling.py
--- a/yt/frontends/gadget/simulation_handling.py
+++ b/yt/frontends/gadget/simulation_handling.py
@@ -375,7 +375,7 @@
else:
if self.parameters["OutputListOn"]:
a_values = [float(a) for a in
- open(self.parameters["OutputListFilename"], "r").readlines()]
+ open(self.parameters["OutputListFilename"], "r").readlines()]
else:
a_values = [float(self.parameters["TimeOfFirstSnapshot"])]
time_max = float(self.parameters["TimeMax"])
https://bitbucket.org/yt_analysis/yt/commits/070496ee72f9/
Changeset: 070496ee72f9
Branch: yt
User: xarthisius
Date: 2015-12-09 16:45:36+00:00
Summary: Fix import typo
Affected #: 1 file
diff -r 07c3e13dcb8b5c61e0c888209bc9635a4488fc0f -r 070496ee72f9d0a4acd3813e3504cb19b1fe7f2c yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -16,7 +16,7 @@
import errno
from yt.extern.six import string_types
-from yt.extern.moves import input
+from yt.extern.six.moves import input
import time
import inspect
import traceback
https://bitbucket.org/yt_analysis/yt/commits/5aa9a06959bb/
Changeset: 5aa9a06959bb
Branch: yt
User: ngoldbaum
Date: 2015-12-09 17:18:54+00:00
Summary: Use IOBase to compare file types instead of file
Affected #: 1 file
diff -r 070496ee72f9d0a4acd3813e3504cb19b1fe7f2c -r 5aa9a06959bb74517a73c67f762e7a2f8f2d4d1e yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -17,6 +17,7 @@
import numpy as np
from functools import wraps
import fileinput
+import io
from re import finditer
from tempfile import TemporaryFile
import os
@@ -1339,14 +1340,9 @@
color_log = True, emit_log = True, plot_index = None,
color_field_max = None, color_field_min = None,
emit_field_max = None, emit_field_min = None):
- from io import IOBase
if plot_index is None:
plot_index = 0
- if sys.version_info < (3, ):
- checker = file # noqa
- else:
- checker = IOBase
- if isinstance(filename, checker):
+ if isinstance(filename, io.IOBase):
fobj = filename + '.obj'
fmtl = filename + '.mtl'
else:
@@ -1638,7 +1634,7 @@
@parallel_root_only
def _export_ply(self, filename, bounds = None, color_field = None,
color_map = "algae", color_log = True, sample_type = "face"):
- if isinstance(filename, file):
+ if isinstance(filename, io.IOBase):
f = filename
else:
f = open(filename, "wb")
https://bitbucket.org/yt_analysis/yt/commits/0ef56a1490ff/
Changeset: 0ef56a1490ff
Branch: yt
User: ngoldbaum
Date: 2015-12-09 17:19:12+00:00
Summary: Use open instead of file to open files
Affected #: 2 files
diff -r 5aa9a06959bb74517a73c67f762e7a2f8f2d4d1e -r 0ef56a1490ff00045f7283825efbff7705eb589e yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -325,7 +325,7 @@
if not os.path.exists(date_file):
print("Could not determine when yt stack was last updated.")
return
- print("".join(file(date_file, 'r').readlines()))
+ print("".join(open(date_file, 'r').readlines()))
print("To update all dependencies, run \"yt update --all\".")
def _update_yt_stack(path):
diff -r 5aa9a06959bb74517a73c67f762e7a2f8f2d4d1e -r 0ef56a1490ff00045f7283825efbff7705eb589e yt/utilities/sdf.py
--- a/yt/utilities/sdf.py
+++ b/yt/utilities/sdf.py
@@ -292,7 +292,7 @@
self.load_memmaps()
def write(self, filename):
- f = file(filename, 'w')
+ f = open(filename, 'w')
f.write("# SDF 1.0\n")
f.write("parameter byteorder = %s;\n" % (self.parameters['byteorder']))
for c in self.comments:
https://bitbucket.org/yt_analysis/yt/commits/c9379844dafc/
Changeset: c9379844dafc
Branch: yt
User: ngoldbaum
Date: 2015-12-09 17:25:43+00:00
Summary: Use __lt__ instead of __cmp__ for py3 compat
Affected #: 2 files
diff -r 0ef56a1490ff00045f7283825efbff7705eb589e -r c9379844dafc093f54c6b7da1ecf9f2449f01119 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -1141,5 +1141,5 @@
def _calculate_offsets(self, fields):
pass
- def __cmp__(self, other):
- return cmp(self.filename, other.filename)
+ def __lt__(self, other):
+ return self.filename < other.filename
diff -r 0ef56a1490ff00045f7283825efbff7705eb589e -r c9379844dafc093f54c6b7da1ecf9f2449f01119 yt/utilities/poster/encode.py
--- a/yt/utilities/poster/encode.py
+++ b/yt/utilities/poster/encode.py
@@ -114,11 +114,11 @@
except:
raise ValueError("Could not determine filesize")
- def __cmp__(self, other):
+ def __lt__(self, other):
attrs = ['name', 'value', 'filename', 'filetype', 'filesize', 'fileobj']
myattrs = [getattr(self, a) for a in attrs]
oattrs = [getattr(other, a) for a in attrs]
- return cmp(myattrs, oattrs)
+ return myattrs < oattrs
def reset(self):
if self.fileobj is not None:
https://bitbucket.org/yt_analysis/yt/commits/e8f6316dad05/
Changeset: e8f6316dad05
Branch: yt
User: MatthewTurk
Date: 2015-12-14 19:18:26+00:00
Summary: Merged in xarthisius/yt (pull request #1899)
[bugfix] py3 compat
Affected #: 14 files
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/analysis_modules/halo_finding/halo_objects.py
--- a/yt/analysis_modules/halo_finding/halo_objects.py
+++ b/yt/analysis_modules/halo_finding/halo_objects.py
@@ -1344,7 +1344,8 @@
def _retrieve_halos(self):
# First get the halo particulars.
- lines = file("%s.out" % self.basename)
+ with open("%s.out" % self.basename, 'r') as fh:
+ lines = fh.readlines()
# The location of particle data for each halo.
locations = self._collect_halo_data_locations()
halo = 0
@@ -1395,7 +1396,8 @@
def _collect_halo_data_locations(self):
# The halos are listed in order in the file.
- lines = file("%s.txt" % self.basename)
+ with open("%s.txt" % self.basename, 'r') as fh:
+ lines = fh.readlines()
locations = []
realpath = path.realpath("%s.txt" % self.basename)
for line in lines:
@@ -1408,7 +1410,6 @@
item = item.split("/")
temp.append(path.join(path.dirname(realpath), item[-1]))
locations.append(temp)
- lines.close()
return locations
class TextHaloList(HaloList):
@@ -1422,7 +1423,8 @@
def _retrieve_halos(self, fname, columns, comment):
# First get the halo particulars.
- lines = file(fname)
+ with open(fname, 'r') as fh:
+ lines = fh.readlines()
halo = 0
base_set = ['x', 'y', 'z', 'r']
keys = columns.keys()
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -17,9 +17,11 @@
import numpy as np
from functools import wraps
import fileinput
+import io
from re import finditer
from tempfile import TemporaryFile
import os
+import sys
import zipfile
from yt.config import ytcfg
@@ -1272,14 +1274,13 @@
def _color_samples_obj(self, cs, em, color_log, emit_log, color_map, arr,
color_field_max, color_field_min, color_field,
emit_field_max, emit_field_min, emit_field): # this now holds for obj files
- from sys import version
if color_field is not None:
if color_log: cs = np.log10(cs)
if emit_field is not None:
if emit_log: em = np.log10(em)
if color_field is not None:
if color_field_min is None:
- if version >= '3':
+ if sys.version_info > (3, ):
cs = [float(field) for field in cs]
cs = np.array(cs)
mi = cs.min()
@@ -1287,7 +1288,7 @@
mi = color_field_min
if color_log: mi = np.log10(mi)
if color_field_max is None:
- if version >= '3':
+ if sys.version_info > (3, ):
cs = [float(field) for field in cs]
cs = np.array(cs)
ma = cs.max()
@@ -1305,7 +1306,7 @@
# now, get emission
if emit_field is not None:
if emit_field_min is None:
- if version >= '3':
+ if sys.version_info > (3, ):
em = [float(field) for field in em]
em = np.array(em)
emi = em.min()
@@ -1313,7 +1314,7 @@
emi = emit_field_min
if emit_log: emi = np.log10(emi)
if emit_field_max is None:
- if version >= '3':
+ if sys.version_info > (3, ):
em = [float(field) for field in em]
em = np.array(em)
ema = em.max()
@@ -1333,15 +1334,9 @@
color_log = True, emit_log = True, plot_index = None,
color_field_max = None, color_field_min = None,
emit_field_max = None, emit_field_min = None):
- from sys import version
- from io import IOBase
if plot_index is None:
plot_index = 0
- if version < '3':
- checker = file
- else:
- checker = IOBase
- if isinstance(filename, checker):
+ if isinstance(filename, io.IOBase):
fobj = filename + '.obj'
fmtl = filename + '.mtl'
else:
@@ -1633,7 +1628,7 @@
@parallel_root_only
def _export_ply(self, filename, bounds = None, color_field = None,
color_map = "algae", color_log = True, sample_type = "face"):
- if isinstance(filename, file):
+ if isinstance(filename, io.IOBase):
f = filename
else:
f = open(filename, "wb")
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/data_objects/region_expression.py
--- a/yt/data_objects/region_expression.py
+++ b/yt/data_objects/region_expression.py
@@ -12,8 +12,8 @@
#-----------------------------------------------------------------------------
import weakref
-import types
+from yt.extern.six import string_types
from yt.utilities.exceptions import YTDimensionalityError
class RegionExpression(object):
@@ -31,11 +31,11 @@
# At first, we will only implement this as accepting a slice that is
# (optionally) unitful corresponding to a specific set of coordinates
# that result in a rectangular prism or a slice.
- if isinstance(item, types.StringTypes):
+ if isinstance(item, string_types):
# This is some field; we will instead pass this back to the
# all_data object.
return self.all_data[item]
- if isinstance(item, tuple) and isinstance(item[1], types.StringTypes):
+ if isinstance(item, tuple) and isinstance(item[1], string_types):
return self.all_data[item]
if len(item) != self.ds.dimensionality:
# Not the right specification, and we don't want to do anything
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -1141,5 +1141,5 @@
def _calculate_offsets(self, fields):
pass
- def __cmp__(self, other):
- return cmp(self.filename, other.filename)
+ def __lt__(self, other):
+ return self.filename < other.filename
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/frontends/athena/data_structures.py
--- a/yt/frontends/athena/data_structures.py
+++ b/yt/frontends/athena/data_structures.py
@@ -152,10 +152,7 @@
self.dataset_type = dataset_type
# for now, the index file is the dataset!
self.index_filename = os.path.join(os.getcwd(), self.dataset.filename)
- if PY2:
- self._fhandle = file(self.index_filename,'rb')
- else:
- self._fhandle = open(self.index_filename,'rb')
+ self._fhandle = open(self.index_filename,'rb')
GridIndex.__init__(self, ds, dataset_type)
self._fhandle.close()
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/frontends/gadget/simulation_handling.py
--- a/yt/frontends/gadget/simulation_handling.py
+++ b/yt/frontends/gadget/simulation_handling.py
@@ -375,7 +375,7 @@
else:
if self.parameters["OutputListOn"]:
a_values = [float(a) for a in
- file(self.parameters["OutputListFilename"], "r").readlines()]
+ open(self.parameters["OutputListFilename"], "r").readlines()]
else:
a_values = [float(self.parameters["TimeOfFirstSnapshot"])]
time_max = float(self.parameters["TimeMax"])
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/frontends/owls_subfind/io.py
--- a/yt/frontends/owls_subfind/io.py
+++ b/yt/frontends/owls_subfind/io.py
@@ -42,7 +42,7 @@
for chunk in chunks:
for obj in chunk.objs:
data_files.update(obj.data_files)
- for data_file in sorted(data_files):
+ for data_file in sorted(data_files, key=lambda f: f.filename):
with h5py.File(data_file.filename, "r") as f:
for ptype, field_list in sorted(ptf.items()):
pcount = data_file.total_particles[ptype]
@@ -76,7 +76,7 @@
for chunk in chunks:
for obj in chunk.objs:
data_files.update(obj.data_files)
- for data_file in sorted(data_files):
+ for data_file in sorted(data_files, key=lambda f: f.filename):
with h5py.File(data_file.filename, "r") as f:
for ptype, field_list in sorted(ptf.items()):
pcount = data_file.total_particles[ptype]
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/frontends/tipsy/data_structures.py
--- a/yt/frontends/tipsy/data_structures.py
+++ b/yt/frontends/tipsy/data_structures.py
@@ -38,6 +38,10 @@
from .fields import \
TipsyFieldInfo
+import sys
+if sys.version_info > (3,):
+ long = int
+
class TipsyFile(ParticleFile):
def __init__(self, ds, io, filename, file_id):
# To go above 1 domain, we need to include an indexing step in the
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -16,6 +16,7 @@
import errno
from yt.extern.six import string_types
+from yt.extern.six.moves import input
import time
import inspect
import traceback
@@ -586,7 +587,7 @@
data = urllib.parse.urlencode(data)
req = urllib.request.Request(uri, data)
if use_pass:
- username = raw_input("Bitbucket Username? ")
+ username = input("Bitbucket Username? ")
password = getpass.getpass()
upw = '%s:%s' % (username, password)
req.add_header('Authorization', 'Basic %s' % base64.b64encode(upw).strip())
@@ -604,7 +605,7 @@
print("*** is a delicate act, I require you to respond ***")
print("*** to the prompt with the word 'yes'. ***")
print()
- response = raw_input("Do you want me to try to check it out? ")
+ response = input("Do you want me to try to check it out? ")
if response != "yes":
print()
print("Okay, I understand. You can check it out yourself.")
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -38,7 +38,7 @@
update_hg, \
enable_plugins
from yt.extern.six import add_metaclass, string_types
-from yt.extern.six.moves import urllib
+from yt.extern.six.moves import urllib, input
from yt.convenience import load
from yt.visualization.plot_window import \
SlicePlot, \
@@ -325,7 +325,7 @@
if not os.path.exists(date_file):
print("Could not determine when yt stack was last updated.")
return
- print("".join(file(date_file, 'r').readlines()))
+ print("".join(open(date_file, 'r').readlines()))
print("To update all dependencies, run \"yt update --all\".")
def _update_yt_stack(path):
@@ -345,7 +345,7 @@
print()
print("[hit enter to continue or Ctrl-C to stop]")
try:
- raw_input()
+ input()
except:
sys.exit(0)
os.environ["REINST_YT"] = "1"
@@ -381,7 +381,7 @@
data = urllib.parse.urlencode(data)
req = urllib.request.Request(uri, data)
if use_pass:
- username = raw_input("Bitbucket Username? ")
+ username = input("Bitbucket Username? ")
password = getpass.getpass()
upw = '%s:%s' % (username, password)
req.add_header('Authorization', 'Basic %s' % base64.b64encode(upw).strip())
@@ -419,7 +419,7 @@
print(" http://yt-project.org/irc.html")
print(" http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org")
print()
- summary = raw_input("Press <enter> if you remain firm in your conviction to continue.")
+ summary = input("Press <enter> if you remain firm in your conviction to continue.")
print()
print()
print("Okay, sorry about that. How about a nice, pithy ( < 12 words )")
@@ -430,7 +430,7 @@
current_version = get_yt_version()
except:
current_version = "Unavailable"
- summary = raw_input("Summary? ")
+ summary = input("Summary? ")
bugtype = "bug"
data = dict(title = summary, type=bugtype)
print()
@@ -442,7 +442,7 @@
if "EDITOR" in os.environ:
print()
print("Press enter to spawn your editor, %s" % os.environ["EDITOR"])
- raw_input()
+ input()
tf = tempfile.NamedTemporaryFile(delete=False)
fn = tf.name
tf.close()
@@ -463,7 +463,7 @@
print()
lines = []
while 1:
- line = raw_input()
+ line = input()
if line.strip() == "---": break
lines.append(line)
content = "\n".join(lines)
@@ -487,7 +487,7 @@
print("'submit'. Next we'll ask for your Bitbucket Username.")
print("If you don't have one, run the 'yt bootstrap_dev' command.")
print()
- raw_input()
+ input()
retval = bb_apicall(endpoint, data, use_pass=True)
import json
retval = json.loads(retval)
@@ -528,17 +528,17 @@
print()
print("What username would you like to go by?")
print()
- username = raw_input("Username? ")
+ username = input("Username? ")
if len(username) == 0: sys.exit(1)
print()
print("To start out, what's your name?")
print()
- name = raw_input("Name? ")
+ name = input("Name? ")
if len(name) == 0: sys.exit(1)
print()
print("And your email address?")
print()
- email = raw_input("Email? ")
+ email = input("Email? ")
if len(email) == 0: sys.exit(1)
print()
print("Please choose a password:")
@@ -554,12 +554,12 @@
print("Would you like a URL displayed for your user?")
print("Leave blank if no.")
print()
- url = raw_input("URL? ")
+ url = input("URL? ")
print()
print("Okay, press enter to register. You should receive a welcome")
print("message at %s when this is complete." % email)
print()
- raw_input()
+ input()
data = dict(name = name, email = email, username = username,
password = password1, password2 = password2,
url = url, zap = "rowsdower")
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/utilities/poster/encode.py
--- a/yt/utilities/poster/encode.py
+++ b/yt/utilities/poster/encode.py
@@ -114,11 +114,11 @@
except:
raise ValueError("Could not determine filesize")
- def __cmp__(self, other):
+ def __lt__(self, other):
attrs = ['name', 'value', 'filename', 'filetype', 'filesize', 'fileobj']
myattrs = [getattr(self, a) for a in attrs]
oattrs = [getattr(other, a) for a in attrs]
- return cmp(myattrs, oattrs)
+ return myattrs < oattrs
def reset(self):
if self.fileobj is not None:
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/utilities/pyparselibconfig/libconfig.py
--- a/yt/utilities/pyparselibconfig/libconfig.py
+++ b/yt/utilities/pyparselibconfig/libconfig.py
@@ -74,7 +74,7 @@
return eval(v)
def write(self, filename):
- f = file(filename, 'w')
+ f = open(filename, 'w')
self.write_dict(f, self, 0)
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/utilities/sdf.py
--- a/yt/utilities/sdf.py
+++ b/yt/utilities/sdf.py
@@ -292,7 +292,7 @@
self.load_memmaps()
def write(self, filename):
- f = file(filename, 'w')
+ f = open(filename, 'w')
f.write("# SDF 1.0\n")
f.write("parameter byteorder = %s;\n" % (self.parameters['byteorder']))
for c in self.comments:
diff -r 0447987365b19d53451bd04609832f070f7362b2 -r e8f6316dad05ec9850bc3e994e163bd484cadb69 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -520,7 +520,7 @@
"""
dtheta = (1.0*theta)/n_steps
- for i in xrange(n_steps):
+ for i in range(n_steps):
self.rotate(dtheta, rot_vector=rot_vector, rot_center=rot_center)
yield i
@@ -561,7 +561,7 @@
dx = position_diff**(1.0/n_steps)
else:
dx = (final - self.position)*1.0/n_steps
- for i in xrange(n_steps):
+ for i in range(n_steps):
if exponential:
self.set_position(self.position * dx)
else:
@@ -621,7 +621,7 @@
"""
f = final**(1.0/n_steps)
- for i in xrange(n_steps):
+ for i in range(n_steps):
self.zoom(f)
yield i
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