I will assume some simple linear systems knowledge but the question can be generalized to any operator that implements __mul__ and __rmul__ methods. Motivation: I am trying to implement a gain matrix, say 3x3 identity matrix, for time being with a single input single output (SISO) system that I have implemented as a class modeling a Transfer or a state space representation. ans = From input 1 to output... [ 1 ] [ ------ , 0 , 0 ] [ s + 1 ] [ 1 ] [ 0 , ------ , 0 ] [ s + 1 ] [ 1 ] [ 0 , 0 , ------ ] [ s + 1 ] Notice that the result type is of LTI system but, in our context, not a NumPy array with "object" dtype. The situation is similar if we go about it as left multiplication G*eye(3) has no problems since this uses directly the __mul__ of G. Therefore we get a different result depending on the direction of multiplication. What I have in mind is to force the users to create static LTI objects and then multiply and reject this possibility. But then I still need to stop NumPy returning "object" dtyped array to be able to let the user know about this. the issue discussion (monologue actually) : https://github.com/ilayn/harold/issues/7 ilhan _______________________________________________ NumPy-Discussion mailing list [hidden email] https://mail.python.org/mailman/listinfo/numpy-discussion |
I answered your question on StackOverflow: In brief, you need to set __array_priority__ or __array_ufunc__ on your object. On Mon, Jun 19, 2017 at 5:27 AM, Ilhan Polat <[hidden email]> wrote:
_______________________________________________ NumPy-Discussion mailing list [hidden email] https://mail.python.org/mailman/listinfo/numpy-discussion |
Thank you. I didn't know that it existed. Is there any place where I can get a feeling for a sane priority number compared to what's being done in production? Just to make sure I'm not stepping on any toes. On Mon, Jun 19, 2017 at 5:36 PM, Stephan Hoyer <[hidden email]> wrote:
_______________________________________________ NumPy-Discussion mailing list [hidden email] https://mail.python.org/mailman/listinfo/numpy-discussion |
I don't think there's any real standard here. Just doing a github search reveals many different choices people have used: On Mon, Jun 19, 2017 at 11:07 AM, Ilhan Polat <[hidden email]> wrote:
_______________________________________________ NumPy-Discussion mailing list [hidden email] https://mail.python.org/mailman/listinfo/numpy-discussion |
Coming up with a single number for a sane "array priority" is basically an impossible task :). If you only need compatibility with the latest version of NumPy, this is one good reason to set __array_ufunc__ instead, even if only to write __array_ufunc__ = None. On Mon, Jun 19, 2017 at 9:14 AM, Nathan Goldbaum <[hidden email]> wrote:
_______________________________________________ NumPy-Discussion mailing list [hidden email] https://mail.python.org/mailman/listinfo/numpy-discussion |
Ah OK. I was just wondering if there are recommended values to start with in case below some values are reserved for NumPy/SciPy internals. I'll just go with the ufunc path just in case. This really looks like TeX overful/underful badness value adjustment. As long as the journal accepts don't mention it. :) On Mon, Jun 19, 2017 at 6:58 PM, Stephan Hoyer <[hidden email]> wrote:
_______________________________________________ NumPy-Discussion mailing list [hidden email] https://mail.python.org/mailman/listinfo/numpy-discussion |
Free forum by Nabble | Edit this page |