Skip to content

Commit

Permalink
Fehlerwerfen
Browse files Browse the repository at this point in the history
  • Loading branch information
douglas-fva committed Jan 22, 2024
1 parent fef68b4 commit bdc9adc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions np_ones_zeros_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ def zeros(countx: int, county:int):
return [[0. for _ in range(county)] for _ in range(countx)]

def check_tolerance(a, b, abs_tol=0.0, rel_tol=1e-09, check_both=False):
if check_both:
return abs(a-b) <= min(rel_tol * max(abs(a), abs(b)), abs_tol)
else:
return (abs(a-b) <= rel_tol * max(abs(a), abs(b))) or (abs(a-b) <= abs_tol)

if type(abs_tol) is float and type(rel_tol) is float:
if check_both:
return abs(a-b) <= min(rel_tol * max(abs(a), abs(b)), abs_tol)
else:
return (abs(a-b) <= rel_tol * max(abs(a), abs(b))) or (abs(a-b) <= abs_tol)
else:
raise Exception("The values of abs or tol are wrong "+ str(abs_tol)+" "+str(rel_tol) +" "+ str(a)+ " "+ str(b))

def check_equality(a, b, abs=0.0, rel=1e-09, check_both=False):
if type(a) is float and type(b) is float:
Expand Down

0 comments on commit bdc9adc

Please sign in to comment.