Skip to content

Support rounding of UnitScalars in Python 3 #84

@JCorson

Description

@JCorson

In Python 3, I am seeing the following when attempting to round a UnitScalar.

In [1]: from scimath.units.api import UnitScalar

In [2]: u = UnitScalar(10.1234, units="gram")

In [3]: u
Out[3]: UnitScalar(10.1234, units='0.001*kg')

In [4]: round(u)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-dfdf7062be34> in <module>()
----> 1 round(u)

TypeError: type UnitScalar doesn't define __round__ method

Is this expected?

This is with scimath 4.2.0.

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