CUQI-DTU / CUQIpy

https://cuqi-dtu.github.io/CUQIpy/
Apache License 2.0
41 stars 7 forks source link

Generalize the code that identifies the correct conjugate pair #454

Open amal-ghamdi opened 1 month ago

amal-ghamdi commented 1 month ago
          one suggestion here for generality, so if more conjugate pairs are created, no need to update this if statement and to avoid the need to repeat prior and likelihood type check condition twice, here and in validate target. something like:
self._conjugatepair=None
# loop over conjugatepair classes and try to create it object from it for the target
for subclass in ConjugatePair subclasses: # conceptual line
    if self._conjugatepair is None:
        if subclass._is_target_valid(self.target): # could be static class that implements a part of validate_target that check the likelihood and prior
            self._conjugatepair=subclass(self.target)

if self._conjugatepair==None
    raise ValueError(f"No conjugate pair ...")

_Originally posted by @amal-ghamdi in https://github.com/CUQI-DTU/CUQIpy/pull/444#discussion_r1662737866_