Skip to content

Should we encourage direct UFloat instantiation? #328

@jagerber48

Description

@jagerber48

In uncertainties<4.0 the convention has been to instantiate "numbers with uncertainty" using the ufloat factory method. This is a bit strange with respect to typical python conventions where you would instantiate the class directly. I think it was maybe done this way because in the previous architecture there were two classes users would end up with during uncertainties calculations. Variable objects resulted from the ufloat call, but AffineScalarFunc objects arose as a result of any mathematical manipulation of Variable objects.

However, in #262, the ufloat function returns a UFloat object and mathematical manipulations also result in UFloat objects. I would say it would be more in line with python convention if we started encouraging direct instantiation via the UFloat constructor and discouraging the ufloat function. We will always have to keep the ufloat convention because it so deeply ingrained in the code for anyone using uncertainties that I wouldn't ever suggest deprecating it.

My vote is that we SHOULD start encouraging UFloat and discouraging ufloat. I recommend a prominent comment in the documentation to this effect, and then using UFloat throughout the documentation and never using ufloat. Eventually we convert all the tests over to UFloat (except for 1 or 2 to prove that ufloat continues to be a faithful wrapper). If we think it is important the prominent note can reassure users that there are no plans to deprecate ufloat ever.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions