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.
Suppose I want to divide a voltage by a resistance and give it the unit
A.If I instead do this:
when I try to print
I, I get an exception saying "'EngNumber' object has no attribute 'number'".EngUnit has an
eng_nummember of typeEngNumber. If thevaluepassed to EngUnit.__init__() isn't a string, it tries to create anEngNumberdirecly fromvalue. Inside EngNumber.__init__(),valuehas to be one ofstr,int,float,EngNumberornumpy.integerand since thevaluehere is none of those (EngUnit), it doesn't create thenumbermember ofEngNumber.