After the discussion in PR #138, it seems a more detailed discussion on how to deal with element-wise operations on data structures is handled. The point of contention was:
>>> 1/vector
If vector, a Vector3d object, were to behave like the array data it contains, then this would imply an element-wise operation, i.e. taking the inverse of each element. However, mathematically, division by a vector is undefined. This leads to the dilemma: should the behavior be more maths-like or more array like? The maths definition would better reflect "real life", but a user may expect array-like behavior, and be put off by doing element wise division like:
>>> vector = Vector3d(1/vector.data)
The issue could be avoided with more operators like the ./ operator in Matlab. However, this operator does not exist in Python and it is not possible to add custom operators - they are baked into the language.
Alternatively, one could overload operators which are unused. One could perhaps make use of **, // and ^, which are all valid operators. // could be used to represent Matlab's ./, but it might confuse users who expect // to mean floor division. In the same vein, ** could be used for element-wise multiplication, but again it might confuse users who expect it to mean power.
After the discussion in PR #138, it seems a more detailed discussion on how to deal with element-wise operations on data structures is handled. The point of contention was:
If vector, a Vector3d object, were to behave like the array data it contains, then this would imply an element-wise operation, i.e. taking the inverse of each element. However, mathematically, division by a vector is undefined. This leads to the dilemma: should the behavior be more maths-like or more array like? The maths definition would better reflect "real life", but a user may expect array-like behavior, and be put off by doing element wise division like:
The issue could be avoided with more operators like the
./
operator in Matlab. However, this operator does not exist in Python and it is not possible to add custom operators - they are baked into the language.Alternatively, one could overload operators which are unused. One could perhaps make use of
**
,//
and^
, which are all valid operators.//
could be used to represent Matlab's./
, but it might confuse users who expect//
to mean floor division. In the same vein,**
could be used for element-wise multiplication, but again it might confuse users who expect it to mean power.