Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many exceptions in enterprise/signals/parameter.py cannot be triggered #364

Open
vhaasteren opened this issue Nov 7, 2023 · 0 comments
Open
Labels

Comments

@vhaasteren
Copy link
Member

The parameter.py class contains quite a few lines that are not unit tested. When adding the PPF functions I had to look into this (because of the codecov), and it turns out many potential exceptions in the original code are testing for the wrong things and cannot be triggered.

Example:

    def get_logpdf(self, value=None, **kwargs):
        # RvH: This exception cannot be triggered
        if not isinstance(self, Parameter):
            raise TypeError("You can only call get_logpdf() on an " "instantiated (named) Parameter.")

This TypeError supposedly is thrown when you use the class factory to obtain a Parameter, such as with par = Uniform(pmin=0, pmax=1). If you then try to use par.get_logpdf(0.5) this should not work, because the class is not instantiated (named). Instead, you need to do: par = Uniform(pmin=0, pmax=1)('testpar').

Thing is, you can never call get_logpdf using the class definition, because you are then not passing self to the function. So that exception can never be triggered. This kind of thing happens a lot in the parameter module. A solution would be to just remove all the exceptions that cannot be triggered.

@vhaasteren vhaasteren added the bug label Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant