[yt-svn] commit/yt: 22 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Aug 20 09:41:33 PDT 2015
22 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/117fbc0f03de/
Changeset: 117fbc0f03de
Branch: yt
User: ngoldbaum
Date: 2015-08-10 19:25:38+00:00
Summary: linting halo_analysis analysis module
Affected #: 6 files
diff -r 57abf679467c2b46098177a6662cc507c173395b -r 117fbc0f03de4a8d2486ce210da1cacd44f6f77c yt/analysis_modules/cosmological_observation/cosmology_splice.py
--- a/yt/analysis_modules/cosmological_observation/cosmology_splice.py
+++ b/yt/analysis_modules/cosmological_observation/cosmology_splice.py
@@ -14,10 +14,11 @@
#-----------------------------------------------------------------------------
import numpy as np
+import os
from yt.convenience import \
simulation
-from yt.funcs import *
+from yt.funcs import mylog
from yt.utilities.cosmology import \
Cosmology
diff -r 57abf679467c2b46098177a6662cc507c173395b -r 117fbc0f03de4a8d2486ce210da1cacd44f6f77c yt/analysis_modules/halo_analysis/enzofof_merger_tree.py
--- a/yt/analysis_modules/halo_analysis/enzofof_merger_tree.py
+++ b/yt/analysis_modules/halo_analysis/enzofof_merger_tree.py
@@ -35,13 +35,13 @@
import numpy as np
import h5py
-import time
-import pdb
+import glob
+import os
+
from yt.extern.six.moves import cPickle
-import glob
+from yt.extern.pykdtree import KDTree
+from yt.funcs import mylog, get_pbar
-from yt.funcs import *
-from yt.extern.pykdtree import KDTree
import yt.extern.pydot as pydot
# We don't currently use this, but we may again find a use for it in the
@@ -180,7 +180,7 @@
def calculate_parentage_fractions(self, other_catalog, radius = 0.10):
parentage_fractions = {}
- if self.halo_positions == None or other_catalog.halo_positions == None:
+ if self.halo_positions is None or other_catalog.halo_positions is None:
return parentage_fractions
mylog.debug("Ball-tree query with radius %0.3e", radius)
all_nearest = self.halo_kdtree.query_ball_tree(
@@ -320,7 +320,7 @@
for redshift in self.redshifts.values():
if redshift <= zrange[0] and redshift >= zrange[1]:
# some reverse lookup magic--assumes unique cycle/z pairs
- cycle = [key for key,value in mt.redshifts.items() \
+ cycle = [key for key,value in self.redshifts.items() \
if value == redshift][0]
del self.redshifts[cycle]
@@ -568,7 +568,7 @@
automatically. See GraphViz (e.g. "dot -v")
for a list of available output formats.
"""
- if filename == None:
+ if filename is None:
filename = "%s/tree_halo%5.5d.gv" % \
(self.FOF_directory, self.halonum)
# Create the pydot graph object.
@@ -598,7 +598,6 @@
# (lvl, br.halo_id, next_lvl, c[0], color)
#fp.write(line)
- last_level = (ii,lvl)
for ii,lvl in enumerate(sorted_lvl):
npart_max = 0
for br in self.levels[lvl]:
diff -r 57abf679467c2b46098177a6662cc507c173395b -r 117fbc0f03de4a8d2486ce210da1cacd44f6f77c yt/analysis_modules/halo_analysis/halo_callbacks.py
--- a/yt/analysis_modules/halo_analysis/halo_callbacks.py
+++ b/yt/analysis_modules/halo_analysis/halo_callbacks.py
@@ -18,23 +18,22 @@
import os
from yt.analysis_modules.cosmological_observation.light_ray.light_ray import \
- periodic_distance
+ periodic_distance
from yt.data_objects.profiles import \
- create_profile
+ create_profile
from yt.units.yt_array import \
- YTArray, YTQuantity
+ YTArray
from yt.utilities.exceptions import \
- YTSphereTooSmall
+ YTSphereTooSmall
from yt.funcs import \
- ensure_list, is_root
-from yt.utilities.exceptions import YTUnitConversionError
+ ensure_list
from yt.utilities.logger import ytLogger as mylog
from yt.utilities.operator_registry import \
- OperatorRegistry
+ OperatorRegistry
from yt.utilities.parallel_tools.parallel_analysis_interface import \
parallel_root_only
from yt.visualization.profile_plotter import \
- PhasePlot
+ PhasePlot
callback_registry = OperatorRegistry()
diff -r 57abf679467c2b46098177a6662cc507c173395b -r 117fbc0f03de4a8d2486ce210da1cacd44f6f77c yt/analysis_modules/halo_analysis/halo_catalog.py
--- a/yt/analysis_modules/halo_analysis/halo_catalog.py
+++ b/yt/analysis_modules/halo_analysis/halo_catalog.py
@@ -138,7 +138,7 @@
self.actions = []
# fields to be written to the halo catalog
self.quantities = []
- if not self.halos_ds is None:
+ if self.halos_ds is not None:
self.add_default_quantities()
def add_callback(self, callback, *args, **kwargs):
diff -r 57abf679467c2b46098177a6662cc507c173395b -r 117fbc0f03de4a8d2486ce210da1cacd44f6f77c yt/analysis_modules/halo_analysis/halo_finding_methods.py
--- a/yt/analysis_modules/halo_analysis/halo_finding_methods.py
+++ b/yt/analysis_modules/halo_analysis/halo_finding_methods.py
@@ -17,8 +17,6 @@
from yt.analysis_modules.halo_finding.halo_objects import \
FOFHaloFinder, HOPHaloFinder
-from yt.frontends.halo_catalog.data_structures import \
- HaloCatalogDataset
from yt.frontends.stream.data_structures import \
load_particles
from yt.units.dimensions import length
diff -r 57abf679467c2b46098177a6662cc507c173395b -r 117fbc0f03de4a8d2486ce210da1cacd44f6f77c yt/analysis_modules/halo_analysis/tests/test_halo_finders.py
--- a/yt/analysis_modules/halo_analysis/tests/test_halo_finders.py
+++ b/yt/analysis_modules/halo_analysis/tests/test_halo_finders.py
@@ -1,10 +1,7 @@
import os
import sys
-from yt.analysis_modules.halo_analysis.api import \
- HaloCatalog
from yt.convenience import load
-from yt.testing import *
from yt.utilities.answer_testing.framework import \
FieldValuesTest, \
requires_ds
https://bitbucket.org/yt_analysis/yt/commits/f2b02a0f2bc2/
Changeset: f2b02a0f2bc2
Branch: yt
User: ngoldbaum
Date: 2015-08-10 20:06:01+00:00
Summary: linting the absorption spectrum analysis module
Affected #: 2 files
diff -r 117fbc0f03de4a8d2486ce210da1cacd44f6f77c -r f2b02a0f2bc287060a75cf9a9062aab0478c598a yt/analysis_modules/absorption_spectrum/absorption_line.py
--- a/yt/analysis_modules/absorption_spectrum/absorption_line.py
+++ b/yt/analysis_modules/absorption_spectrum/absorption_line.py
@@ -70,15 +70,6 @@
x = np.asarray(u).astype(np.float64)
y = np.asarray(a).astype(np.float64)
- w = np.array([0.462243670, 0.286675505, 0.109017206,
- 0.0248105209, 0.00324377334, 0.000228338636,
- 7.80255648e-6, 1.08606937e-7, 4.39934099e-10,
- 2.22939365e-13])
-
- t = np.array([0.245340708, 0.737473729, 1.23407622, 1.73853771,
- 2.25497400, 2.78880606, 3.34785457, 3.94476404,
- 4.60368245, 5.38748089])
-
# Hummer's Chebyshev Coefficients
c = ( 0.1999999999972224, -0.1840000000029998, 0.1558399999965025,
-0.1216640000043988, 0.0877081599940391, -0.0585141248086907,
@@ -195,7 +186,6 @@
## conversions
nu1 = speed_of_light_cgs / lam1 # line freq in Hz
nudop = v_doppler / speed_of_light_cgs * nu1 # doppler width in Hz
- lamdop = v_doppler / speed_of_light_cgs * lam1 # doppler width in Ang
## create wavelength
if lambda_bins is None:
diff -r 117fbc0f03de4a8d2486ce210da1cacd44f6f77c -r f2b02a0f2bc287060a75cf9a9062aab0478c598a yt/analysis_modules/absorption_spectrum/absorption_spectrum_fit.py
--- a/yt/analysis_modules/absorption_spectrum/absorption_spectrum_fit.py
+++ b/yt/analysis_modules/absorption_spectrum/absorption_spectrum_fit.py
@@ -141,7 +141,7 @@
if flag and species=='lya' and min(yDatBounded)<.1:
newLinesP=_large_flag_fit(xBounded,yDatBounded,
yFitBounded,z,speciesDict,
- minSize,minError)
+ fitLim,minError)
if np.size(newLinesP)> 0:
@@ -226,7 +226,7 @@
"""
#Setup initial line guesses
- if initP==None: #Regular fit
+ if initP is None: #Regular fit
initP = [0,0,0]
if min(yDat)<.01: #Large lines get larger initial guess
initP[0] = speciesDict['init_N']*10**2
@@ -252,7 +252,7 @@
#Values to proceed through first run
errSq,prevErrSq,prevLinesP=1,10*len(x),[]
- if errBound == None:
+ if errBound is None:
errBound = len(yDat)*(max(1-yDat)*1E-2)**2
else:
errBound = errBound*len(yDat)
@@ -548,7 +548,7 @@
lb = _get_bounds(p[2],b,wl,x0,xRes)
xb,yb=x[lb[0]:lb[1]],y[lb[0]:lb[1]]
- if errBound == None:
+ if errBound is None:
errBound = 10*len(yb)*(max(1-yb)*1E-2)**2
else:
errBound = 10*errBound*len(yb)
https://bitbucket.org/yt_analysis/yt/commits/af8b88aaf3fa/
Changeset: af8b88aaf3fa
Branch: yt
User: ngoldbaum
Date: 2015-08-10 20:14:12+00:00
Summary: linting the cosmological_observation analysis module
Affected #: 5 files
diff -r f2b02a0f2bc287060a75cf9a9062aab0478c598a -r af8b88aaf3fa6e5e9e8326dd226459ccd022e00c yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
--- a/yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
+++ b/yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
@@ -24,8 +24,6 @@
CosmologySplice
from yt.convenience import \
load
-from yt.utilities.cosmology import \
- Cosmology
from yt.utilities.parallel_tools.parallel_analysis_interface import \
parallel_objects, \
parallel_root_only
diff -r f2b02a0f2bc287060a75cf9a9062aab0478c598a -r af8b88aaf3fa6e5e9e8326dd226459ccd022e00c yt/analysis_modules/cosmological_observation/light_cone/setup.py
--- a/yt/analysis_modules/cosmological_observation/light_cone/setup.py
+++ b/yt/analysis_modules/cosmological_observation/light_cone/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r f2b02a0f2bc287060a75cf9a9062aab0478c598a -r af8b88aaf3fa6e5e9e8326dd226459ccd022e00c yt/analysis_modules/cosmological_observation/light_ray/light_ray.py
--- a/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py
+++ b/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py
@@ -13,7 +13,6 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-import copy
import h5py
import numpy as np
diff -r f2b02a0f2bc287060a75cf9a9062aab0478c598a -r af8b88aaf3fa6e5e9e8326dd226459ccd022e00c yt/analysis_modules/cosmological_observation/light_ray/setup.py
--- a/yt/analysis_modules/cosmological_observation/light_ray/setup.py
+++ b/yt/analysis_modules/cosmological_observation/light_ray/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r f2b02a0f2bc287060a75cf9a9062aab0478c598a -r af8b88aaf3fa6e5e9e8326dd226459ccd022e00c yt/analysis_modules/cosmological_observation/setup.py
--- a/yt/analysis_modules/cosmological_observation/setup.py
+++ b/yt/analysis_modules/cosmological_observation/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
https://bitbucket.org/yt_analysis/yt/commits/dd662fe66066/
Changeset: dd662fe66066
Branch: yt
User: ngoldbaum
Date: 2015-08-10 20:28:05+00:00
Summary: linting the halo_finding analysis module
Affected #: 6 files
diff -r af8b88aaf3fa6e5e9e8326dd226459ccd022e00c -r dd662fe660662e5625089a7205c55de2f68013b7 yt/analysis_modules/halo_finding/fof/setup.py
--- a/yt/analysis_modules/halo_finding/fof/setup.py
+++ b/yt/analysis_modules/halo_finding/fof/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r af8b88aaf3fa6e5e9e8326dd226459ccd022e00c -r dd662fe660662e5625089a7205c55de2f68013b7 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
@@ -17,21 +17,15 @@
import h5py
import math
import numpy as np
-import random
-import sys
import glob
import os
import os.path as path
from functools import cmp_to_key
-from collections import defaultdict
from yt.extern.six import add_metaclass
from yt.extern.six.moves import zip as izip
from yt.config import ytcfg
from yt.funcs import mylog, ensure_dir_exists
-from yt.utilities.performance_counters import \
- time_function, \
- yt_counters
from yt.utilities.math_utils import \
get_rotation_matrix, \
periodic_dist
@@ -39,7 +33,7 @@
mass_sun_cgs, \
TINY
from yt.utilities.physical_ratios import \
- rho_crit_g_cm3_h2
+ rho_crit_g_cm3_h2
from .hop.EnzoHop import RunHOP
from .fof.EnzoFOF import RunFOF
@@ -282,7 +276,7 @@
return r.max()
def __getitem__(self, key):
- if ytcfg.getboolean("yt", "inline") == False:
+ if ytcfg.getboolean("yt", "inline") is False:
return self.data[key][self.indices]
else:
return self.data[key][self.indices]
@@ -339,8 +333,6 @@
if ('io','creation_time') in self.data.ds.field_list:
handle.create_dataset("/%s/creation_time" % gn,
data=self['creation_time'])
- n = handle["/%s" % gn]
- # set attributes on n
self._processing = False
def virial_mass(self, virial_overdensity=200., bins=300):
@@ -419,7 +411,7 @@
"""
self.virial_info(bins=bins)
over = (self.overdensity > virial_overdensity)
- if (over == True).any():
+ if (over is True).any():
vir_bin = max(np.arange(bins + 1)[over])
return vir_bin
else:
@@ -1233,7 +1225,6 @@
fglob = path.join(basedir, 'halos_%d.*.bin' % n)
files = glob.glob(fglob)
halos = self._get_halos_binary(files)
- Jc = 1.0
length = 1.0 / ds['Mpchcm']
conv = dict(pos = np.array([length, length, length,
1, 1, 1]), # to unitary
diff -r af8b88aaf3fa6e5e9e8326dd226459ccd022e00c -r dd662fe660662e5625089a7205c55de2f68013b7 yt/analysis_modules/halo_finding/hop/setup.py
--- a/yt/analysis_modules/halo_finding/hop/setup.py
+++ b/yt/analysis_modules/halo_finding/hop/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r af8b88aaf3fa6e5e9e8326dd226459ccd022e00c -r dd662fe660662e5625089a7205c55de2f68013b7 yt/analysis_modules/halo_finding/rockstar/rockstar.py
--- a/yt/analysis_modules/halo_finding/rockstar/rockstar.py
+++ b/yt/analysis_modules/halo_finding/rockstar/rockstar.py
@@ -16,23 +16,21 @@
from yt.config import ytcfg
from yt.data_objects.time_series import \
- DatasetSeries
+ DatasetSeries
from yt.funcs import \
- is_root
+ is_root, mylog
from yt.utilities.parallel_tools.parallel_analysis_interface import \
- ParallelAnalysisInterface, ProcessorPool, Communicator
-from yt.analysis_modules.halo_finding.halo_objects import * #Halos & HaloLists
+ ParallelAnalysisInterface, ProcessorPool
+from yt.analysis_modules.halo_finding.halo_objects import \
+ RockstarHaloList
from yt.utilities.exceptions import YTRockstarMultiMassNotSupported
from . import rockstar_interface
import socket
import time
-import threading
-import signal
import os
-from os import environ
-from os import mkdir
+import numpy as np
from os import path
class InlineRunner(ParallelAnalysisInterface):
@@ -202,7 +200,7 @@
mylog.info("http://adsabs.harvard.edu/abs/2013ApJ...762..109B")
ParallelAnalysisInterface.__init__(self)
# Decide how we're working.
- if ytcfg.getboolean("yt", "inline") == True:
+ if ytcfg.getboolean("yt", "inline") is True:
self.runner = InlineRunner()
else:
self.runner = StandardRunner(num_readers, num_writers)
@@ -247,8 +245,6 @@
dd = tds.all_data()
# Get DM particle mass.
- all_fields = set(tds.derived_field_list + tds.field_list)
- has_particle_type = ("particle_type" in all_fields)
particle_mass = self.particle_mass
if particle_mass is None:
diff -r af8b88aaf3fa6e5e9e8326dd226459ccd022e00c -r dd662fe660662e5625089a7205c55de2f68013b7 yt/analysis_modules/halo_finding/rockstar/setup.py
--- a/yt/analysis_modules/halo_finding/rockstar/setup.py
+++ b/yt/analysis_modules/halo_finding/rockstar/setup.py
@@ -1,9 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
-import setuptools
-import os, sys, os.path
-
import os.path
+import sys
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
diff -r af8b88aaf3fa6e5e9e8326dd226459ccd022e00c -r dd662fe660662e5625089a7205c55de2f68013b7 yt/analysis_modules/halo_finding/tests/test_rockstar.py
--- a/yt/analysis_modules/halo_finding/tests/test_rockstar.py
+++ b/yt/analysis_modules/halo_finding/tests/test_rockstar.py
@@ -2,7 +2,6 @@
import sys
from yt.convenience import load
-from yt.testing import *
from yt.utilities.answer_testing.framework import \
FieldValuesTest, \
requires_sim
https://bitbucket.org/yt_analysis/yt/commits/bb24ef2b8522/
Changeset: bb24ef2b8522
Branch: yt
User: ngoldbaum
Date: 2015-08-10 20:57:47+00:00
Summary: linting the halo_mass_function analysis module
Affected #: 2 files
diff -r dd662fe660662e5625089a7205c55de2f68013b7 -r bb24ef2b8522901f79dcb6056e8d4559996f955b yt/analysis_modules/halo_mass_function/halo_mass_function.py
--- a/yt/analysis_modules/halo_mass_function/halo_mass_function.py
+++ b/yt/analysis_modules/halo_mass_function/halo_mass_function.py
@@ -14,7 +14,7 @@
#-----------------------------------------------------------------------------
import numpy as np
-import math, time
+import math
from yt.funcs import mylog
from yt.units.yt_array import \
@@ -184,7 +184,7 @@
if log_mass_max is None:
self.log_mass_max = 16
# If we're making the analytic function...
- if self.make_analytic == True:
+ if self.make_analytic is True:
# Try to set cosmological parameters from the simulation dataset
if simulation_ds is not None:
self.omega_matter0 = self.simulation_ds.omega_matter
@@ -623,27 +623,27 @@
many times as you want. */
/* TFmdm_set_cosm() -- User passes all the cosmological parameters as
- arguments; the routine sets up all of the scalar quantites needed
- computation of the fitting formula. The input parameters are:
- 1) omega_matter -- Density of CDM, baryons, and massive neutrinos,
- in units of the critical density.
- 2) omega_baryon -- Density of baryons, in units of critical.
- 3) omega_hdm -- Density of massive neutrinos, in units of critical
- 4) degen_hdm -- (Int) Number of degenerate massive neutrino species
- 5) omega_lambda -- Cosmological constant
- 6) hubble -- Hubble constant, in units of 100 km/s/Mpc
- 7) redshift -- The redshift at which to evaluate */
+ arguments; the routine sets up all of the scalar quantites needed
+ computation of the fitting formula. The input parameters are:
+ 1) omega_matter -- Density of CDM, baryons, and massive neutrinos,
+ in units of the critical density.
+ 2) omega_baryon -- Density of baryons, in units of critical.
+ 3) omega_hdm -- Density of massive neutrinos, in units of critical
+ 4) degen_hdm -- (Int) Number of degenerate massive neutrino species
+ 5) omega_lambda -- Cosmological constant
+ 6) hubble -- Hubble constant, in units of 100 km/s/Mpc
+ 7) redshift -- The redshift at which to evaluate */
/* TFmdm_onek_mpc() -- User passes a single wavenumber, in units of Mpc^-1.
- Routine returns the transfer function from the Eisenstein & Hu
- fitting formula, based on the cosmology currently held in the
- internal variables. The routine returns T_cb (the CDM+Baryon
- density-weighted transfer function), although T_cbn (the CDM+
- Baryon+Neutrino density-weighted transfer function) is stored
- in the global variable tf_cbnu. */
+ Routine returns the transfer function from the Eisenstein & Hu
+ fitting formula, based on the cosmology currently held in the
+ internal variables. The routine returns T_cb (the CDM+Baryon
+ density-weighted transfer function), although T_cbn (the CDM+
+ Baryon+Neutrino density-weighted transfer function) is stored
+ in the global variable tf_cbnu. */
/* We also supply TFmdm_onek_hmpc(), which is identical to the previous
- routine, but takes the wavenumber in units of h Mpc^-1. */
+ routine, but takes the wavenumber in units of h Mpc^-1. */
/* We hold the internal scalar quantities in global variables, so that
the user may access them in an external program, via "extern" declarations. */
@@ -667,7 +667,7 @@
sets many global variables for use in TFmdm_onek_mpc() */
"""
def __init__(self, omega_matter, omega_baryon, omega_hdm,
- degen_hdm, omega_lambda, hubble, redshift):
+ degen_hdm, omega_lambda, hubble, redshift):
self.qwarn = 0;
self.theta_cmb = 2.728/2.7 # Assuming T_cmb = 2.728 K
diff -r dd662fe660662e5625089a7205c55de2f68013b7 -r bb24ef2b8522901f79dcb6056e8d4559996f955b yt/analysis_modules/halo_mass_function/setup.py
--- a/yt/analysis_modules/halo_mass_function/setup.py
+++ b/yt/analysis_modules/halo_mass_function/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
https://bitbucket.org/yt_analysis/yt/commits/fad7140bdb43/
Changeset: fad7140bdb43
Branch: yt
User: ngoldbaum
Date: 2015-08-10 21:16:36+00:00
Summary: linting the level_sets analysis module
Affected #: 5 files
diff -r bb24ef2b8522901f79dcb6056e8d4559996f955b -r fad7140bdb43a8484849dd31baf2159810c90887 yt/analysis_modules/level_sets/clump_handling.py
--- a/yt/analysis_modules/level_sets/clump_handling.py
+++ b/yt/analysis_modules/level_sets/clump_handling.py
@@ -19,7 +19,7 @@
from yt.fields.derived_field import \
ValidateSpatial
-from yt.funcs import mylog
+from yt.funcs import mylog, iterable
from yt.extern.six import string_types
from .clump_info_items import \
diff -r bb24ef2b8522901f79dcb6056e8d4559996f955b -r fad7140bdb43a8484849dd31baf2159810c90887 yt/analysis_modules/level_sets/clump_tools.py
--- a/yt/analysis_modules/level_sets/clump_tools.py
+++ b/yt/analysis_modules/level_sets/clump_tools.py
@@ -28,9 +28,9 @@
counter += 1
list.append(clump)
clump.level = level
- if clump.children != None:
+ if clump.children is not None:
for child in clump.children:
- x = recursive_all_clumps(child,list,level+1,clump.number)
+ recursive_all_clumps(child,list,level+1,clump.number)
return list
def return_all_clumps(clump):
@@ -64,8 +64,6 @@
Recursive. Prints the level and the number of cores to the screen."""
global counter
- if dbg > 0:
- print(tabs(level), "l =",level, "n_core",counter)
if ((clump.children is None) or (len(clump.children) == 0)):
counter += 1
diff -r bb24ef2b8522901f79dcb6056e8d4559996f955b -r fad7140bdb43a8484849dd31baf2159810c90887 yt/analysis_modules/level_sets/clump_validators.py
--- a/yt/analysis_modules/level_sets/clump_validators.py
+++ b/yt/analysis_modules/level_sets/clump_validators.py
@@ -13,8 +13,6 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-import numpy as np
-
from yt.utilities.data_point_utilities import FindBindingEnergy
from yt.utilities.operator_registry import \
OperatorRegistry
diff -r bb24ef2b8522901f79dcb6056e8d4559996f955b -r fad7140bdb43a8484849dd31baf2159810c90887 yt/analysis_modules/level_sets/contour_finder.py
--- a/yt/analysis_modules/level_sets/contour_finder.py
+++ b/yt/analysis_modules/level_sets/contour_finder.py
@@ -13,11 +13,11 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from itertools import chain
import numpy as np
-from yt.funcs import *
-import yt.utilities.data_point_utilities as data_point_utilities
+from collections import defaultdict
+
+from yt.funcs import mylog, get_pbar
from yt.utilities.lib.ContourFinding import \
ContourTree, TileContourTree, link_node_contours, \
update_joins
@@ -32,7 +32,6 @@
contours = {}
node_ids = []
DLE = data_source.ds.domain_left_edge
- selector = getattr(data_source, "base_object", data_source).selector
masks = dict((g.id, m) for g, m in data_source.blocks)
for (g, node, (sl, dims, gi)) in data_source.tiles.slice_traverse():
node.node_ind = len(node_ids)
diff -r bb24ef2b8522901f79dcb6056e8d4559996f955b -r fad7140bdb43a8484849dd31baf2159810c90887 yt/analysis_modules/level_sets/setup.py
--- a/yt/analysis_modules/level_sets/setup.py
+++ b/yt/analysis_modules/level_sets/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
https://bitbucket.org/yt_analysis/yt/commits/af7194bd9cc5/
Changeset: af7194bd9cc5
Branch: yt
User: ngoldbaum
Date: 2015-08-10 21:25:17+00:00
Summary: linting the particle_trajectories analysis module
Affected #: 2 files
diff -r fad7140bdb43a8484849dd31baf2159810c90887 -r af7194bd9cc5929d0de84403822885b1b27f050e yt/analysis_modules/particle_trajectories/particle_trajectories.py
--- a/yt/analysis_modules/particle_trajectories/particle_trajectories.py
+++ b/yt/analysis_modules/particle_trajectories/particle_trajectories.py
@@ -16,7 +16,7 @@
from yt.utilities.lib.CICDeposit import CICSample_3
from yt.utilities.parallel_tools.parallel_analysis_interface import \
parallel_root_only
-from yt.funcs import *
+from yt.funcs import mylog, get_pbar
from yt.units.yt_array import array_like_field
from yt.config import ytcfg
from collections import OrderedDict
diff -r fad7140bdb43a8484849dd31baf2159810c90887 -r af7194bd9cc5929d0de84403822885b1b27f050e yt/analysis_modules/particle_trajectories/setup.py
--- a/yt/analysis_modules/particle_trajectories/setup.py
+++ b/yt/analysis_modules/particle_trajectories/setup.py
@@ -1,8 +1,5 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
+
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
https://bitbucket.org/yt_analysis/yt/commits/1826244ec03d/
Changeset: 1826244ec03d
Branch: yt
User: ngoldbaum
Date: 2015-08-10 21:35:40+00:00
Summary: linting the photon simulation analysis module
Affected #: 5 files
diff -r af7194bd9cc5929d0de84403822885b1b27f050e -r 1826244ec03d9861b43f94d9518649947e9b70bc yt/analysis_modules/photon_simulator/photon_models.py
--- a/yt/analysis_modules/photon_simulator/photon_models.py
+++ b/yt/analysis_modules/photon_simulator/photon_models.py
@@ -24,7 +24,8 @@
from yt.extern.six import string_types
import numpy as np
-from yt.funcs import *
+from yt.funcs import mylog, get_pbar
+from yt.units.yt_array import YTArray
from yt.utilities.physical_constants import mp
from yt.utilities.parallel_tools.parallel_analysis_interface import \
parallel_objects
diff -r af7194bd9cc5929d0de84403822885b1b27f050e -r 1826244ec03d9861b43f94d9518649947e9b70bc 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
@@ -26,14 +26,15 @@
#-----------------------------------------------------------------------------
from yt.extern.six import string_types
import numpy as np
-from yt.funcs import *
+from yt.funcs import \
+ mylog, get_pbar, iterable, ensure_list
from yt.utilities.physical_constants import clight
from yt.utilities.cosmology import Cosmology
from yt.utilities.orientation import Orientation
from yt.utilities.fits_image import assert_same_wcs
from yt.utilities.parallel_tools.parallel_analysis_interface import \
- communication_system, parallel_root_only, get_mpi_type, \
- parallel_capable
+ communication_system, parallel_root_only, get_mpi_type, \
+ parallel_capable
from yt.units.yt_array import YTQuantity, YTArray, uconcatenate
import h5py
from yt.utilities.on_demand_imports import _astropy
diff -r af7194bd9cc5929d0de84403822885b1b27f050e -r 1826244ec03d9861b43f94d9518649947e9b70bc yt/analysis_modules/photon_simulator/setup.py
--- a/yt/analysis_modules/photon_simulator/setup.py
+++ b/yt/analysis_modules/photon_simulator/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r af7194bd9cc5929d0de84403822885b1b27f050e -r 1826244ec03d9861b43f94d9518649947e9b70bc yt/analysis_modules/photon_simulator/spectral_models.py
--- a/yt/analysis_modules/photon_simulator/spectral_models.py
+++ b/yt/analysis_modules/photon_simulator/spectral_models.py
@@ -11,11 +11,12 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import h5py
import numpy as np
import os
-from yt.funcs import *
-from yt.units.yt_array import YTQuantity
-import h5py
+
+from yt.funcs import mylog
+from yt.units.yt_array import YTArray, YTQuantity
from yt.utilities.on_demand_imports import _astropy, _scipy
from yt.utilities.physical_constants import hcgs, clight, erg_per_keV, amu_cgs
diff -r af7194bd9cc5929d0de84403822885b1b27f050e -r 1826244ec03d9861b43f94d9518649947e9b70bc yt/analysis_modules/photon_simulator/tests/test_cluster.py
--- a/yt/analysis_modules/photon_simulator/tests/test_cluster.py
+++ b/yt/analysis_modules/photon_simulator/tests/test_cluster.py
@@ -10,11 +10,13 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from yt.testing import *
+from yt.analysis_modules.photon_simulator.api import \
+ TableApecModel, TableAbsorbModel, \
+ ThermalPhotonModel, PhotonList
from yt.config import ytcfg
-from yt.analysis_modules.photon_simulator.api import *
+from yt.testing import requires_file
from yt.utilities.answer_testing.framework import requires_ds, \
- GenericArrayTest, data_dir_load
+ GenericArrayTest, data_dir_load
import numpy as np
def setup():
https://bitbucket.org/yt_analysis/yt/commits/e1592a4064f9/
Changeset: e1592a4064f9
Branch: yt
User: ngoldbaum
Date: 2015-08-10 21:36:44+00:00
Summary: linting the PPV cube analysis module
Affected #: 2 files
diff -r 1826244ec03d9861b43f94d9518649947e9b70bc -r e1592a4064f97cdb3bca7573c3c627d5c5baf356 yt/analysis_modules/ppv_cube/setup.py
--- a/yt/analysis_modules/ppv_cube/setup.py
+++ b/yt/analysis_modules/ppv_cube/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r 1826244ec03d9861b43f94d9518649947e9b70bc -r e1592a4064f97cdb3bca7573c3c627d5c5baf356 yt/analysis_modules/ppv_cube/tests/test_ppv.py
--- a/yt/analysis_modules/ppv_cube/tests/test_ppv.py
+++ b/yt/analysis_modules/ppv_cube/tests/test_ppv.py
@@ -15,7 +15,7 @@
import yt.units as u
from yt.utilities.physical_constants import kboltz, mh, clight
import numpy as np
-from yt.testing import *
+from yt.testing import assert_allclose
def setup():
"""Test specific setup."""
https://bitbucket.org/yt_analysis/yt/commits/64e4b2138372/
Changeset: 64e4b2138372
Branch: yt
User: ngoldbaum
Date: 2015-08-10 21:38:19+00:00
Summary: linting radmc3d exporter
Affected #: 1 file
diff -r e1592a4064f97cdb3bca7573c3c627d5c5baf356 -r 64e4b213837243e3e89c6d3e126bf493861f0763 yt/analysis_modules/radmc3d_export/tests/test_radmc3d_exporter.py
--- a/yt/analysis_modules/radmc3d_export/tests/test_radmc3d_exporter.py
+++ b/yt/analysis_modules/radmc3d_export/tests/test_radmc3d_exporter.py
@@ -11,13 +11,13 @@
#-----------------------------------------------------------------------------
import yt
-from yt.testing import *
+from yt.testing import assert_allclose
from yt.analysis_modules.radmc3d_export.api import RadMC3DWriter
from yt.utilities.answer_testing.framework import \
AnswerTestingTest, \
requires_ds
-from yt.config import ytcfg
import tempfile
+import numpy as np
import os
import shutil
https://bitbucket.org/yt_analysis/yt/commits/19ad53fb0efa/
Changeset: 19ad53fb0efa
Branch: yt
User: ngoldbaum
Date: 2015-08-10 21:39:01+00:00
Summary: linting spectral_integrator analysis module
Affected #: 1 file
diff -r 64e4b213837243e3e89c6d3e126bf493861f0763 -r 19ad53fb0efa27a7246730818b43e2c607bd30ad yt/analysis_modules/spectral_integrator/setup.py
--- a/yt/analysis_modules/spectral_integrator/setup.py
+++ b/yt/analysis_modules/spectral_integrator/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
https://bitbucket.org/yt_analysis/yt/commits/c8816ed5efa7/
Changeset: c8816ed5efa7
Branch: yt
User: ngoldbaum
Date: 2015-08-10 21:40:16+00:00
Summary: linting the star_analysis analysis module
Affected #: 2 files
diff -r 19ad53fb0efa27a7246730818b43e2c607bd30ad -r c8816ed5efa7e7b15237b10dfa9d2f3f164cf24e yt/analysis_modules/star_analysis/setup.py
--- a/yt/analysis_modules/star_analysis/setup.py
+++ b/yt/analysis_modules/star_analysis/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r 19ad53fb0efa27a7246730818b43e2c607bd30ad -r c8816ed5efa7e7b15237b10dfa9d2f3f164cf24e yt/analysis_modules/star_analysis/sfr_spectrum.py
--- a/yt/analysis_modules/star_analysis/sfr_spectrum.py
+++ b/yt/analysis_modules/star_analysis/sfr_spectrum.py
@@ -18,7 +18,6 @@
import numpy as np
import h5py
import math
-import itertools
from yt.config import ytcfg
from yt.extern.six.moves import zip as izip
https://bitbucket.org/yt_analysis/yt/commits/8571ef961193/
Changeset: 8571ef961193
Branch: yt
User: ngoldbaum
Date: 2015-08-10 21:53:46+00:00
Summary: Linting the sunrise exporter
Affected #: 1 file
diff -r c8816ed5efa7e7b15237b10dfa9d2f3f164cf24e -r 8571ef96119336599ac26c2f0f85b758d7b895f7 yt/analysis_modules/sunrise_export/sunrise_exporter.py
--- a/yt/analysis_modules/sunrise_export/sunrise_exporter.py
+++ b/yt/analysis_modules/sunrise_export/sunrise_exporter.py
@@ -19,14 +19,17 @@
except ImportError:
pass
+import os
import time
import numpy as np
-from yt.funcs import *
+
import yt.utilities.lib.api as amr_utils
+
+from yt import add_field
+from yt.funcs import get_pbar, mylog
from yt.utilities.physical_constants import \
kpc_per_cm, \
sec_per_year
-from yt.mods import *
def export_to_sunrise(ds, fn, star_particle_type, fc, fwidth, ncells_wide=None,
debug=False,dd=None,**kwargs):
@@ -492,7 +495,7 @@
idxst = dd["particle_type"] == star_type
#make sure we select more than a single particle
- assert na.sum(idxst)>0
+ assert np.sum(idxst)>0
if pos is None:
pos = np.array([dd["particle_position_%s" % ax]
for ax in 'xyz']).transpose()
@@ -543,7 +546,7 @@
#make sure we have nonzero particle number
assert pd_table.data.shape[0]>0
- return pd_table,na.sum(idx)
+ return pd_table,np.sum(idx)
def add_fields():
@@ -559,12 +562,8 @@
# SFR in a cell. This assumes stars were created by the Cen & Ostriker algorithm
# Check Grid_AddToDiskProfile.C and star_maker7.src
star_mass_ejection_fraction = data.ds.get_parameter("StarMassEjectionFraction",float)
- star_maker_minimum_dynamical_time = 3e6 # years, which will get divided out
- dtForSFR = star_maker_minimum_dynamical_time / data.ds["years"]
xv1 = ((data.ds["InitialTime"] - data["creation_time"])
/ data["dynamical_time"])
- xv2 = ((data.ds["InitialTime"] + dtForSFR - data["creation_time"])
- / data["dynamical_time"])
denom = (1.0 - star_mass_ejection_fraction * (1.0 - (1.0 + xv1)*np.exp(-xv1)))
minitial = data["ParticleMassMsun"] / denom
return minitial
https://bitbucket.org/yt_analysis/yt/commits/79854fc3a53b/
Changeset: 79854fc3a53b
Branch: yt
User: ngoldbaum
Date: 2015-08-10 21:47:37+00:00
Summary: Linting the SZ analysis module
Affected #: 2 files
diff -r 8571ef96119336599ac26c2f0f85b758d7b895f7 -r 79854fc3a53b382f0beb9afec703539ca251bacc yt/analysis_modules/sunyaev_zeldovich/setup.py
--- a/yt/analysis_modules/sunyaev_zeldovich/setup.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r 8571ef96119336599ac26c2f0f85b758d7b895f7 -r 79854fc3a53b382f0beb9afec703539ca251bacc yt/analysis_modules/sunyaev_zeldovich/tests/test_projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/tests/test_projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/tests/test_projection.py
@@ -11,12 +11,12 @@
#-----------------------------------------------------------------------------
from yt.frontends.stream.api import load_uniform_grid
-from yt.funcs import get_pbar, mylog
+from yt.funcs import get_pbar
from yt.utilities.physical_constants import cm_per_kpc, K_per_keV, \
- mh, cm_per_km, kboltz, Tcmb, hcgs, clight, sigma_thompson
-from yt.testing import *
+ mh, cm_per_km, kboltz, Tcmb, hcgs, clight, sigma_thompson
+from yt.testing import requires_module, assert_almost_equal
from yt.utilities.answer_testing.framework import requires_ds, \
- GenericArrayTest, data_dir_load, GenericImageTest
+ GenericArrayTest, data_dir_load, GenericImageTest
try:
from yt.analysis_modules.sunyaev_zeldovich.projection import SZProjection, I0
except ImportError:
https://bitbucket.org/yt_analysis/yt/commits/7d00e1971649/
Changeset: 7d00e1971649
Branch: yt
User: ngoldbaum
Date: 2015-08-10 21:54:57+00:00
Summary: linting the two point functions analysis module
Affected #: 2 files
diff -r 79854fc3a53b382f0beb9afec703539ca251bacc -r 7d00e197164941c7b1276eec40c8e0602a461184 yt/analysis_modules/two_point_functions/setup.py
--- a/yt/analysis_modules/two_point_functions/setup.py
+++ b/yt/analysis_modules/two_point_functions/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r 79854fc3a53b382f0beb9afec703539ca251bacc -r 7d00e197164941c7b1276eec40c8e0602a461184 yt/analysis_modules/two_point_functions/two_point_functions.py
--- a/yt/analysis_modules/two_point_functions/two_point_functions.py
+++ b/yt/analysis_modules/two_point_functions/two_point_functions.py
@@ -14,17 +14,19 @@
#-----------------------------------------------------------------------------
import h5py
-from yt.mods import *
-#from yt.utilities.math_utils import *
-from yt.utilities.performance_counters import yt_counters, time_function
+import numpy as np
+
+from yt.funcs import mylog
+from yt.utilities.performance_counters import yt_counters
from yt.utilities.parallel_tools.parallel_analysis_interface import ParallelAnalysisInterface, parallel_blocking_call, parallel_root_only
try:
- from yt.utilities.kdtree.api import *
+ from yt.utilities.kdtree.api import \
+ fKD, free_tree, create_tree
except ImportError:
mylog.debug("The Fortran kD-Tree did not import correctly.")
-import math, sys, itertools, inspect, types, time
+import math, inspect, time
from collections import defaultdict
sep = 12
@@ -117,7 +119,7 @@
self.index = ds.index
self.center = (ds.domain_right_edge + ds.domain_left_edge)/2.0
# Figure out the range of ruler lengths.
- if length_range == None:
+ if length_range is None:
length_range = [math.sqrt(3) * self.ds.index.get_smallest_dx(),
self.min_edge/2.]
else:
@@ -679,7 +681,7 @@
"""
for fset in self._fsets:
# Only operate on correlation functions.
- if fset.corr_norm == None: continue
+ if fset.corr_norm is None: continue
fp = self.comm.write_on_root("%s_correlation.txt" % fset.function.__name__)
line = "# length".ljust(sep)
line += "\\xi".ljust(sep)
https://bitbucket.org/yt_analysis/yt/commits/a66fc9adc574/
Changeset: a66fc9adc574
Branch: yt
User: ngoldbaum
Date: 2015-08-10 21:55:18+00:00
Summary: Linting the top-level analysis modules module
Affected #: 2 files
diff -r 7d00e197164941c7b1276eec40c8e0602a461184 -r a66fc9adc5744cf4eac5bccb5d9b8415e742fd55 yt/analysis_modules/list_modules.py
--- a/yt/analysis_modules/list_modules.py
+++ b/yt/analysis_modules/list_modules.py
@@ -33,7 +33,7 @@
def __getattr__(self, attr):
try:
name = "yt.analysis_modules.%s.api" % (attr)
- nm = __import__(name, level=-1)
+ __import__(name, level=-1)
setattr(self, attr, sys.modules[name])
except ImportError:
raise AttributeError(attr)
diff -r 7d00e197164941c7b1276eec40c8e0602a461184 -r a66fc9adc5744cf4eac5bccb5d9b8415e742fd55 yt/analysis_modules/setup.py
--- a/yt/analysis_modules/setup.py
+++ b/yt/analysis_modules/setup.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
-import sys
+
+
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('analysis_modules', parent_package, top_path)
https://bitbucket.org/yt_analysis/yt/commits/9f108179d004/
Changeset: 9f108179d004
Branch: yt
User: ngoldbaum
Date: 2015-08-10 21:59:32+00:00
Summary: Adding a number of new flake8 rules to setup.cfg.
These rules were chosen to be ignored if they only affect code style and do not
have any functional implications. I'm using an explicit list of rules to ignore
in the hope that one day we can remove some or all these rules one by one.
Affected #: 1 file
diff -r a66fc9adc5744cf4eac5bccb5d9b8415e742fd55 -r 9f108179d00449329d98984c52c0daa046d877b4 setup.cfg
--- a/setup.cfg
+++ b/setup.cfg
@@ -7,3 +7,9 @@
where=yt
exclude=answer_testing
with-xunit=1
+
+[flake8]
+# if we include api.py files, we get tons of spurious "imported but unused" errors
+exclude = */api.py,*/__config__.py
+max-line-length=160
+ignore = E111,E121,E122,E125,E126,E127,E128,E129,E131,E201,E202,E211,E221,E222,E228,E241,E301,E203,E225,E226,E231,E251,E261,E262,E265,E302,E303,E401,E502,E701,E703,W291,W293,W391
\ No newline at end of file
https://bitbucket.org/yt_analysis/yt/commits/447d1fcc8147/
Changeset: 447d1fcc8147
Branch: yt
User: ngoldbaum
Date: 2015-08-11 03:00:13+00:00
Summary: Don't unnecessarily compare a boolean array with True
Affected #: 1 file
diff -r 9f108179d00449329d98984c52c0daa046d877b4 -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 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
@@ -411,7 +411,7 @@
"""
self.virial_info(bins=bins)
over = (self.overdensity > virial_overdensity)
- if (over is True).any():
+ if over.any():
vir_bin = max(np.arange(bins + 1)[over])
return vir_bin
else:
https://bitbucket.org/yt_analysis/yt/commits/c20aab1a920d/
Changeset: c20aab1a920d
Branch: yt
User: ngoldbaum
Date: 2015-08-17 14:52:51+00:00
Summary: Merging with mainline
Affected #: 25 files
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa MANIFEST.in
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,12 +1,12 @@
-include distribute_setup.py README* CREDITS COPYING.txt CITATION
+include distribute_setup.py README* CREDITS COPYING.txt CITATION requirements.txt optional-requirements.txt
recursive-include yt/gui/reason/html *.html *.png *.ico *.js *.gif *.css
-recursive-include yt *.py *.pyx *.pxd *.h README* *.txt LICENSE*
+recursive-include yt *.py *.pyx *.pxd *.h README* *.txt LICENSE* *.cu
recursive-include doc *.rst *.txt *.py *.ipynb *.png *.jpg *.css *.inc *.html
recursive-include doc *.h *.c *.sh *.svgz *.pdf *.svg *.pyx
include doc/README doc/activate doc/activate.csh doc/cheatsheet.tex
include doc/extensions/README doc/Makefile
prune doc/source/reference/api/generated
-prune doc/build/
+prune doc/build
recursive-include yt/analysis_modules/halo_finding/rockstar *.py *.pyx
prune yt/frontends/_skeleton
prune tests
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa doc/source/_templates/layout.html
--- a/doc/source/_templates/layout.html
+++ b/doc/source/_templates/layout.html
@@ -1,5 +1,10 @@
{% extends '!layout.html' %}
+{%- block linktags %}
+ <link href="http://yt-project.org/doc/{{ pagename }}.html" rel="canonical" />
+ {{ super() }}
+{%- endblock %}
+
{%- block extrahead %}
{{ super() }}
<script type="text/javascript">
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa doc/source/analyzing/parallel_computation.rst
--- a/doc/source/analyzing/parallel_computation.rst
+++ b/doc/source/analyzing/parallel_computation.rst
@@ -42,7 +42,18 @@
$ pip install mpi4py
-Once that has been installed, you're all done! You just need to launch your
+If you have an Anaconda installation of yt and there is no MPI library on the
+system you are using try:
+
+.. code-block:: bash
+
+ $ conda install mpi4py
+
+This will install `MPICH2 <https://www.mpich.org/>`_ and will interefere with
+other MPI libraries that are already installed. Therefore, it is preferable to
+use the ``pip`` installation method.
+
+Once mpi4py has been installed, you're all done! You just need to launch your
scripts with ``mpirun`` (or equivalent) and signal to yt that you want to
run them in parallel by invoking the ``yt.enable_parallelism()`` function in
your script. In general, that's all it takes to get a speed benefit on a
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa doc/source/analyzing/units/1)_Symbolic_Units.ipynb
--- a/doc/source/analyzing/units/1)_Symbolic_Units.ipynb
+++ b/doc/source/analyzing/units/1)_Symbolic_Units.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:5d881061b9e82bd9df5d3598983c8ddc5fbec35e3bf7ae4524430dc558e27489"
+ "signature": "sha256:0dbaef644354e4d0191367f8f90e6dfd0d3d527925ef0331e1ef381c9099a8cd"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -516,9 +516,147 @@
"language": "python",
"metadata": {},
"outputs": []
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Saving and Loading `YTArray`s to/from disk"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "`YTArray`s can be written to disk, to be loaded again to be used in yt or in a different context later. There are two formats that can be written to/read from: HDF5 and ASCII. \n",
+ "\n",
+ "To write to HDF5, use `write_hdf5`:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "my_dens = YTArray(np.random.random(10), 'Msun/kpc**3')\n",
+ "my_temp = YTArray(np.random.random(10), 'K')\n",
+ "my_dens.write_hdf5(\"my_data.h5\", dataset_name=\"density\")\n",
+ "my_temp.write_hdf5(\"my_data.h5\", dataset_name=\"temperature\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Where we used the `dataset_name` keyword argument to create a separate dataset for each array in the same file.\n",
+ "\n",
+ "We can use the `from_hdf5` classmethod to read the data back in:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "read_dens = YTArray.from_hdf5(\"my_data.h5\", dataset_name=\"density\")\n",
+ "print read_dens\n",
+ "print my_dens"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We can use the `info` keyword argument to `write_hdf5` to write some additional data to the file, which will be stored as attributes of the dataset:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "my_vels = YTArray(np.random.normal(10), 'km/s')\n",
+ "info = {\"source\":\"galaxy cluster\",\"user\":\"jzuhone\"}\n",
+ "my_vels.write_hdf5(\"my_data.h5\", dataset_name=\"velocity\", info=info)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To write one or more `YTArray`s to an ASCII text file, use `yt.savetxt`, which works a lot like NumPy's `savetxt`, except with units:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import yt\n",
+ "a = YTArray(np.random.random(size=10), \"cm\")\n",
+ "b = YTArray(np.random.random(size=10), \"g\")\n",
+ "c = YTArray(np.random.random(size=10), \"s\")\n",
+ "yt.savetxt(\"my_data.dat\", [a,b,c], header='My cool data', footer='Data is over', delimiter=\"\\t\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The file we wrote can then be easily used in other contexts, such as plotting in Gnuplot, or loading into a spreadsheet, or just for causal examination. We can quickly check it here:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "%%bash \n",
+ "more my_data.dat"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "You can see that the header comes first, and then right before the data we have a subheader marking the units of each column. The footer comes after the data. "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "`yt.loadtxt` can be used to read the same data with units back in, or read data that has been generated from some other source. Just make sure it's in the format above. `loadtxt` can also selectively read from particular columns in the file with the `usecols` keyword argument:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "bb, cc = yt.loadtxt(\"my_data.dat\", usecols=(1,2), delimiter=\"\\t\")\n",
+ "print bb\n",
+ "print b\n",
+ "print\n",
+ "print cc\n",
+ "print c"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
}
],
"metadata": {}
}
]
-}
+}
\ No newline at end of file
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa doc/source/index.rst
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -11,6 +11,18 @@
:ref:`sample data for each format <getting-sample-data>` with
:ref:`instructions on how to load and examine each data type <examining-data>`.
+.. raw:: html
+
+ <form action="search.html" method="get" _lpchecked="1">
+ <div class="form-group">
+ <input type="text" name="q" class="form-control" placeholder="Search" style="width: 70%">
+ </div>
+ <input type="hidden" name="check_keywords" value="yes">
+ <input type="hidden" name="area" value="default">
+ </form>
+
+
+
Table of Contents
-----------------
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa doc/source/installing.rst
--- a/doc/source/installing.rst
+++ b/doc/source/installing.rst
@@ -39,6 +39,12 @@
have the the necessary compilers installed (e.g. the ``build-essentials``
package on debian and ubuntu).
+.. note::
+ See `Parallel Computation
+ <http://yt-project.org/docs/dev/analyzing/parallel_computation.html>`_
+ for a discussion on using yt in parallel.
+
+
.. _branches-of-yt:
Branches of yt: ``yt``, ``stable``, and ``yt-2.x``
@@ -201,7 +207,8 @@
bash Miniconda-3.3.0-Linux-x86_64.sh
-Make sure that the Anaconda ``bin`` directory is in your path, and then issue:
+For both the Anaconda and Miniconda installations, make sure that the Anaconda
+``bin`` directory is in your path, and then issue:
.. code-block:: bash
@@ -209,6 +216,34 @@
which will install yt along with all of its dependencies.
+Obtaining Source Code
+^^^^^^^^^^^^^^^^^^^^^
+
+There are two ways to get the yt source code when using an Anaconda
+installation.
+
+Option 1:
+
+Clone the yt repository with:
+
+.. code-block:: bash
+
+ hg clone https://bitbucket.org/yt_analysis/yt
+
+Once inside the yt directory, update to the appropriate branch and
+run ``setup.py``. For example, the following commands will allow you
+to see the tip of the development branch.
+
+.. code-block:: bash
+
+ hg up yt
+ python setup.py develop
+
+This will make sure you are running a version of yt corresponding to the
+most up-to-date source code.
+
+Option 2:
+
Recipes to build conda packages for yt are available at
https://github.com/conda/conda-recipes. To build the yt conda recipe, first
clone the conda-recipes repository
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -103,7 +103,9 @@
YTQuantity, \
uconcatenate, \
uintersect1d, \
- uunion1d
+ uunion1d, \
+ loadtxt, \
+ savetxt
from yt.fields.api import \
field_plugins, \
@@ -169,4 +171,3 @@
# Import some helpful math utilities
from yt.utilities.math_utils import \
ortho_find, quartiles, periodic_position
-
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/analysis_modules/absorption_spectrum/tests/test_absorption_spectrum.py
--- a/yt/analysis_modules/absorption_spectrum/tests/test_absorption_spectrum.py
+++ b/yt/analysis_modules/absorption_spectrum/tests/test_absorption_spectrum.py
@@ -12,7 +12,7 @@
import numpy as np
from yt.testing import \
- assert_allclose, requires_file, requires_module
+ assert_allclose_units, requires_file, requires_module
from yt.analysis_modules.absorption_spectrum.absorption_line import \
voigt_old, voigt_scipy
from yt.analysis_modules.absorption_spectrum.api import AbsorptionSpectrum
@@ -129,4 +129,4 @@
def test_voigt_profiles():
a = 1.7e-4
x = np.linspace(5.0, -3.6, 60)
- yield assert_allclose, voigt_old(a, x), voigt_scipy(a, x), 1e-8
+ yield assert_allclose_units, voigt_old(a, x), voigt_scipy(a, x), 1e-8
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/analysis_modules/ppv_cube/tests/test_ppv.py
--- a/yt/analysis_modules/ppv_cube/tests/test_ppv.py
+++ b/yt/analysis_modules/ppv_cube/tests/test_ppv.py
@@ -46,7 +46,7 @@
a = cube.data.mean(axis=(0,1)).v
b = dv*np.exp(-((cube.vmid+v_shift)/v_th)**2)/(np.sqrt(np.pi)*v_th)
- yield assert_allclose, a, b, 1.0e-2
+ yield assert_allclose_units, a, b, 1.0e-2
E_0 = 6.8*u.keV
@@ -58,4 +58,4 @@
c = dE*np.exp(-((cube.vmid-E_shift)/delta_E)**2)/(np.sqrt(np.pi)*delta_E)
- yield assert_allclose, a, c, 1.0e-2
+ yield assert_allclose_units, a, c, 1.0e-2
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/fields/derived_field.py
--- a/yt/fields/derived_field.py
+++ b/yt/fields/derived_field.py
@@ -215,7 +215,7 @@
units = Unit(self.units)
# Add unit label
if not units.is_dimensionless:
- data_label += r"\ \ (%s)" % (units)
+ data_label += r"\ \ (%s)" % (units.latex_representation())
data_label += r"$"
return data_label
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/fields/fluid_fields.py
--- a/yt/fields/fluid_fields.py
+++ b/yt/fields/fluid_fields.py
@@ -215,7 +215,11 @@
return new_field
return func
- grad_units = "(%s) / cm" % field_units
+ if field_units != "":
+ grad_units = "(%s) / cm" % field_units
+ else:
+ grad_units = "1 / cm"
+
for axi, ax in enumerate('xyz'):
f = grad_func(axi, ax)
registry.add_field((ftype, "%s_gradient_%s" % (fname, ax)),
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -196,15 +196,23 @@
def test_add_gradient_fields():
gfields = base_ds.add_gradient_fields(("gas","density"))
+ gfields += base_ds.add_gradient_fields(("index", "ones"))
field_list = [('gas', 'density_gradient_x'),
('gas', 'density_gradient_y'),
('gas', 'density_gradient_z'),
- ('gas', 'density_gradient_magnitude')]
+ ('gas', 'density_gradient_magnitude'),
+ ('index', 'ones_gradient_x'),
+ ('index', 'ones_gradient_y'),
+ ('index', 'ones_gradient_z'),
+ ('index', 'ones_gradient_magnitude')]
assert_equal(gfields, field_list)
ad = base_ds.all_data()
for field in field_list:
ret = ad[field]
- assert str(ret.units) == "g/cm**4"
+ if field[0] == 'gas':
+ assert str(ret.units) == "g/cm**4"
+ else:
+ assert str(ret.units) == "1/cm"
def get_data(ds, field_name):
# Need to create a new data object otherwise the errors we are
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/frontends/athena/tests/test_outputs.py
--- a/yt/frontends/athena/tests/test_outputs.py
+++ b/yt/frontends/athena/tests/test_outputs.py
@@ -78,10 +78,10 @@
prj2 = ds1.proj("density",0)
yield assert_equal, sp1.quantities.extrema("pressure"), sp2.quantities.extrema("pressure")
- yield assert_allclose, sp1.quantities.total_quantity("pressure"), sp2.quantities.total_quantity("pressure")
+ yield assert_allclose_units, sp1.quantities.total_quantity("pressure"), sp2.quantities.total_quantity("pressure")
for ax in "xyz":
yield assert_equal, sp1.quantities.extrema("velocity_%s" % ax), sp2.quantities.extrema("velocity_%s" % ax)
- yield assert_allclose, sp1.quantities.bulk_velocity(), sp2.quantities.bulk_velocity()
+ yield assert_allclose_units, sp1.quantities.bulk_velocity(), sp2.quantities.bulk_velocity()
yield assert_equal, prj1["density"], prj2["density"]
ytcfg["yt","skip_dataset_cache"] = "False"
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/frontends/enzo/data_structures.py
--- a/yt/frontends/enzo/data_structures.py
+++ b/yt/frontends/enzo/data_structures.py
@@ -338,7 +338,7 @@
def _fill_arrays(self, ei, si, LE, RE, npart, nap):
self.grid_dimensions.flat[:] = ei
- self.grid_dimensions -= np.array(si, self.float_type)
+ self.grid_dimensions -= np.array(si, dtype='i4')
self.grid_dimensions += 1
self.grid_left_edge.flat[:] = LE
self.grid_right_edge.flat[:] = RE
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/frontends/enzo/fields.py
--- a/yt/frontends/enzo/fields.py
+++ b/yt/frontends/enzo/fields.py
@@ -137,7 +137,7 @@
("enzo", "%s_Density" % species))
def setup_species_fields(self):
- species_names = [fn.rsplit("_Density")[0] for ft, fn in
+ species_names = [fn.rsplit("_Density")[0] for ft, fn in
self.field_list if fn.endswith("_Density")]
species_names = [sp for sp in species_names
if sp in known_species_names]
@@ -149,6 +149,7 @@
for sp in species_names:
self.add_species_field(sp)
self.species_names.append(known_species_names[sp])
+ self.species_names.sort() # bb #1059
def setup_fluid_fields(self):
# Now we conditionally load a few other things.
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/frontends/fits/data_structures.py
--- a/yt/frontends/fits/data_structures.py
+++ b/yt/frontends/fits/data_structures.py
@@ -111,6 +111,8 @@
field_units = field_units.replace(unit, known_units[unit])
n += 1
if n != len(units): field_units = "dimensionless"
+ if field_units[0] == "/":
+ field_units = "1%s" % field_units
return field_units
except KeyError:
return "dimensionless"
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -446,7 +446,7 @@
@cython.wraparound(False)
@cython.cdivision(True)
cdef int fill_mask_selector(self, np.float64_t left_edge[3],
- np.float64_t right_edge[3],
+ np.float64_t right_edge[3],
np.float64_t dds[3], int dim[3],
np.ndarray[np.uint8_t, ndim=3, cast=True] child_mask,
np.ndarray[np.uint8_t, ndim=3] mask,
@@ -603,9 +603,12 @@
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 = 0
for v in self._hash_vals() + self._base_hash():
- hash_val ^= hash(v)
+ # FNV hash cf. http://www.isthe.com/chongo/tech/comp/fnv/index.html
+ hash_val = (hash_val * 16777619) ^ hash(v)
return hash_val
def _hash_vals(self):
@@ -1107,7 +1110,7 @@
def _hash_vals(self):
return (("norm_vec[0]", self.norm_vec[0]),
- ("norm_vec[1]", self.norm_vec[1]),
+ ("norm_vec[1]", self.norm_vec[1]),
("norm_vec[2]", self.norm_vec[2]),
("d", self.d))
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/testing.py
--- a/yt/testing.py
+++ b/yt/testing.py
@@ -751,3 +751,59 @@
finally:
os.chdir(initial_dir)
mylog.setLevel(orig_level)
+
+def assert_allclose_units(actual, desired, rtol=1e-7, atol=0, **kwargs):
+ """Raise an error if two objects are not equal up to desired tolerance
+
+ This is a wrapper for :func:`numpy.testing.assert_allclose` that also
+ verifies unit consistency
+
+ Parameters
+ ----------
+ actual : array-like
+ Array obtained (possibly with attached units)
+ desired : array-like
+ Array to compare with (possibly with attached units)
+ rtol : float, oprtional
+ Relative tolerance, defaults to 1e-7
+ atol : float or quantity, optional
+ Absolute tolerance. If units are attached, they must be consistent
+ with the units of ``actual`` and ``desired``. If no units are attached,
+ assumes the same units as ``desired``. Defaults to zero.
+
+ Also accepts additional keyword arguments accepted by
+ :func:`numpy.testing.assert_allclose`, see the documentation of that
+ function for details.
+ """
+ # Create a copy to ensure this function does not alter input arrays
+ act = YTArray(actual)
+ des = YTArray(desired)
+
+ try:
+ des = des.in_units(act.units)
+ except YTUnitOperationError:
+ raise AssertionError("Units of actual (%s) and desired (%s) do not have "
+ "equivalent dimensions" % (act.units, des.units))
+
+ rt = YTArray(rtol)
+ if not rt.units.is_dimensionless:
+ raise AssertionError("Units of rtol (%s) are not "
+ "dimensionless" % rt.units)
+
+ if not isinstance(atol, YTArray):
+ at = YTQuantity(atol, des.units)
+
+ try:
+ at = at.in_units(act.units)
+ except YTUnitOperationError:
+ raise AssertionError("Units of atol (%s) and actual (%s) do not have "
+ "equivalent dimensions" % (at.units, act.units))
+
+ # units have been validated, so we strip units before calling numpy
+ # to avoid spurious errors
+ act = act.value
+ des = des.value
+ rt = rt.value
+ at = at.value
+
+ return assert_allclose(act, des, rt, at, **kwargs)
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/units/tests/test_units.py
--- a/yt/units/tests/test_units.py
+++ b/yt/units/tests/test_units.py
@@ -18,11 +18,13 @@
import nose
import numpy as np
from numpy.testing import \
- assert_approx_equal, assert_array_almost_equal_nulp, \
- assert_allclose, assert_raises
+ assert_array_almost_equal_nulp, \
+ assert_raises
from nose.tools import assert_true
+import operator
from sympy import Symbol
-from yt.testing import fake_random_ds
+from yt.testing import \
+ fake_random_ds, assert_allclose_units
# dimensions
from yt.units.dimensions import \
@@ -30,7 +32,7 @@
# functions
from yt.units.unit_object import get_conversion_factor
# classes
-from yt.units.unit_object import Unit, UnitParseError
+from yt.units.unit_object import Unit, UnitParseError, InvalidUnitOperation
# objects
from yt.units.unit_lookup_table import \
default_unit_symbol_lut, unit_prefixes, prefixable_units
@@ -154,10 +156,10 @@
yield assert_true, u3.expr == s3
yield assert_true, u4.expr == s4
- yield assert_allclose, u1.base_value, pc_cgs, 1e-12
- yield assert_allclose, u2.base_value, yr_cgs, 1e-12
- yield assert_allclose, u3.base_value, pc_cgs * yr_cgs, 1e-12
- yield assert_allclose, u4.base_value, pc_cgs**2 / yr_cgs, 1e-12
+ yield assert_allclose_units, u1.base_value, pc_cgs, 1e-12
+ yield assert_allclose_units, u2.base_value, yr_cgs, 1e-12
+ yield assert_allclose_units, u3.base_value, pc_cgs * yr_cgs, 1e-12
+ yield assert_allclose_units, u4.base_value, pc_cgs**2 / yr_cgs, 1e-12
yield assert_true, u1.dimensions == length
yield assert_true, u2.dimensions == time
@@ -179,7 +181,7 @@
yield assert_true, u1.base_value == 1
yield assert_true, u1.dimensions == power
- yield assert_allclose, u2.base_value, km_cgs / Mpc_cgs, 1e-12
+ yield assert_allclose_units, u2.base_value, km_cgs / Mpc_cgs, 1e-12
yield assert_true, u2.dimensions == rate
def test_create_new_symbol():
@@ -323,7 +325,7 @@
u3 = u1 * u2
yield assert_true, u3.expr == msun_sym * pc_sym
- yield assert_allclose, u3.base_value, msun_cgs * pc_cgs, 1e-12
+ yield assert_allclose_units, u3.base_value, msun_cgs * pc_cgs, 1e-12
yield assert_true, u3.dimensions == mass * length
# Pow and Mul operations
@@ -333,7 +335,7 @@
u6 = u4 * u5
yield assert_true, u6.expr == pc_sym**2 * msun_sym * s_sym
- yield assert_allclose, u6.base_value, pc_cgs**2 * msun_cgs, 1e-12
+ yield assert_allclose_units, u6.base_value, pc_cgs**2 * msun_cgs, 1e-12
yield assert_true, u6.dimensions == length**2 * mass * time
@@ -357,7 +359,7 @@
u3 = u1 / u2
yield assert_true, u3.expr == pc_sym / (km_sym * s_sym)
- yield assert_allclose, u3.base_value, pc_cgs / km_cgs, 1e-12
+ yield assert_allclose_units, u3.base_value, pc_cgs / km_cgs, 1e-12
yield assert_true, u3.dimensions == 1 / time
@@ -376,12 +378,12 @@
u2 = u1**2
yield assert_true, u2.dimensions == u1_dims**2
- yield assert_allclose, u2.base_value, (pc_cgs**2 * mK_cgs**4)**2, 1e-12
+ yield assert_allclose_units, u2.base_value, (pc_cgs**2 * mK_cgs**4)**2, 1e-12
u3 = u1**(-1.0/3)
yield assert_true, u3.dimensions == nsimplify(u1_dims**(-1.0/3))
- yield assert_allclose, u3.base_value, (pc_cgs**2 * mK_cgs**4)**(-1.0/3), 1e-12
+ yield assert_allclose_units, u3.base_value, (pc_cgs**2 * mK_cgs**4)**(-1.0/3), 1e-12
def test_equality():
@@ -413,7 +415,7 @@
yield assert_true, u2.expr == u3.expr
yield assert_true, u2 == u3
- yield assert_allclose, u1.base_value, Msun_cgs / Mpc_cgs**3, 1e-12
+ yield assert_allclose_units, u1.base_value, Msun_cgs / Mpc_cgs**3, 1e-12
yield assert_true, u2.base_value == 1
yield assert_true, u3.base_value == 1
@@ -423,7 +425,7 @@
yield assert_true, u2.dimensions == mass_density
yield assert_true, u3.dimensions == mass_density
- yield assert_allclose, get_conversion_factor(u1, u3)[0], \
+ yield assert_allclose_units, get_conversion_factor(u1, u3)[0], \
Msun_cgs / Mpc_cgs**3, 1e-12
def test_is_code_unit():
@@ -441,3 +443,10 @@
yield assert_true, u4.is_code_unit
yield assert_true, not u5.is_code_unit
yield assert_true, not u6.is_code_unit
+
+def test_temperature_offsets():
+ u1 = Unit('degC')
+ u2 = Unit('degF')
+
+ assert_raises(InvalidUnitOperation, operator.mul, u1, u2)
+ assert_raises(InvalidUnitOperation, operator.div, u1, u2)
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/units/tests/test_ytarray.py
--- a/yt/units/tests/test_ytarray.py
+++ b/yt/units/tests/test_ytarray.py
@@ -28,17 +28,18 @@
assert_array_equal, \
assert_equal, assert_raises, \
assert_array_almost_equal_nulp, \
- assert_array_almost_equal, \
- assert_allclose
+ assert_array_almost_equal
from numpy import array
from yt.units.yt_array import \
YTArray, YTQuantity, \
unary_operators, binary_operators, \
uconcatenate, uintersect1d, \
- uunion1d
+ uunion1d, loadtxt, savetxt
from yt.utilities.exceptions import \
YTUnitOperationError, YTUfuncUnitError
-from yt.testing import fake_random_ds, requires_module
+from yt.testing import \
+ fake_random_ds, requires_module, \
+ assert_allclose_units
from yt.funcs import fix_length
from yt.units.unit_symbols import \
cm, m, g
@@ -554,6 +555,17 @@
yield assert_true, a_slice.base is a
+def test_iteration():
+ """
+ Test that iterating over a YTArray returns a sequence of YTQuantity insances
+ """
+ a = np.arange(3)
+ b = YTArray(np.arange(3), 'cm')
+ for ia, ib, in zip(a, b):
+ yield assert_equal, ia, ib.value
+ yield assert_equal, ib.units, b.units
+
+
def test_fix_length():
"""
Test fixing the length of an array. Used in spheres and other data objects
@@ -883,14 +895,14 @@
E = mp.to_equivalent("keV","mass_energy")
yield assert_equal, E, mp*clight*clight
- yield assert_allclose, mp, E.to_equivalent("g", "mass_energy")
+ yield assert_allclose_units, mp, E.to_equivalent("g", "mass_energy")
# Thermal
T = YTQuantity(1.0e8,"K")
E = T.to_equivalent("W*hr","thermal")
yield assert_equal, E, (kboltz*T).in_units("W*hr")
- yield assert_allclose, T, E.to_equivalent("K", "thermal")
+ yield assert_allclose_units, T, E.to_equivalent("K", "thermal")
# Spectral
@@ -899,11 +911,11 @@
yield assert_equal, nu, clight/l
E = hcgs*nu
l2 = E.to_equivalent("angstrom", "spectral")
- yield assert_allclose, l, l2
+ yield assert_allclose_units, l, l2
nu2 = clight/l2.in_units("cm")
- yield assert_allclose, nu, nu2
+ yield assert_allclose_units, nu, nu2
E2 = nu2.to_equivalent("keV", "spectral")
- yield assert_allclose, E2, E.in_units("keV")
+ yield assert_allclose_units, E2, E.in_units("keV")
# Sound-speed
@@ -911,13 +923,13 @@
gg = 5./3.
c_s = T.to_equivalent("km/s","sound_speed")
yield assert_equal, c_s, np.sqrt(gg*kboltz*T/(mu*mh))
- yield assert_allclose, T, c_s.to_equivalent("K","sound_speed")
+ yield assert_allclose_units, T, c_s.to_equivalent("K","sound_speed")
mu = 0.5
gg = 4./3.
c_s = T.to_equivalent("km/s","sound_speed", mu=mu, gamma=gg)
yield assert_equal, c_s, np.sqrt(gg*kboltz*T/(mu*mh))
- yield assert_allclose, T, c_s.to_equivalent("K","sound_speed",
+ yield assert_allclose_units, T, c_s.to_equivalent("K","sound_speed",
mu=mu, gamma=gg)
# Lorentz
@@ -925,21 +937,21 @@
v = 0.8*clight
g = v.to_equivalent("dimensionless","lorentz")
g2 = YTQuantity(1./np.sqrt(1.-0.8*0.8), "dimensionless")
- yield assert_allclose, g, g2
+ yield assert_allclose_units, g, g2
v2 = g2.to_equivalent("mile/hr", "lorentz")
- yield assert_allclose, v2, v.in_units("mile/hr")
+ yield assert_allclose_units, v2, v.in_units("mile/hr")
# Schwarzschild
R = mass_sun_cgs.to_equivalent("kpc","schwarzschild")
yield assert_equal, R.in_cgs(), 2*G*mass_sun_cgs/(clight*clight)
- yield assert_allclose, mass_sun_cgs, R.to_equivalent("g", "schwarzschild")
+ yield assert_allclose_units, mass_sun_cgs, R.to_equivalent("g", "schwarzschild")
# Compton
l = me.to_equivalent("angstrom","compton")
yield assert_equal, l, hcgs/(me*clight)
- yield assert_allclose, me, l.to_equivalent("g", "compton")
+ yield assert_allclose_units, me, l.to_equivalent("g", "compton")
# Number density
@@ -947,18 +959,18 @@
n = rho.to_equivalent("cm**-3","number_density")
yield assert_equal, n, rho/(mh*0.6)
- yield assert_allclose, rho, n.to_equivalent("g/cm**3","number_density")
+ yield assert_allclose_units, rho, n.to_equivalent("g/cm**3","number_density")
n = rho.to_equivalent("cm**-3","number_density", mu=0.75)
yield assert_equal, n, rho/(mh*0.75)
- yield assert_allclose, rho, n.to_equivalent("g/cm**3","number_density", mu=0.75)
+ yield assert_allclose_units, rho, n.to_equivalent("g/cm**3","number_density", mu=0.75)
# Effective temperature
T = YTQuantity(1.0e4, "K")
F = T.to_equivalent("erg/s/cm**2","effective_temperature")
yield assert_equal, F, stefan_boltzmann_constant_cgs*T**4
- yield assert_allclose, T, F.to_equivalent("K", "effective_temperature")
+ yield assert_allclose_units, T, F.to_equivalent("K", "effective_temperature")
def test_electromagnetic():
from yt.units.dimensions import charge_mks, pressure, current_cgs, \
@@ -1009,7 +1021,18 @@
V = YTQuantity(1.0, "statV")
V_mks = V.to_equivalent("V", "SI")
yield assert_array_almost_equal, V_mks.v, 1.0e8*V.v/speed_of_light_cm_per_s
-
+
+def test_ytarray_coercion():
+ a = YTArray([1, 2, 3], 'cm')
+ q = YTQuantity(3, 'cm')
+ na = np.array([1, 2, 3])
+
+ assert_isinstance(a*q, YTArray)
+ assert_isinstance(q*na, YTArray)
+ assert_isinstance(q*3, YTQuantity)
+ assert_isinstance(q*np.float64(3), YTQuantity)
+ assert_isinstance(q*np.array(3), YTQuantity)
+
def test_numpy_wrappers():
a1 = YTArray([1, 2, 3], 'cm')
a2 = YTArray([2, 3, 4, 5, 6], 'cm')
@@ -1050,3 +1073,22 @@
yield assert_true, ret == 0.5
yield assert_true, ret.units.is_dimensionless
yield assert_true, ret.units.base_value == 1.0
+
+def test_load_and_save():
+ tmpdir = tempfile.mkdtemp()
+ curdir = os.getcwd()
+ os.chdir(tmpdir)
+
+ a = YTArray(np.random.random(10), "kpc")
+ b = YTArray(np.random.random(10), "Msun")
+ c = YTArray(np.random.random(10), "km/s")
+
+ savetxt("arrays.dat", [a,b,c], delimiter=",")
+
+ d, e = loadtxt("arrays.dat", usecols=(1,2), delimiter=",")
+
+ yield assert_array_equal, b, d
+ yield assert_array_equal, c, e
+
+ os.chdir(curdir)
+ shutil.rmtree(tmpdir)
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/units/unit_object.py
--- a/yt/units/unit_object.py
+++ b/yt/units/unit_object.py
@@ -290,9 +290,9 @@
base_offset = 0.0
if self.base_offset or u.base_offset:
- if u.dimensions is dims.temperature and self.is_dimensionless:
+ if u.dimensions is temperature and self.is_dimensionless:
base_offset = u.base_offset
- elif self.dimensions is dims.temperature and u.is_dimensionless:
+ elif self.dimensions is temperature and u.is_dimensionless:
base_offset = self.base_offset
else:
raise InvalidUnitOperation("Quantities with units of Farhenheit "
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/units/yt_array.py
--- a/yt/units/yt_array.py
+++ b/yt/units/yt_array.py
@@ -40,6 +40,7 @@
from sympy import Rational
from yt.units.unit_lookup_table import unit_prefixes, prefixable_units
from yt.units.equivalencies import equivalence_registry
+from yt.utilities.logger import ytLogger as mylog
NULL_UNIT = Unit()
@@ -134,6 +135,17 @@
raise YTUnitOperationError(op_string, inp.units, dimensionless)
return ret
+def validate_comparison_units(this, other, op_string):
+ # Check that other is a YTArray.
+ if hasattr(other, 'units'):
+ if this.units.expr is other.units.expr:
+ return other
+ if not this.units.same_dimensions_as(other.units):
+ raise YTUnitOperationError(op_string, this.units, other.units)
+ return other.in_units(this.units)
+
+ return other
+
unary_operators = (
negative, absolute, rint, ones_like, sign, conj, exp, exp2, log, log2,
log10, expm1, log1p, sqrt, square, reciprocal, sin, cos, tan, arcsin,
@@ -166,7 +178,13 @@
with a unit registry and this is specified, this will be used instead of
the registry associated with the unit object.
dtype : string or NumPy dtype object
- The dtype of the array data.
+ The dtype of the array data. Defaults to the dtype of the input data,
+ or, if none is found, uses np.float64
+ bypass_validation : boolean
+ If True, all input validation is skipped. Using this option may produce
+ corrupted, invalid units or array data, but can lead to significant
+ speedups in the input validation logic adds significant overhead. If set,
+ input_units *must* be a valid unit object. Defaults to False.
Examples
--------
@@ -285,9 +303,16 @@
__array_priority__ = 2.0
- def __new__(cls, input_array, input_units=None, registry=None, dtype=None):
+ def __new__(cls, input_array, input_units=None, registry=None, dtype=None,
+ bypass_validation=False):
if dtype is None:
dtype = getattr(input_array, 'dtype', np.float64)
+ if bypass_validation is True:
+ obj = np.asarray(input_array, dtype=dtype).view(cls)
+ obj.units = input_units
+ if registry is not None:
+ obj.units.registry = registry
+ return obj
if input_array is NotImplemented:
return input_array
if registry is None and isinstance(input_units, (str, bytes)):
@@ -910,26 +935,13 @@
# @todo: outsource to a single method with an op argument.
def __lt__(self, other):
""" Test if this is less than the object on the right. """
- # Check that other is a YTArray.
- if isinstance(other, YTArray):
- if not self.units.same_dimensions_as(other.units):
- raise YTUnitOperationError('less than', self.units, other.units)
-
- return np.array(self).__lt__(np.array(other.in_units(self.units)))
-
- return np.array(self).__lt__(np.array(other))
+ oth = validate_comparison_units(self, other, 'less_than')
+ return np.array(self).__lt__(np.array(oth))
def __le__(self, other):
""" Test if this is less than or equal to the object on the right. """
- # Check that other is a YTArray.
- if isinstance(other, YTArray):
- if not self.units.same_dimensions_as(other.units):
- raise YTUnitOperationError('less than or equal', self.units,
- other.units)
-
- return np.array(self).__le__(np.array(other.in_units(self.units)))
-
- return np.array(self).__le__(np.array(other))
+ oth = validate_comparison_units(self, other, 'less_than or equal')
+ return np.array(self).__le__(np.array(oth))
def __eq__(self, other):
""" Test if this is equal to the object on the right. """
@@ -937,50 +949,28 @@
if other is None:
# self is a YTArray, so it can't be None.
return False
- if isinstance(other, YTArray):
- if not self.units.same_dimensions_as(other.units):
- raise YTUnitOperationError("equal", self.units, other.units)
-
- return np.array(self).__eq__(np.array(other.in_units(self.units)))
-
- return np.array(self).__eq__(np.array(other))
+ oth = validate_comparison_units(self, other, 'equal')
+ return np.array(self).__eq__(np.array(oth))
def __ne__(self, other):
""" Test if this is not equal to the object on the right. """
# Check that the other is a YTArray.
if other is None:
return True
- if isinstance(other, YTArray):
- if not self.units.same_dimensions_as(other.units):
- raise YTUnitOperationError("not equal", self.units, other.units)
-
- return np.array(self).__ne__(np.array(other.in_units(self.units)))
-
- return np.array(self).__ne__(np.array(other))
+ oth = validate_comparison_units(self, other, 'not equal')
+ return np.array(self).__ne__(np.array(oth))
def __ge__(self, other):
""" Test if this is greater than or equal to other. """
# Check that the other is a YTArray.
- if isinstance(other, YTArray):
- if not self.units.same_dimensions_as(other.units):
- raise YTUnitOperationError("greater than or equal",
- self.units, other.units)
-
- return np.array(self).__ge__(np.array(other.in_units(self.units)))
-
- return np.array(self).__ge__(np.array(other))
+ oth = validate_comparison_units(self, other, 'greater than or equal')
+ return np.array(self).__ge__(np.array(oth))
def __gt__(self, other):
""" Test if this is greater than the object on the right. """
# Check that the other is a YTArray.
- if isinstance(other, YTArray):
- if not self.units.same_dimensions_as(other.units):
- raise YTUnitOperationError("greater than", self.units,
- other.units)
-
- return np.array(self).__gt__(np.array(other.in_units(self.units)))
-
- return np.array(self).__gt__(np.array(other))
+ oth = validate_comparison_units(self, other, 'greater than')
+ return np.array(self).__gt__(np.array(oth))
#
# End comparison operators
@@ -1017,7 +1007,7 @@
def __getitem__(self, item):
ret = super(YTArray, self).__getitem__(item)
if ret.shape == ():
- return YTQuantity(ret, self.units)
+ return YTQuantity(ret, self.units, bypass_validation=True)
else:
return ret
@@ -1085,7 +1075,7 @@
if ret_class is YTQuantity:
# This happens if you do ndarray * YTQuantity. Explicitly
# casting to YTArray avoids creating a YTQuantity with size > 1
- return YTArray(np.array(out_arr, unit))
+ return YTArray(np.array(out_arr), unit)
return ret_class(np.array(out_arr, copy=False), unit)
@@ -1184,11 +1174,11 @@
"""
def __new__(cls, input_scalar, input_units=None, registry=None,
- dtype=np.float64):
+ dtype=np.float64, bypass_validation=False):
if not isinstance(input_scalar, (numeric_type, np.number, np.ndarray)):
raise RuntimeError("YTQuantity values must be numeric")
ret = YTArray.__new__(cls, input_scalar, input_units, registry,
- dtype=dtype)
+ dtype=dtype, bypass_validation=bypass_validation)
if ret.size > 1:
raise RuntimeError("YTQuantity instances must be scalars")
return ret
@@ -1229,7 +1219,7 @@
def ucross(arr1,arr2, registry=None):
"""Applies the cross product to two YT arrays.
- This wrapper around numpy.cross preserves units.
+ This wrapper around numpy.cross preserves units.
See the documentation of numpy.cross for full
details.
"""
@@ -1310,3 +1300,113 @@
else:
raise RuntimeError("Undefined operation for a YTArray subclass. "
"Received operand types (%s) and (%s)" % (cls1, cls2))
+
+def loadtxt(fname, dtype='float', delimiter='\t', usecols=None, comments='#'):
+ r"""
+ Load YTArrays with unit information from a text file. Each row in the
+ text file must have the same number of values.
+
+ Parameters
+ ----------
+ fname : str
+ Filename to read.
+ dtype : data-type, optional
+ Data-type of the resulting array; default: float.
+ delimiter : str, optional
+ The string used to separate values. By default, this is any
+ whitespace.
+ usecols : sequence, optional
+ Which columns to read, with 0 being the first. For example,
+ ``usecols = (1,4,5)`` will extract the 2nd, 5th and 6th columns.
+ The default, None, results in all columns being read.
+ comments : str, optional
+ The character used to indicate the start of a comment;
+ default: '#'.
+
+ Examples
+ --------
+ >>> temp, velx = yt.loadtxt("sphere.dat", usecols=(1,2), delimiter="\t")
+ """
+ f = open(fname, 'r')
+ next_one = False
+ units = []
+ num_cols = -1
+ for line in f.readlines():
+ words = line.strip().split()
+ if len(words) == 0:
+ continue
+ if line[0] == comments:
+ if next_one:
+ units = words[1:]
+ if len(words) == 2 and words[1] == "Units":
+ next_one = True
+ else:
+ # Here we catch the first line of numbers
+ try:
+ col_words = line.strip().split(delimiter)
+ for word in col_words:
+ float(word)
+ num_cols = len(col_words)
+ break
+ except ValueError:
+ mylog.warning("Unrecognized character at beginning of line: \"%s\"." % line[0])
+ f.close()
+ if len(units) != num_cols:
+ mylog.warning("Malformed or incomplete units header. Arrays will be "
+ "dimensionless!")
+ units = ["dimensionless"]*num_cols
+ arrays = np.loadtxt(fname, dtype=dtype, comments=comments,
+ delimiter=delimiter, converters=None,
+ unpack=True, usecols=usecols, ndmin=0)
+ if usecols is not None:
+ units = [units[col] for col in usecols]
+ mylog.info("Array units: %s" % ", ".join(units))
+ return tuple([YTArray(arr, unit) for arr, unit in zip(arrays, units)])
+
+def savetxt(fname, arrays, fmt='%.18e', delimiter='\t', header='',
+ footer='', comments='#'):
+ r"""
+ Write YTArrays with unit information to a text file.
+
+ Parameters
+ ----------
+ fname : str
+ The file to write the YTArrays to.
+ arrays : list of YTArrays or single YTArray
+ The array(s) to write to the file.
+ fmt : str or sequence of strs, optional
+ A single format (%10.5f), or a sequence of formats.
+ delimiter : str, optional
+ String or character separating columns.
+ header : str, optional
+ String that will be written at the beginning of the file, before the
+ unit header.
+ footer : str, optional
+ String that will be written at the end of the file.
+ comments : str, optional
+ String that will be prepended to the ``header`` and ``footer`` strings,
+ to mark them as comments. Default: '# ', as expected by e.g.
+ ``yt.loadtxt``.
+
+ Examples
+ --------
+ >>> sp = ds.sphere("c", (100,"kpc"))
+ >>> a = sphere["density"]
+ >>> b = sphere["temperature"]
+ >>> c = sphere["velocity_x"]
+ >>> yt.savetxt("sphere.dat", [a,b,c], header='My sphere stuff', delimiter="\t")
+ """
+ if not isinstance(arrays, list):
+ arrays = [arrays]
+ units = []
+ for array in arrays:
+ if hasattr(array, "units"):
+ units.append(str(array.units))
+ else:
+ units.append("dimensionless")
+ if header != '':
+ header += '\n'
+ header += " Units\n " + '\t'.join(units)
+ np.savetxt(fname, np.transpose(arrays), header=header,
+ fmt=fmt, delimiter=delimiter, footer=footer,
+ newline='\n', comments=comments)
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -403,8 +403,8 @@
assert_equal(new_result, old_result,
err_msg=err_msg, verbose=True)
else:
- assert_allclose(new_result, old_result, 10.**(-self.decimals),
- err_msg=err_msg, verbose=True)
+ assert_allclose_units(new_result, old_result, 10.**(-self.decimals),
+ err_msg=err_msg, verbose=True)
class AllFieldValuesTest(AnswerTestingTest):
_type_name = "AllFieldValues"
@@ -478,8 +478,8 @@
if self.decimals is None:
assert_equal(nres, ores, err_msg=err_msg)
else:
- assert_allclose(nres, ores, 10.**-(self.decimals),
- err_msg=err_msg)
+ assert_allclose_units(nres, ores, 10.**-(self.decimals),
+ err_msg=err_msg)
class PixelizedProjectionValuesTest(AnswerTestingTest):
_type_name = "PixelizedProjectionValues"
@@ -727,7 +727,8 @@
if self.decimals is None:
assert_equal(new_result[k], old_result[k])
else:
- assert_allclose(new_result[k], old_result[k], 10**(-self.decimals))
+ assert_allclose_units(new_result[k], old_result[k],
+ 10**(-self.decimals))
class GenericImageTest(AnswerTestingTest):
_type_name = "GenericImage"
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -195,7 +195,7 @@
"the %s base system of units." % (self.unit, self.units_base)
return err
-class YTEquivalentDimsError(Exception):
+class YTEquivalentDimsError(YTUnitOperationError):
def __init__(self, old_units, new_units, base):
self.old_units = old_units
self.new_units = new_units
diff -r 447d1fcc814767e7b7d7eef420dee4ce66f98606 -r c20aab1a920decf5c9d63d28cb1df9da479441aa yt/visualization/tests/test_export_frb.py
--- a/yt/visualization/tests/test_export_frb.py
+++ b/yt/visualization/tests/test_export_frb.py
@@ -16,7 +16,7 @@
import numpy as np
from yt.testing import \
fake_random_ds, assert_equal, \
- assert_allclose
+ assert_allclose_units
def setup():
"""Test specific setup."""
@@ -35,5 +35,6 @@
yield assert_equal, frb_ds.domain_right_edge.v, np.array([0.75,0.75,1.0])
yield assert_equal, frb_ds.domain_width.v, np.array([0.5,0.5,1.0])
yield assert_equal, frb_ds.domain_dimensions, np.array([64,64,1], dtype="int64")
- yield assert_allclose, frb["density"].sum(), dd_frb.quantities.total_quantity("density")
+ yield assert_allclose_units, frb["density"].sum(), \
+ dd_frb.quantities.total_quantity("density")
yield assert_equal, frb_ds.index.num_grids, 8
https://bitbucket.org/yt_analysis/yt/commits/ea0a4fc94007/
Changeset: ea0a4fc94007
Branch: yt
User: ngoldbaum
Date: 2015-08-17 20:21:50+00:00
Summary: Add E123 and E124 to this list of ignored rules and ignore _mpl_imports,
increase max-line-length
Affected #: 1 file
diff -r c20aab1a920decf5c9d63d28cb1df9da479441aa -r ea0a4fc9400745c52ef84384752ae96ed50e04a7 setup.cfg
--- a/setup.cfg
+++ b/setup.cfg
@@ -10,6 +10,6 @@
[flake8]
# if we include api.py files, we get tons of spurious "imported but unused" errors
-exclude = */api.py,*/__config__.py
-max-line-length=160
-ignore = E111,E121,E122,E125,E126,E127,E128,E129,E131,E201,E202,E211,E221,E222,E228,E241,E301,E203,E225,E226,E231,E251,E261,E262,E265,E302,E303,E401,E502,E701,E703,W291,W293,W391
\ No newline at end of file
+exclude = */api.py,*/__config__.py,yt/visualization/_mpl_imports.py
+max-line-length=999
+ignore = E111,E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E201,E202,E211,E221,E222,E228,E241,E301,E203,E225,E226,E231,E251,E261,E262,E265,E302,E303,E401,E502,E701,E703,W291,W293,W391
\ No newline at end of file
https://bitbucket.org/yt_analysis/yt/commits/2930eea4c879/
Changeset: 2930eea4c879
Branch: yt
User: ngoldbaum
Date: 2015-08-17 23:19:41+00:00
Summary: Fix merge error
Affected #: 1 file
diff -r ea0a4fc9400745c52ef84384752ae96ed50e04a7 -r 2930eea4c8794c0ef62e01de284b04924cbfcec3 yt/analysis_modules/ppv_cube/tests/test_ppv.py
--- a/yt/analysis_modules/ppv_cube/tests/test_ppv.py
+++ b/yt/analysis_modules/ppv_cube/tests/test_ppv.py
@@ -15,7 +15,7 @@
import yt.units as u
from yt.utilities.physical_constants import kboltz, mh, clight
import numpy as np
-from yt.testing import assert_allclose
+from yt.testing import assert_allclose_units
def setup():
"""Test specific setup."""
https://bitbucket.org/yt_analysis/yt/commits/4bfdb0ddccdb/
Changeset: 4bfdb0ddccdb
Branch: yt
User: chummels
Date: 2015-08-20 16:41:21+00:00
Summary: Merged in ngoldbaum/yt (pull request #1691)
Codebase linting: analysis modules and flake8 rules
Affected #: 47 files
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 setup.cfg
--- a/setup.cfg
+++ b/setup.cfg
@@ -7,3 +7,9 @@
where=yt
exclude=answer_testing
with-xunit=1
+
+[flake8]
+# if we include api.py files, we get tons of spurious "imported but unused" errors
+exclude = */api.py,*/__config__.py,yt/visualization/_mpl_imports.py
+max-line-length=999
+ignore = E111,E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E201,E202,E211,E221,E222,E228,E241,E301,E203,E225,E226,E231,E251,E261,E262,E265,E302,E303,E401,E502,E701,E703,W291,W293,W391
\ No newline at end of file
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/absorption_spectrum/absorption_line.py
--- a/yt/analysis_modules/absorption_spectrum/absorption_line.py
+++ b/yt/analysis_modules/absorption_spectrum/absorption_line.py
@@ -70,15 +70,6 @@
x = np.asarray(u).astype(np.float64)
y = np.asarray(a).astype(np.float64)
- w = np.array([0.462243670, 0.286675505, 0.109017206,
- 0.0248105209, 0.00324377334, 0.000228338636,
- 7.80255648e-6, 1.08606937e-7, 4.39934099e-10,
- 2.22939365e-13])
-
- t = np.array([0.245340708, 0.737473729, 1.23407622, 1.73853771,
- 2.25497400, 2.78880606, 3.34785457, 3.94476404,
- 4.60368245, 5.38748089])
-
# Hummer's Chebyshev Coefficients
c = ( 0.1999999999972224, -0.1840000000029998, 0.1558399999965025,
-0.1216640000043988, 0.0877081599940391, -0.0585141248086907,
@@ -195,7 +186,6 @@
## conversions
nu1 = speed_of_light_cgs / lam1 # line freq in Hz
nudop = v_doppler / speed_of_light_cgs * nu1 # doppler width in Hz
- lamdop = v_doppler / speed_of_light_cgs * lam1 # doppler width in Ang
## create wavelength
if lambda_bins is None:
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/absorption_spectrum/absorption_spectrum_fit.py
--- a/yt/analysis_modules/absorption_spectrum/absorption_spectrum_fit.py
+++ b/yt/analysis_modules/absorption_spectrum/absorption_spectrum_fit.py
@@ -141,7 +141,7 @@
if flag and species=='lya' and min(yDatBounded)<.1:
newLinesP=_large_flag_fit(xBounded,yDatBounded,
yFitBounded,z,speciesDict,
- minSize,minError)
+ fitLim,minError)
if np.size(newLinesP)> 0:
@@ -226,7 +226,7 @@
"""
#Setup initial line guesses
- if initP==None: #Regular fit
+ if initP is None: #Regular fit
initP = [0,0,0]
if min(yDat)<.01: #Large lines get larger initial guess
initP[0] = speciesDict['init_N']*10**2
@@ -252,7 +252,7 @@
#Values to proceed through first run
errSq,prevErrSq,prevLinesP=1,10*len(x),[]
- if errBound == None:
+ if errBound is None:
errBound = len(yDat)*(max(1-yDat)*1E-2)**2
else:
errBound = errBound*len(yDat)
@@ -548,7 +548,7 @@
lb = _get_bounds(p[2],b,wl,x0,xRes)
xb,yb=x[lb[0]:lb[1]],y[lb[0]:lb[1]]
- if errBound == None:
+ if errBound is None:
errBound = 10*len(yb)*(max(1-yb)*1E-2)**2
else:
errBound = 10*errBound*len(yb)
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/cosmological_observation/cosmology_splice.py
--- a/yt/analysis_modules/cosmological_observation/cosmology_splice.py
+++ b/yt/analysis_modules/cosmological_observation/cosmology_splice.py
@@ -14,10 +14,11 @@
#-----------------------------------------------------------------------------
import numpy as np
+import os
from yt.convenience import \
simulation
-from yt.funcs import *
+from yt.funcs import mylog
from yt.utilities.cosmology import \
Cosmology
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
--- a/yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
+++ b/yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
@@ -24,8 +24,6 @@
CosmologySplice
from yt.convenience import \
load
-from yt.utilities.cosmology import \
- Cosmology
from yt.utilities.parallel_tools.parallel_analysis_interface import \
parallel_objects, \
parallel_root_only
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/cosmological_observation/light_cone/setup.py
--- a/yt/analysis_modules/cosmological_observation/light_cone/setup.py
+++ b/yt/analysis_modules/cosmological_observation/light_cone/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/cosmological_observation/light_ray/light_ray.py
--- a/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py
+++ b/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py
@@ -13,7 +13,6 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-import copy
import h5py
import numpy as np
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/cosmological_observation/light_ray/setup.py
--- a/yt/analysis_modules/cosmological_observation/light_ray/setup.py
+++ b/yt/analysis_modules/cosmological_observation/light_ray/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/cosmological_observation/setup.py
--- a/yt/analysis_modules/cosmological_observation/setup.py
+++ b/yt/analysis_modules/cosmological_observation/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/halo_analysis/enzofof_merger_tree.py
--- a/yt/analysis_modules/halo_analysis/enzofof_merger_tree.py
+++ b/yt/analysis_modules/halo_analysis/enzofof_merger_tree.py
@@ -35,13 +35,13 @@
import numpy as np
import h5py
-import time
-import pdb
+import glob
+import os
+
from yt.extern.six.moves import cPickle
-import glob
+from yt.extern.pykdtree import KDTree
+from yt.funcs import mylog, get_pbar
-from yt.funcs import *
-from yt.extern.pykdtree import KDTree
import yt.extern.pydot as pydot
# We don't currently use this, but we may again find a use for it in the
@@ -180,7 +180,7 @@
def calculate_parentage_fractions(self, other_catalog, radius = 0.10):
parentage_fractions = {}
- if self.halo_positions == None or other_catalog.halo_positions == None:
+ if self.halo_positions is None or other_catalog.halo_positions is None:
return parentage_fractions
mylog.debug("Ball-tree query with radius %0.3e", radius)
all_nearest = self.halo_kdtree.query_ball_tree(
@@ -320,7 +320,7 @@
for redshift in self.redshifts.values():
if redshift <= zrange[0] and redshift >= zrange[1]:
# some reverse lookup magic--assumes unique cycle/z pairs
- cycle = [key for key,value in mt.redshifts.items() \
+ cycle = [key for key,value in self.redshifts.items() \
if value == redshift][0]
del self.redshifts[cycle]
@@ -568,7 +568,7 @@
automatically. See GraphViz (e.g. "dot -v")
for a list of available output formats.
"""
- if filename == None:
+ if filename is None:
filename = "%s/tree_halo%5.5d.gv" % \
(self.FOF_directory, self.halonum)
# Create the pydot graph object.
@@ -598,7 +598,6 @@
# (lvl, br.halo_id, next_lvl, c[0], color)
#fp.write(line)
- last_level = (ii,lvl)
for ii,lvl in enumerate(sorted_lvl):
npart_max = 0
for br in self.levels[lvl]:
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/halo_analysis/halo_callbacks.py
--- a/yt/analysis_modules/halo_analysis/halo_callbacks.py
+++ b/yt/analysis_modules/halo_analysis/halo_callbacks.py
@@ -18,23 +18,22 @@
import os
from yt.analysis_modules.cosmological_observation.light_ray.light_ray import \
- periodic_distance
+ periodic_distance
from yt.data_objects.profiles import \
- create_profile
+ create_profile
from yt.units.yt_array import \
- YTArray, YTQuantity
+ YTArray
from yt.utilities.exceptions import \
- YTSphereTooSmall
+ YTSphereTooSmall
from yt.funcs import \
- ensure_list, is_root
-from yt.utilities.exceptions import YTUnitConversionError
+ ensure_list
from yt.utilities.logger import ytLogger as mylog
from yt.utilities.operator_registry import \
- OperatorRegistry
+ OperatorRegistry
from yt.utilities.parallel_tools.parallel_analysis_interface import \
parallel_root_only
from yt.visualization.profile_plotter import \
- PhasePlot
+ PhasePlot
callback_registry = OperatorRegistry()
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/halo_analysis/halo_catalog.py
--- a/yt/analysis_modules/halo_analysis/halo_catalog.py
+++ b/yt/analysis_modules/halo_analysis/halo_catalog.py
@@ -138,7 +138,7 @@
self.actions = []
# fields to be written to the halo catalog
self.quantities = []
- if not self.halos_ds is None:
+ if self.halos_ds is not None:
self.add_default_quantities()
def add_callback(self, callback, *args, **kwargs):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/halo_analysis/halo_finding_methods.py
--- a/yt/analysis_modules/halo_analysis/halo_finding_methods.py
+++ b/yt/analysis_modules/halo_analysis/halo_finding_methods.py
@@ -17,8 +17,6 @@
from yt.analysis_modules.halo_finding.halo_objects import \
FOFHaloFinder, HOPHaloFinder
-from yt.frontends.halo_catalog.data_structures import \
- HaloCatalogDataset
from yt.frontends.stream.data_structures import \
load_particles
from yt.units.dimensions import length
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/halo_analysis/tests/test_halo_finders.py
--- a/yt/analysis_modules/halo_analysis/tests/test_halo_finders.py
+++ b/yt/analysis_modules/halo_analysis/tests/test_halo_finders.py
@@ -1,10 +1,7 @@
import os
import sys
-from yt.analysis_modules.halo_analysis.api import \
- HaloCatalog
from yt.convenience import load
-from yt.testing import *
from yt.utilities.answer_testing.framework import \
FieldValuesTest, \
requires_ds
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/halo_finding/fof/setup.py
--- a/yt/analysis_modules/halo_finding/fof/setup.py
+++ b/yt/analysis_modules/halo_finding/fof/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 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
@@ -17,21 +17,15 @@
import h5py
import math
import numpy as np
-import random
-import sys
import glob
import os
import os.path as path
from functools import cmp_to_key
-from collections import defaultdict
from yt.extern.six import add_metaclass
from yt.extern.six.moves import zip as izip
from yt.config import ytcfg
from yt.funcs import mylog, ensure_dir_exists
-from yt.utilities.performance_counters import \
- time_function, \
- yt_counters
from yt.utilities.math_utils import \
get_rotation_matrix, \
periodic_dist
@@ -39,7 +33,7 @@
mass_sun_cgs, \
TINY
from yt.utilities.physical_ratios import \
- rho_crit_g_cm3_h2
+ rho_crit_g_cm3_h2
from .hop.EnzoHop import RunHOP
from .fof.EnzoFOF import RunFOF
@@ -282,7 +276,7 @@
return r.max()
def __getitem__(self, key):
- if ytcfg.getboolean("yt", "inline") == False:
+ if ytcfg.getboolean("yt", "inline") is False:
return self.data[key][self.indices]
else:
return self.data[key][self.indices]
@@ -339,8 +333,6 @@
if ('io','creation_time') in self.data.ds.field_list:
handle.create_dataset("/%s/creation_time" % gn,
data=self['creation_time'])
- n = handle["/%s" % gn]
- # set attributes on n
self._processing = False
def virial_mass(self, virial_overdensity=200., bins=300):
@@ -419,7 +411,7 @@
"""
self.virial_info(bins=bins)
over = (self.overdensity > virial_overdensity)
- if (over == True).any():
+ if over.any():
vir_bin = max(np.arange(bins + 1)[over])
return vir_bin
else:
@@ -1233,7 +1225,6 @@
fglob = path.join(basedir, 'halos_%d.*.bin' % n)
files = glob.glob(fglob)
halos = self._get_halos_binary(files)
- Jc = 1.0
length = 1.0 / ds['Mpchcm']
conv = dict(pos = np.array([length, length, length,
1, 1, 1]), # to unitary
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/halo_finding/hop/setup.py
--- a/yt/analysis_modules/halo_finding/hop/setup.py
+++ b/yt/analysis_modules/halo_finding/hop/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/halo_finding/rockstar/rockstar.py
--- a/yt/analysis_modules/halo_finding/rockstar/rockstar.py
+++ b/yt/analysis_modules/halo_finding/rockstar/rockstar.py
@@ -16,23 +16,21 @@
from yt.config import ytcfg
from yt.data_objects.time_series import \
- DatasetSeries
+ DatasetSeries
from yt.funcs import \
- is_root
+ is_root, mylog
from yt.utilities.parallel_tools.parallel_analysis_interface import \
- ParallelAnalysisInterface, ProcessorPool, Communicator
-from yt.analysis_modules.halo_finding.halo_objects import * #Halos & HaloLists
+ ParallelAnalysisInterface, ProcessorPool
+from yt.analysis_modules.halo_finding.halo_objects import \
+ RockstarHaloList
from yt.utilities.exceptions import YTRockstarMultiMassNotSupported
from . import rockstar_interface
import socket
import time
-import threading
-import signal
import os
-from os import environ
-from os import mkdir
+import numpy as np
from os import path
class InlineRunner(ParallelAnalysisInterface):
@@ -202,7 +200,7 @@
mylog.info("http://adsabs.harvard.edu/abs/2013ApJ...762..109B")
ParallelAnalysisInterface.__init__(self)
# Decide how we're working.
- if ytcfg.getboolean("yt", "inline") == True:
+ if ytcfg.getboolean("yt", "inline") is True:
self.runner = InlineRunner()
else:
self.runner = StandardRunner(num_readers, num_writers)
@@ -247,8 +245,6 @@
dd = tds.all_data()
# Get DM particle mass.
- all_fields = set(tds.derived_field_list + tds.field_list)
- has_particle_type = ("particle_type" in all_fields)
particle_mass = self.particle_mass
if particle_mass is None:
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/halo_finding/rockstar/setup.py
--- a/yt/analysis_modules/halo_finding/rockstar/setup.py
+++ b/yt/analysis_modules/halo_finding/rockstar/setup.py
@@ -1,9 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
-import setuptools
-import os, sys, os.path
-
import os.path
+import sys
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/halo_finding/tests/test_rockstar.py
--- a/yt/analysis_modules/halo_finding/tests/test_rockstar.py
+++ b/yt/analysis_modules/halo_finding/tests/test_rockstar.py
@@ -2,7 +2,6 @@
import sys
from yt.convenience import load
-from yt.testing import *
from yt.utilities.answer_testing.framework import \
FieldValuesTest, \
requires_sim
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/halo_mass_function/halo_mass_function.py
--- a/yt/analysis_modules/halo_mass_function/halo_mass_function.py
+++ b/yt/analysis_modules/halo_mass_function/halo_mass_function.py
@@ -14,7 +14,7 @@
#-----------------------------------------------------------------------------
import numpy as np
-import math, time
+import math
from yt.funcs import mylog
from yt.units.yt_array import \
@@ -184,7 +184,7 @@
if log_mass_max is None:
self.log_mass_max = 16
# If we're making the analytic function...
- if self.make_analytic == True:
+ if self.make_analytic is True:
# Try to set cosmological parameters from the simulation dataset
if simulation_ds is not None:
self.omega_matter0 = self.simulation_ds.omega_matter
@@ -623,27 +623,27 @@
many times as you want. */
/* TFmdm_set_cosm() -- User passes all the cosmological parameters as
- arguments; the routine sets up all of the scalar quantites needed
- computation of the fitting formula. The input parameters are:
- 1) omega_matter -- Density of CDM, baryons, and massive neutrinos,
- in units of the critical density.
- 2) omega_baryon -- Density of baryons, in units of critical.
- 3) omega_hdm -- Density of massive neutrinos, in units of critical
- 4) degen_hdm -- (Int) Number of degenerate massive neutrino species
- 5) omega_lambda -- Cosmological constant
- 6) hubble -- Hubble constant, in units of 100 km/s/Mpc
- 7) redshift -- The redshift at which to evaluate */
+ arguments; the routine sets up all of the scalar quantites needed
+ computation of the fitting formula. The input parameters are:
+ 1) omega_matter -- Density of CDM, baryons, and massive neutrinos,
+ in units of the critical density.
+ 2) omega_baryon -- Density of baryons, in units of critical.
+ 3) omega_hdm -- Density of massive neutrinos, in units of critical
+ 4) degen_hdm -- (Int) Number of degenerate massive neutrino species
+ 5) omega_lambda -- Cosmological constant
+ 6) hubble -- Hubble constant, in units of 100 km/s/Mpc
+ 7) redshift -- The redshift at which to evaluate */
/* TFmdm_onek_mpc() -- User passes a single wavenumber, in units of Mpc^-1.
- Routine returns the transfer function from the Eisenstein & Hu
- fitting formula, based on the cosmology currently held in the
- internal variables. The routine returns T_cb (the CDM+Baryon
- density-weighted transfer function), although T_cbn (the CDM+
- Baryon+Neutrino density-weighted transfer function) is stored
- in the global variable tf_cbnu. */
+ Routine returns the transfer function from the Eisenstein & Hu
+ fitting formula, based on the cosmology currently held in the
+ internal variables. The routine returns T_cb (the CDM+Baryon
+ density-weighted transfer function), although T_cbn (the CDM+
+ Baryon+Neutrino density-weighted transfer function) is stored
+ in the global variable tf_cbnu. */
/* We also supply TFmdm_onek_hmpc(), which is identical to the previous
- routine, but takes the wavenumber in units of h Mpc^-1. */
+ routine, but takes the wavenumber in units of h Mpc^-1. */
/* We hold the internal scalar quantities in global variables, so that
the user may access them in an external program, via "extern" declarations. */
@@ -667,7 +667,7 @@
sets many global variables for use in TFmdm_onek_mpc() */
"""
def __init__(self, omega_matter, omega_baryon, omega_hdm,
- degen_hdm, omega_lambda, hubble, redshift):
+ degen_hdm, omega_lambda, hubble, redshift):
self.qwarn = 0;
self.theta_cmb = 2.728/2.7 # Assuming T_cmb = 2.728 K
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/halo_mass_function/setup.py
--- a/yt/analysis_modules/halo_mass_function/setup.py
+++ b/yt/analysis_modules/halo_mass_function/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/level_sets/clump_handling.py
--- a/yt/analysis_modules/level_sets/clump_handling.py
+++ b/yt/analysis_modules/level_sets/clump_handling.py
@@ -19,7 +19,7 @@
from yt.fields.derived_field import \
ValidateSpatial
-from yt.funcs import mylog
+from yt.funcs import mylog, iterable
from yt.extern.six import string_types
from .clump_info_items import \
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/level_sets/clump_tools.py
--- a/yt/analysis_modules/level_sets/clump_tools.py
+++ b/yt/analysis_modules/level_sets/clump_tools.py
@@ -28,9 +28,9 @@
counter += 1
list.append(clump)
clump.level = level
- if clump.children != None:
+ if clump.children is not None:
for child in clump.children:
- x = recursive_all_clumps(child,list,level+1,clump.number)
+ recursive_all_clumps(child,list,level+1,clump.number)
return list
def return_all_clumps(clump):
@@ -64,8 +64,6 @@
Recursive. Prints the level and the number of cores to the screen."""
global counter
- if dbg > 0:
- print(tabs(level), "l =",level, "n_core",counter)
if ((clump.children is None) or (len(clump.children) == 0)):
counter += 1
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/level_sets/clump_validators.py
--- a/yt/analysis_modules/level_sets/clump_validators.py
+++ b/yt/analysis_modules/level_sets/clump_validators.py
@@ -13,8 +13,6 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-import numpy as np
-
from yt.utilities.data_point_utilities import FindBindingEnergy
from yt.utilities.operator_registry import \
OperatorRegistry
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/level_sets/contour_finder.py
--- a/yt/analysis_modules/level_sets/contour_finder.py
+++ b/yt/analysis_modules/level_sets/contour_finder.py
@@ -13,11 +13,11 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from itertools import chain
import numpy as np
-from yt.funcs import *
-import yt.utilities.data_point_utilities as data_point_utilities
+from collections import defaultdict
+
+from yt.funcs import mylog, get_pbar
from yt.utilities.lib.ContourFinding import \
ContourTree, TileContourTree, link_node_contours, \
update_joins
@@ -32,7 +32,6 @@
contours = {}
node_ids = []
DLE = data_source.ds.domain_left_edge
- selector = getattr(data_source, "base_object", data_source).selector
masks = dict((g.id, m) for g, m in data_source.blocks)
for (g, node, (sl, dims, gi)) in data_source.tiles.slice_traverse():
node.node_ind = len(node_ids)
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/level_sets/setup.py
--- a/yt/analysis_modules/level_sets/setup.py
+++ b/yt/analysis_modules/level_sets/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/list_modules.py
--- a/yt/analysis_modules/list_modules.py
+++ b/yt/analysis_modules/list_modules.py
@@ -33,7 +33,7 @@
def __getattr__(self, attr):
try:
name = "yt.analysis_modules.%s.api" % (attr)
- nm = __import__(name, level=-1)
+ __import__(name, level=-1)
setattr(self, attr, sys.modules[name])
except ImportError:
raise AttributeError(attr)
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/particle_trajectories/particle_trajectories.py
--- a/yt/analysis_modules/particle_trajectories/particle_trajectories.py
+++ b/yt/analysis_modules/particle_trajectories/particle_trajectories.py
@@ -16,7 +16,7 @@
from yt.utilities.lib.CICDeposit import CICSample_3
from yt.utilities.parallel_tools.parallel_analysis_interface import \
parallel_root_only
-from yt.funcs import *
+from yt.funcs import mylog, get_pbar
from yt.units.yt_array import array_like_field
from yt.config import ytcfg
from collections import OrderedDict
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/particle_trajectories/setup.py
--- a/yt/analysis_modules/particle_trajectories/setup.py
+++ b/yt/analysis_modules/particle_trajectories/setup.py
@@ -1,8 +1,5 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
+
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/photon_simulator/photon_models.py
--- a/yt/analysis_modules/photon_simulator/photon_models.py
+++ b/yt/analysis_modules/photon_simulator/photon_models.py
@@ -24,7 +24,8 @@
from yt.extern.six import string_types
import numpy as np
-from yt.funcs import *
+from yt.funcs import mylog, get_pbar
+from yt.units.yt_array import YTArray
from yt.utilities.physical_constants import mp
from yt.utilities.parallel_tools.parallel_analysis_interface import \
parallel_objects
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 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
@@ -26,14 +26,15 @@
#-----------------------------------------------------------------------------
from yt.extern.six import string_types
import numpy as np
-from yt.funcs import *
+from yt.funcs import \
+ mylog, get_pbar, iterable, ensure_list
from yt.utilities.physical_constants import clight
from yt.utilities.cosmology import Cosmology
from yt.utilities.orientation import Orientation
from yt.utilities.fits_image import assert_same_wcs
from yt.utilities.parallel_tools.parallel_analysis_interface import \
- communication_system, parallel_root_only, get_mpi_type, \
- parallel_capable
+ communication_system, parallel_root_only, get_mpi_type, \
+ parallel_capable
from yt.units.yt_array import YTQuantity, YTArray, uconcatenate
import h5py
from yt.utilities.on_demand_imports import _astropy
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/photon_simulator/setup.py
--- a/yt/analysis_modules/photon_simulator/setup.py
+++ b/yt/analysis_modules/photon_simulator/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/photon_simulator/spectral_models.py
--- a/yt/analysis_modules/photon_simulator/spectral_models.py
+++ b/yt/analysis_modules/photon_simulator/spectral_models.py
@@ -11,11 +11,12 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import h5py
import numpy as np
import os
-from yt.funcs import *
-from yt.units.yt_array import YTQuantity
-import h5py
+
+from yt.funcs import mylog
+from yt.units.yt_array import YTArray, YTQuantity
from yt.utilities.on_demand_imports import _astropy, _scipy
from yt.utilities.physical_constants import hcgs, clight, erg_per_keV, amu_cgs
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/photon_simulator/tests/test_cluster.py
--- a/yt/analysis_modules/photon_simulator/tests/test_cluster.py
+++ b/yt/analysis_modules/photon_simulator/tests/test_cluster.py
@@ -10,11 +10,13 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from yt.testing import *
+from yt.analysis_modules.photon_simulator.api import \
+ TableApecModel, TableAbsorbModel, \
+ ThermalPhotonModel, PhotonList
from yt.config import ytcfg
-from yt.analysis_modules.photon_simulator.api import *
+from yt.testing import requires_file
from yt.utilities.answer_testing.framework import requires_ds, \
- GenericArrayTest, data_dir_load
+ GenericArrayTest, data_dir_load
import numpy as np
def setup():
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/ppv_cube/setup.py
--- a/yt/analysis_modules/ppv_cube/setup.py
+++ b/yt/analysis_modules/ppv_cube/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/ppv_cube/tests/test_ppv.py
--- a/yt/analysis_modules/ppv_cube/tests/test_ppv.py
+++ b/yt/analysis_modules/ppv_cube/tests/test_ppv.py
@@ -15,7 +15,7 @@
import yt.units as u
from yt.utilities.physical_constants import kboltz, mh, clight
import numpy as np
-from yt.testing import *
+from yt.testing import assert_allclose_units
def setup():
"""Test specific setup."""
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/radmc3d_export/tests/test_radmc3d_exporter.py
--- a/yt/analysis_modules/radmc3d_export/tests/test_radmc3d_exporter.py
+++ b/yt/analysis_modules/radmc3d_export/tests/test_radmc3d_exporter.py
@@ -11,13 +11,13 @@
#-----------------------------------------------------------------------------
import yt
-from yt.testing import *
+from yt.testing import assert_allclose
from yt.analysis_modules.radmc3d_export.api import RadMC3DWriter
from yt.utilities.answer_testing.framework import \
AnswerTestingTest, \
requires_ds
-from yt.config import ytcfg
import tempfile
+import numpy as np
import os
import shutil
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/setup.py
--- a/yt/analysis_modules/setup.py
+++ b/yt/analysis_modules/setup.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
-import sys
+
+
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('analysis_modules', parent_package, top_path)
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/spectral_integrator/setup.py
--- a/yt/analysis_modules/spectral_integrator/setup.py
+++ b/yt/analysis_modules/spectral_integrator/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/star_analysis/setup.py
--- a/yt/analysis_modules/star_analysis/setup.py
+++ b/yt/analysis_modules/star_analysis/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/star_analysis/sfr_spectrum.py
--- a/yt/analysis_modules/star_analysis/sfr_spectrum.py
+++ b/yt/analysis_modules/star_analysis/sfr_spectrum.py
@@ -18,7 +18,6 @@
import numpy as np
import h5py
import math
-import itertools
from yt.config import ytcfg
from yt.extern.six.moves import zip as izip
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/sunrise_export/sunrise_exporter.py
--- a/yt/analysis_modules/sunrise_export/sunrise_exporter.py
+++ b/yt/analysis_modules/sunrise_export/sunrise_exporter.py
@@ -19,14 +19,17 @@
except ImportError:
pass
+import os
import time
import numpy as np
-from yt.funcs import *
+
import yt.utilities.lib.api as amr_utils
+
+from yt import add_field
+from yt.funcs import get_pbar, mylog
from yt.utilities.physical_constants import \
kpc_per_cm, \
sec_per_year
-from yt.mods import *
def export_to_sunrise(ds, fn, star_particle_type, fc, fwidth, ncells_wide=None,
debug=False,dd=None,**kwargs):
@@ -492,7 +495,7 @@
idxst = dd["particle_type"] == star_type
#make sure we select more than a single particle
- assert na.sum(idxst)>0
+ assert np.sum(idxst)>0
if pos is None:
pos = np.array([dd["particle_position_%s" % ax]
for ax in 'xyz']).transpose()
@@ -543,7 +546,7 @@
#make sure we have nonzero particle number
assert pd_table.data.shape[0]>0
- return pd_table,na.sum(idx)
+ return pd_table,np.sum(idx)
def add_fields():
@@ -559,12 +562,8 @@
# SFR in a cell. This assumes stars were created by the Cen & Ostriker algorithm
# Check Grid_AddToDiskProfile.C and star_maker7.src
star_mass_ejection_fraction = data.ds.get_parameter("StarMassEjectionFraction",float)
- star_maker_minimum_dynamical_time = 3e6 # years, which will get divided out
- dtForSFR = star_maker_minimum_dynamical_time / data.ds["years"]
xv1 = ((data.ds["InitialTime"] - data["creation_time"])
/ data["dynamical_time"])
- xv2 = ((data.ds["InitialTime"] + dtForSFR - data["creation_time"])
- / data["dynamical_time"])
denom = (1.0 - star_mass_ejection_fraction * (1.0 - (1.0 + xv1)*np.exp(-xv1)))
minitial = data["ParticleMassMsun"] / denom
return minitial
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/sunyaev_zeldovich/setup.py
--- a/yt/analysis_modules/sunyaev_zeldovich/setup.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/sunyaev_zeldovich/tests/test_projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/tests/test_projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/tests/test_projection.py
@@ -11,12 +11,12 @@
#-----------------------------------------------------------------------------
from yt.frontends.stream.api import load_uniform_grid
-from yt.funcs import get_pbar, mylog
+from yt.funcs import get_pbar
from yt.utilities.physical_constants import cm_per_kpc, K_per_keV, \
- mh, cm_per_km, kboltz, Tcmb, hcgs, clight, sigma_thompson
-from yt.testing import *
+ mh, cm_per_km, kboltz, Tcmb, hcgs, clight, sigma_thompson
+from yt.testing import requires_module, assert_almost_equal
from yt.utilities.answer_testing.framework import requires_ds, \
- GenericArrayTest, data_dir_load, GenericImageTest
+ GenericArrayTest, data_dir_load, GenericImageTest
try:
from yt.analysis_modules.sunyaev_zeldovich.projection import SZProjection, I0
except ImportError:
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/two_point_functions/setup.py
--- a/yt/analysis_modules/two_point_functions/setup.py
+++ b/yt/analysis_modules/two_point_functions/setup.py
@@ -1,8 +1,4 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
def configuration(parent_package='', top_path=None):
diff -r deeb92e93357a433dd56e83a339a2192ca42e9e1 -r 4bfdb0ddccdb3bad26724484a89149b5a7ecfe51 yt/analysis_modules/two_point_functions/two_point_functions.py
--- a/yt/analysis_modules/two_point_functions/two_point_functions.py
+++ b/yt/analysis_modules/two_point_functions/two_point_functions.py
@@ -14,17 +14,19 @@
#-----------------------------------------------------------------------------
import h5py
-from yt.mods import *
-#from yt.utilities.math_utils import *
-from yt.utilities.performance_counters import yt_counters, time_function
+import numpy as np
+
+from yt.funcs import mylog
+from yt.utilities.performance_counters import yt_counters
from yt.utilities.parallel_tools.parallel_analysis_interface import ParallelAnalysisInterface, parallel_blocking_call, parallel_root_only
try:
- from yt.utilities.kdtree.api import *
+ from yt.utilities.kdtree.api import \
+ fKD, free_tree, create_tree
except ImportError:
mylog.debug("The Fortran kD-Tree did not import correctly.")
-import math, sys, itertools, inspect, types, time
+import math, inspect, time
from collections import defaultdict
sep = 12
@@ -117,7 +119,7 @@
self.index = ds.index
self.center = (ds.domain_right_edge + ds.domain_left_edge)/2.0
# Figure out the range of ruler lengths.
- if length_range == None:
+ if length_range is None:
length_range = [math.sqrt(3) * self.ds.index.get_smallest_dx(),
self.min_edge/2.]
else:
@@ -679,7 +681,7 @@
"""
for fset in self._fsets:
# Only operate on correlation functions.
- if fset.corr_norm == None: continue
+ if fset.corr_norm is None: continue
fp = self.comm.write_on_root("%s_correlation.txt" % fset.function.__name__)
line = "# length".ljust(sep)
line += "\\xi".ljust(sep)
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