Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Don't miss actually setting the lifetimes...
Browse files Browse the repository at this point in the history
  • Loading branch information
EinarElen authored and tomeichlersmith committed Nov 20, 2023
1 parent 93bc05e commit 550e9bc
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions python/kaon_physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,19 @@ def __setattr__(self, key, value):
"""
if 'branching_ratios' in key:
# super().__setattr__(key, value)
if not isinstance(value, list):
raise TypeError(f'Values of branching ratios ({key}) need to be lists')
total_branching_ratio = sum(value)
if abs(total_branching_ratio- 1) > 0.05:
raise ValueError(f'Total of branching ratios in {key} significantly different from one, was {total_branching_ratio}: {value}.')
super().__setattr__(key, value)
elif 'lifetime' in key:
if not isinstance(value, float):
raise TypeError(f'Lifetime parameter ({key}) needs to be floating-point')
if value < 0:
raise ValueError(f'Lifetime parameter ({key}) needs to be positive')
pass
else:
super().__setattr__(key, value)

# Everything ok!
super().__setattr__(key, value)

def __repr__(self):
return (
Expand Down

0 comments on commit 550e9bc

Please sign in to comment.