Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return self.msg
class YTHubRegisterError(YTException):
def __str__(self):
return "You must create an API key before uploading. See " + \
"https://data.yt-project.org/getting_started.html"
class YTNoFilenamesMatchPattern(YTException):
def __init__(self, pattern):
self.pattern = pattern
def __str__(self):
return "No filenames were found to match the pattern: " + \
"'%s'" % (self.pattern)
class YTNoOldAnswer(YTException):
def __init__(self, path):
self.path = path
def __str__(self):
return "There is no old answer available.\n" + \
str(self.path)
class YTCloudError(YTException):
def __init__(self, path):
self.path = path
def __str__(self):
return "Failed to retrieve cloud data. Connection may be broken.\n" + \
str(self.path)
class YTEllipsoidOrdering(YTException):
def _validate_unit_vectors(normal_vector, north_vector):
# Make sure vectors are unitless
if north_vector is not None:
north_vector = YTArray(north_vector, "", dtype='float64')
if normal_vector is not None:
normal_vector = YTArray(normal_vector, "", dtype='float64')
if not np.dot(normal_vector, normal_vector) > 0:
raise YTException("normal_vector cannot be the zero vector.")
if north_vector is not None and _aligned(north_vector, normal_vector):
raise YTException("normal_vector and north_vector cannot be aligned.")
return normal_vector, north_vector
data_url = "http://yt-project.org/data"
def _get_data_file(table_type, data_dir=None):
data_file = "%s_emissivity_v%d.h5" % (table_type, data_version[table_type])
if data_dir is None:
supp_data_dir = ytcfg.get("yt", "supp_data_dir")
data_dir = supp_data_dir if os.path.exists(supp_data_dir) else "."
data_path = os.path.join(data_dir, data_file)
if not os.path.exists(data_path):
msg = "Failed to find emissivity data file %s! " % data_file + \
"Please download from http://yt-project.org/data!"
mylog.error(msg)
raise IOError(msg)
return data_path
class EnergyBoundsException(YTException):
def __init__(self, lower, upper):
self.lower = lower
self.upper = upper
def __str__(self):
return "Energy bounds are %e to %e keV." % \
(self.lower, self.upper)
class ObsoleteDataException(YTException):
def __init__(self, table_type):
data_file = "%s_emissivity_v%d.h5" % (table_type, data_version[table_type])
self.msg = "X-ray emissivity data is out of date.\n"
self.msg += "Download the latest data from %s/%s." % (data_url, data_file)
def __str__(self):
return self.msg
self.weight_field, self.weight_field_ptype)
else:
weight_msg = ""
return msg + weight_msg
class YTBooleanObjectError(YTException):
def __init__(self, bad_object):
self.bad_object = bad_object
def __str__(self):
v = "Supplied:\n%s\nto a boolean operation" % (self.bad_object)
v += " but it is not a YTSelectionContainer3D object."
return v
class YTBooleanObjectsWrongDataset(YTException):
def __init__(self):
pass
def __str__(self):
return "Boolean data objects must share a common dataset object."
class YTIllDefinedAMR(YTException):
def __init__(self, level, axis):
self.level = level
self.axis = axis
def __str__(self):
msg = (
"Grids on the level {} are not properly aligned with cell edges "
"on the parent level ({} axis)"
).format(self.level, self.axis)
def __init__(self, ds, radius, smallest_cell):
YTException.__init__(self, ds=ds)
self.radius = radius
self.smallest_cell = smallest_cell
def __str__(self):
return "%0.5e < %0.5e" % (self.radius, self.smallest_cell)
class YTAxesNotOrthogonalError(YTException):
def __init__(self, axes):
self.axes = axes
def __str__(self):
return "The supplied axes are not orthogonal. %s" % (self.axes)
class YTNoDataInObjectError(YTException):
def __init__(self, obj):
self.obj_type = getattr(obj, "_type_name", "")
def __str__(self):
s = "The object requested has no data included in it."
if self.obj_type == "slice":
s += " It may lie on a grid face. Try offsetting slightly."
return s
class YTFieldNotFound(YTException):
def __init__(self, fname, ds):
self.fname = fname
self.ds = ds
def __str__(self):
return "Could not find field '%s' in %s." % (self.fname, self.ds)
self.ftype in self.ds.particle_types:
return ("Could not find field type '%s'. " +
"This field type is a known particle type for this dataset. " +
"Try adding this field with particle_type=True.") % self.ftype
else:
return "Could not find field type '%s'." % (self.ftype)
class YTSimulationNotIdentified(YTException):
def __init__(self, sim_type):
YTException.__init__(self)
self.sim_type = sim_type
def __str__(self):
return "Simulation time-series type %s not defined." % self.sim_type
class YTCannotParseFieldDisplayName(YTException):
def __init__(self, field_name, display_name, mathtext_error):
self.field_name = field_name
self.display_name = display_name
self.mathtext_error = mathtext_error
def __str__(self):
return ("The display name \"%s\" "
"of the derived field %s "
"contains the following LaTeX parser errors:\n" ) \
% (self.display_name, self.field_name) + self.mathtext_error
class YTCannotParseUnitDisplayName(YTException):
def __init__(self, field_name, unit_name, mathtext_error):
self.field_name = field_name
self.unit_name = unit_name
self.mathtext_error = mathtext_error
for store, ds in self.piter(return_values):
store.result = []
for task in tasks:
try:
style = inspect.getargspec(task.eval)[0][1]
if style == 'ds':
arg = ds
elif style == 'data_object':
if obj is None:
obj = DatasetSeriesObject(self, "all_data")
arg = obj.get(ds)
rv = task.eval(arg)
# We catch and store YT-originating exceptions
# This fixes the standard problem of having a sphere that's too
# small.
except YTException:
pass
store.result.append(rv)
return [v for k, v in sorted(return_values.items())]
def __str__(self):
return "Boolean data objects must share a common dataset object."
class YTIllDefinedAMR(YTException):
def __init__(self, level, axis):
self.level = level
self.axis = axis
def __str__(self):
msg = (
"Grids on the level {} are not properly aligned with cell edges "
"on the parent level ({} axis)"
).format(self.level, self.axis)
return msg
class YTIllDefinedParticleData(YTException):
pass
class YTIllDefinedAMRData(YTException):
pass
class YTInconsistentGridFieldShape(YTException):
def __init__(self, shapes):
self.shapes = shapes
def __str__(self):
msg = "Not all grid-based fields have the same shape!\n"
for name, shape in self.shapes:
msg += " Field {} has shape {}.\n".format(name, shape)
return msg
class YTInconsistentParticleFieldShape(YTException):
def __str__(self):
return "Integer domain overflow: %s in %s" % (
self.dims, self.dd)
class YTIllDefinedFilter(YTException):
def __init__(self, filter, s1, s2):
self.filter = filter
self.s1 = s1
self.s2 = s2
def __str__(self):
return "Filter '%s' ill-defined. Applied to shape %s but is shape %s." % (
self.filter, self.s1, self.s2)
class YTIllDefinedParticleFilter(YTException):
def __init__(self, filter, missing):
self.filter = filter
self.missing = missing
def __str__(self):
msg = ("\nThe fields\n\t{},\nrequired by the \"{}\" particle filter, "
"are not defined for this dataset.")
f = self.filter
return msg.format("\n".join([str(m) for m in self.missing]), f.name)
class YTIllDefinedBounds(YTException):
def __init__(self, lb, ub):
self.lb = lb
self.ub = ub
def __str__(self):