Skip to content

EngUnit doesn't handle __init__ from other EngUnits properly #28

@SMMB-DEV

Description

@SMMB-DEV

Suppose I want to divide a voltage by a resistance and give it the unit A.

V = EngUnit(5, unit='V')
R = EngUnit(1.2, unit='Ω')
I = V / R
I.unit = 'A'

If I instead do this:

I = EngUnit(V / R, unit='A')

when I try to print I, I get an exception saying "'EngNumber' object has no attribute 'number'".

EngUnit has an eng_num member of type EngNumber. If the value passed to EngUnit.__init__() isn't a string, it tries to create an EngNumber direcly from value. Inside EngNumber.__init__(), value has to be one of str, int, float, EngNumber or numpy.integer and since the value here is none of those (EngUnit), it doesn't create the number member of EngNumber.

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