Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def can_run_ds(ds_fn, file_check = False):
result_storage = AnswerTestingTest.result_storage
if isinstance(ds_fn, Dataset):
return result_storage is not None
path = ytcfg.get("yt", "test_data_dir")
if not os.path.isdir(path):
return False
if file_check:
return os.path.isfile(os.path.join(path, ds_fn)) and \
result_storage is not None
try:
load(ds_fn)
except YTOutputNotIdentified:
if ytcfg.getboolean("yt", "requires_ds_strict"):
if result_storage is not None:
result_storage['tainted'] = True
raise
return False
return result_storage is not None
def standard_small_simulation(ds_fn, fields):
if not can_run_ds(ds_fn): return
dso = [None]
tolerance = ytcfg.getint("yt", "answer_testing_tolerance")
bitwise = ytcfg.getboolean("yt", "answer_testing_bitwise")
for field in fields:
if bitwise:
yield GridValuesTest(ds_fn, field)
if 'particle' in field: continue
for dobj_name in dso:
for axis in [0, 1, 2]:
for weight_field in [None, "Density"]:
yield ProjectionValuesTest(
ds_fn, axis, field, weight_field,
dobj_name, decimals=tolerance)
yield FieldValuesTest(
ds_fn, field, dobj_name, decimals=tolerance)
def __init__(self):
self.counters = defaultdict(lambda: 0.0)
self.counting = defaultdict(lambda: False)
self.starttime = defaultdict(lambda: 0)
self.endtime = defaultdict(lambda: 0)
self._on = ytcfg.getboolean("yt", "timefunctions")
self.exit()
You should have received a copy of the GNU General Public License
along with this program. If not, see .
"""
import sys
from yt.logger import enkiLogger as mylog
from yt.config import ytcfg
from yt.arraytypes import *
# Now we import the SWIG enzo interface
# Note that we're going to try super-hard to get the one that's local for the
# user
sp = sys.path
if ytcfg.getboolean("lagos","useswig"):
if ytcfg.has_option("SWIG", "EnzoInterfacePath"):
swig_path = ytcfg.get("SWIG","EnzoInterfacePath")
mylog.info("Using %s as path to SWIG Interface", swig_path)
sys.path = sys.path[:1] + [swig_path] + sys.path[1:] # We want '' to be the first
try:
import EnzoInterface
mylog.debug("Imported EnzoInterface successfully")
has_SWIG = True
except ImportError, e:
mylog.warning("EnzoInterface failed to import; all SWIG actions will fail")
mylog.warning("(%s)", e)
has_SWIG = False
else:
has_SWIG = False
sys.path = sp
def get_pbar(title, maxval):
"""
This returns a progressbar of the most appropriate type, given a *title*
and a *maxval*.
"""
maxval = max(maxval, 1)
from yt.config import ytcfg
if ytcfg.getboolean("yt", "suppressStreamLogging") or \
"__IPYTHON__" in dir(__builtin__) or \
ytcfg.getboolean("yt", "__withintesting"):
return DummyProgressBar()
elif ytcfg.getboolean("yt", "__withinreason"):
from yt.gui.reason.extdirect_repl import ExtProgressBar
return ExtProgressBar(title, maxval)
elif ytcfg.getboolean("yt", "__parallel"):
return ParallelProgressBar(title, maxval)
widgets = [ title,
pb.Percentage(), ' ',
pb.Bar(marker=pb.RotatingMarker()),
' ', pb.ETA(), ' ']
pbar = pb.ProgressBar(widgets=widgets,
maxval=maxval).start()
return pbar
def __init__(self, ts, num_readers = 1, num_writers = None,
outbase="rockstar_halos", particle_type="all",
force_res=None, total_particles=None, dm_only=False,
particle_mass=None, min_halo_size=25):
if is_root():
mylog.info("The citation for the Rockstar halo finder can be found at")
mylog.info("https://ui.adsabs.harvard.edu/abs/2013ApJ...762..109B")
ParallelAnalysisInterface.__init__(self)
# Decide how we're working.
if ytcfg.getboolean("yt", "inline") is True:
self.runner = InlineRunner()
else:
self.runner = StandardRunner(num_readers, num_writers)
self.num_readers = self.runner.num_readers
self.num_writers = self.runner.num_writers
mylog.info("Rockstar is using %d readers and %d writers",
self.num_readers, self.num_writers)
# Note that Rockstar does not support subvolumes.
# We assume that all of the snapshots in the time series
# use the same domain info as the first snapshots.
if not isinstance(ts, DatasetSeries):
ts = DatasetSeries([ts])
self.ts = ts
self.particle_type = particle_type
self.outbase = six.b(outbase)
self.min_halo_size = min_halo_size
def run_nose(verbose=False, run_answer_tests=False, answer_big_data=False):
import nose, os, sys
from yt.config import ytcfg
nose_argv = sys.argv
nose_argv += ['--exclude=answer_testing','--detailed-errors']
if verbose:
nose_argv.append('-v')
if run_answer_tests:
nose_argv.append('--with-answer-testing')
if answer_big_data:
nose_argv.append('--answer-big-data')
log_suppress = ytcfg.getboolean("yt","suppressStreamLogging")
ytcfg.set("yt","suppressStreamLogging", 'True')
initial_dir = os.getcwd()
yt_file = os.path.abspath(__file__)
yt_dir = os.path.dirname(yt_file)
os.chdir(yt_dir)
try:
nose.run(argv=nose_argv)
finally:
os.chdir(initial_dir)
ytcfg.set("yt","suppressStreamLogging", str(log_suppress))
from new import classobj
from string import strip, rstrip
from math import ceil, floor, log10, pi
import os, os.path, types, exceptions, re
from stat import ST_CTIME
import sets
import time
if ytcfg.getboolean("lagos","useswig"):
try:
from yt.enki import EnzoInterface
except ImportError:
pass
if ytcfg.getboolean("lagos","usefortran"):
try:
import EnzoFortranRoutines
except ImportError:
pass
# Now we import all the subfiles
import PointCombine
from WeaveStrings import *
from EnzoDefs import *
from DerivedFields import *
from DerivedQuantities import quantityInfo
from DataReadingFuncs import *
from ClusterFiles import *
from BaseDataTypes import *
from BaseGridType import *