← Back to team overview

python-quantities-developers team mailing list archive

concerns about zeros

 

I was implementing Quantities.fill(scalar) and it made me think about
assigning zeros to Quantity array elements.
If a quantity is non-dimensionless and someone tries to assign zero to an
array element, an error will be thrown, even if it makes sense to assign a
zero to the element.

 Example:

x = [10, 5, 1, 3]  * BTU

x[1] = 0    # this will throw an error because a float does not have units
of BTU

I worry about this because I imagine that a good deal of algorithms that we
would like to work with Quantities assign zeros to some array elements in
some circumstances, and that will break compatibility. I'm not really sure
how to deal with that.

What do you think?

Follow ups