Skip to content

Commit 2afae82

Browse files
committed
asserts added
1 parent 479cfc6 commit 2afae82

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

mctools/fluka/sigma.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,12 @@ def generateInputs(args,tmp):
5353
E = pow(10, e)
5454
fname = f"sigma-{i:0>3}.inp"
5555
fname = os.path.join(tmp,fname);
56-
# print(fname, file=sys.stderr)
5756
with open(fname, "w") as f:
5857
with redirect_stdout(f):
5958
inp(args.projectile, args.material, E, args.include)
6059

6160
def run(tmp):
62-
if which("parallel") is None:
63-
print("ERROR: GNU parallel is not installed", file=sys.stderr)
61+
assert which("parallel"), "GNU parallel is not installed"
6462

6563
command = f"cd {tmp} && parallel --bar $FLUPRO/flutil/rfluka -N0 -M1 ::: sigma*inp"
6664
return_value = os.system(command)
@@ -99,8 +97,6 @@ def fixEmin(args):
9997

10098
return emin
10199

102-
103-
104100
def main():
105101
""" A simple FLUKA cross section plotter """
106102
parser = argparse.ArgumentParser(description=main.__doc__,
@@ -117,9 +113,8 @@ def main():
117113

118114
args.emin = fixEmin(args)
119115

120-
if args.emin > args.emax:
121-
print("ERROR: emin > emax", file=sys.stderr)
122-
return 1
116+
assert args.emin < args.emax, "emin > emax"
117+
assert args.npoints > 1, "Number of energy points is too small"
123118

124119
data = {}
125120
with tempfile.TemporaryDirectory(prefix="sigma.") as tmp:

0 commit comments

Comments
 (0)