Skip to content

Commit af799ad

Browse files
committed
add printValErr function
1 parent 624606a commit af799ad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mctools/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
__all__ = ["common", "fluka", "mcnp", "phits" ]
33

44
import subprocess, os, sys
5-
from math import sqrt
5+
from math import sqrt, log10, floor
66
import numpy as np
77

8+
def printValErr(val, err):
9+
""" Print value and its error in the () notation """
10+
tmp=-floor(log10(err))
11+
print('{:.{prec}f}({:.0f})'.format(val, floor(err * (10**tmp)), prec=tmp))
12+
813
def L2E(l, m=1.674927351e-27): #constants.physical_constants['neutron mass'][0]):
914
"""
1015
Angstrom to MeV converter.

0 commit comments

Comments
 (0)