PYTHON: Convert returns to exceptions in Amun class.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2021-10-04 22:24:08 -03:00
parent 8e125253f7
commit 61d5eeb839

View File

@ -927,23 +927,19 @@ class Amun:
sup = np.array(dup)
if extent != None:
if len(extent) != 2 * self.attributes['ndims']:
print("Wrong dimension of the extent!")
return None
raise Exception("Wrong dimensions of the argument 'extent'!")
slo = np.array(extent)[0::2]
sup = np.array(extent)[1::2]
if any(slo > dup) or any(sup < dlo) or any (slo >= sup):
print("Wrong order in the extent!")
return None
raise Exception("Wrong order of the dimensions in the argument 'extent'!")
if isinstance(maxlev,int):
if 1 <= maxlev <= self.attributes['maxlev']:
shrink = 2**(self.attributes['maxlev']-maxlev)
elif maxlev > self.attributes['maxlev']:
sys.stdout.write("maxlev should be between 1 and {}.\n".format(self.attributes['maxlev']))
return None
raise Exception("Argument 'maxlev' should be between 1 and {}.\n".format(self.attributes['maxlev']))
else:
sys.stdout.write("maxlev must be an integer between 1 and {}.\n".format(self.attributes['maxlev']))
return None
raise Exception("Argument 'maxlev' must be an integer between 1 and {}.\n".format(self.attributes['maxlev']))
bm = np.array([ self.attributes['ncells'] ]*self.attributes['ndims'])
@ -1034,8 +1030,7 @@ class Amun:
label = dataset_name
if self.attributes['ndims'] < 3:
print("Conversion to OverlappedAMR works only with 3D snapshots!")
return None
raise Exception("Conversion to OverlappedAMR works only with 3D snapshots!")
base = OcBase([self.attributes['xmin'], self.attributes['ymin'], self.attributes['zmin']], \
[self.attributes['xlen'], self.attributes['ylen'], self.attributes['zlen']], \