rhayes777 / PyAutoFit

PyAutoFit: Classy Probabilistic Programming
https://pyautofit.readthedocs.io/
MIT License
59 stars 11 forks source link

Inequalities in Prior linking #65

Closed Jammy2211 closed 4 years ago

Jammy2211 commented 4 years ago

we can current set two parameters equal to one anoother:

model.param1 = model.param2

It'd be good if we could define an inequality, so that is param2 is greater than param1 the model is instantly resampled:

model.param1 > model.param2.

Jammy2211 commented 4 years ago

Couple of issues:

First, I can't seem to set up an assertion using a PriorModel, e.g.:

    gaussian_0 = af.PriorModel(al.lp.EllipticalGaussian)
    gaussian_1 = af.PriorModel(al.lp.EllipticalGaussian)

    gaussian_0.add_assertion(assertion=gaussian_0.sigma > gaussian_1.sigma)

The examples in the unit tests seem to set the model up as a ModelMapper - this isn't the API used in pipelines. Any thoguhts?

Secondly, the assetion are checked in the function instance_from_unit_vector. We want the assertion to work on physical values, e.g. we want the physical sigma value of gaussian 1 above to be lower than gaussian 0 irrespective of their priors. Are we safe to simply move the assertion functioon to physical_instance_from_unit_vector (or all appropriate functions) or does this require a little more thought?

rhayes777 commented 4 years ago

Assertions are now checked when instance_for_arguments is called; it shouldn't matter which object they're attached to

rhayes777 commented 4 years ago

Oh and yeah it works on arguments which is a dictionary mapping priors to physical values so it's physical values that are being compared.

Jammy2211 commented 4 years ago

How do I pass an assertion to a pipeline?

The line

gaussian_0.add_assertion(gaussian_0.sigma < gaussian_1.sigma)

Passes a bool to the add_assetion method, not an AbstractAssertion.

rhayes777 commented 4 years ago

It only works on Priors

On 23 Feb 2020, at 17:41, James Nightingale notifications@github.com wrote:

How do I pass an assertion to a pipeline?

The line

gaussian_0.add_assertion(gaussian_0.sigma < gaussian_1.sigma)

Passes a bool to the add_assetion method, not an AbstractAssertion.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/rhayes777/PyAutoFit/issues/65?email_source=notifications&email_token=ABQRGMTTH6G4CZUONUFDID3REKYNPA5CNFSM4KYXPXHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMWCHNI#issuecomment-590095285, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQRGMX27PH7KRLI6R7JPDTREKYNPANCNFSM4KYXPXHA.

Jammy2211 commented 4 years ago

Do I use something instead of a PriorModel to make the thing with Priors?

Bare in mind I'm also doing things like:

    gaussian_0 = af.PriorModel(al.lp.EllipticalGaussian)
    gaussian_1 = af.PriorModel(al.lp.EllipticalGaussian)

    gaussian_1.centre = gaussian_0.centre

I can over ride the sigmas with priors if needs be!