Skip to content

Class interface: Make properites that should not be set directly private #3

@meliache

Description

@meliache

The BtoV class contains properties like BtoV.mL are public and can be set/modified after initializing the class, e.g. BtoV.mL = ..., but should not. The reason is that mL is used to set the attributes BtoV.kinematics and subsequently BtoV.w_max, BtoV.w_min etc, and those will not get updated if you set the mL property.

I suggest using leading underscore to mark those properites that should just be set via the constructor and are otherwise internal as private by making their names have leading underscores. We could also add a property function called mL that allows to obtain the stored lepton mass, but doesn't allow for it being set. Then, optionally, we could also add a setter function of the same name, e.g. something like:

    @property
    def mL(self):
        return self._mL

    @mL.setter
    def mL(self, value):
        if value < 0:
            raise ValueError(...)
        # update value
        self._mL = value
        # update kinematics
        self.kinematics = ... 
        self.w_max = ...

I agree that we want to make this idiot prove.
If mL should be private, or a property with setter (so that it also sets it correctly in all other > classes of the composite class) is a thing to debate.

Originally posted by @MarkusPrim in #2 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions