flav-io / flavio

A Python package for flavour physics phenomenology in the Standard model and beyond
http://flav-io.github.io/
MIT License
71 stars 62 forks source link

Strange side effect of calling Observable.get_measurements() #89

Closed bednya closed 5 years ago

bednya commented 5 years ago

Hi @DavidMStraub, I was trying to play with handy getMeasurements(), but encountered a very strange side effect:

The code:

import flavio
print('Flavio version:', flavio.__version__)
print('SM_prediction before get_measurements()', flavio.sm_prediction('BR(Bs->mumu)'))
print('Measurements:', flavio.Observable('BR(Bs->mumu)').get_measurements())
print('SM_prediction after get_measurements()', flavio.sm_prediction('BR(Bs->mumu)'))

produces the following error on the second call to sm_predictions():

Flavio version: 1.5.0
SM_prediction before get_measurements() 3.66775536885e-09
Measurements: ['CMS Bs->mumu 2013', 'LHCb Bs->mumu 2017', 'ATLAS Bs->mumu 2018', 'inofficial combination Bs->mumu 2019']
Traceback (most recent call last):
  File "bug_get_measurements.py", line 5, in <module>
    print('SM_prediction after get_measurements()', flavio.sm_prediction('BR(Bs->mumu)'))
  File "~/.local/lib/python3.6/site-packages/flavio/functions.py", line 40, in sm_prediction
    return obs.prediction_central(flavio.default_parameters, wc_sm, *args, **kwargs)
  File "~/.local/lib/python3.6/site-packages/flavio/classes.py", line 559, in prediction_central
    return self.prediction.get_central(constraints_obj, wc_obj, *args, **kwargs)
AttributeError: 'NoneType' object has no attribute 'get_central'

Am I doing something wrong?

All the best, Alexander

DavidMStraub commented 5 years ago

Hi,

I think it's just a typo. It should be:

flavio.Observable['BR(Bs->mumu)'].get_measurements()

By using round brackets, you are effectively creating a new observable that is called 'BR(Bs->mumu)', for which there are apparently measurements, but for which no prediction function is defined yet.

bednya commented 5 years ago

Thanks, David!

My fault:( Indeed, square brackets solve the issue:)