Open Helveg opened 10 months ago
Hi @Helveg,
I'd agree with the API as written here:
x = 42 * U.m2
# Should give an error; numbers are not quantities
y = x + 1
# Error, wrong unit
y = x + 1 * U.Ohm
# That works, though
y = x + 1 * U.cm2
If you want the magnitude of a quantity, use
x = 42 * U.m2
# as currently set
x_m = x.value
# safer: force your expected unit
x_m = x.value_as(U.cm2)
x.value
and x.value_as
solve this, but they're not listed in dir(x)
(and so likely also not easily found in other places?), which should list all regularly available members of an object. I'd guess there's an issue with the quantity class's bindings if it has no visible members.
I just checked, at least for v0.10.0 it seems like expected:
In [8]: q = 4 * U.ns
In [9]: dir(q)
Out[9]:
['__add__',
'__class__',
'__delattr__',
[...]
'__subclasshook__',
'__truediv__',
'units',
'value',
'value_as']
Ok!
Wait, did you check the return value of an arbor function like arbor.membrane_capacitance(1 * units.F / units.m2)
the way I did in the original report?
Aha, no I didn't, led astray by the title mentioning 'stubs'. Yes, that interface leaves something to be desired, you can't even extract the value.
yea my massive text blurb of my interpreter adventures isn't the greatest bug report either ;) sorry :)
There's some stubs like
arbor.membrane_capacitance
that aren't very Python friendly, to retrieve the value it seems I have to parse their string representations:There's also
arbor.axial_resistivity
and probably others. These are returned fromdecor.paintings()
and make it pretty opaque to inspection.