Skip to content

UFloat.error_components, method or property? #336

@jagerber48

Description

@jagerber48

In 3.x the AffineScalarFunc class has two attributes that tell users about the contribution of other Variables to the uncertainty: the derivatives property and the error_component method.

x = ufloat(1, 0.1)
y = x**2

y.derivatives
y.error_components()

One is a property, so it is accessed without the () parentheses, the other is a method so it needs the parentheses (). In 4.x the derivatives property is being removed from the UFloat class. error_components remains. This issue is asking if error_components should be changed to a property.

  • The pro is that error_components() is just returning something it reads off the UFloat._uncertainty (which is a UCombo) attribute. I would say semantically it is more like a property than a method. The simpler notation would reflect that.
  • The downside is that it would not be backwards compatible. Also I generally find it tricky to remember when an attribute is a property and whether or not I should use (). This change in behavior will make that even worse.

I would take a weak preference towards changing error_components to be a property and will do so if no one pushes back. But I'm very open to pushback. If we want to change it we need to put in a deprecation/change coming warning in 3.2.x.

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