Skip to content

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

@vhaasteren

Description

@vhaasteren

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions