<div dir="ltr">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. <br><br>This really looks like TeX overful/underful badness value adjustment. As long as the journal accepts don't mention it. :)<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 19, 2017 at 6:58 PM, Stephan Hoyer <span dir="ltr"><<a href="mailto:shoyer@gmail.com" target="_blank">shoyer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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. </div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 19, 2017 at 9:14 AM, Nathan Goldbaum <span dir="ltr"><<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I don't think there's any real standard here. Just doing a github search reveals many different choices people have used:<div><br></div><div><a href="https://github.com/search?l=Python&q=__array_priority__&type=Code&utf8=%E2%9C%93" target="_blank">https://github.com/search?l=Py<wbr>thon&q=__array_priority__&type<wbr>=Code&utf8=%E2%9C%93</a><br></div></div><div class="m_229140919772718240HOEnZb"><div class="m_229140919772718240h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 19, 2017 at 11:07 AM, Ilhan Polat <span dir="ltr"><<a href="mailto:ilhanpolat@gmail.com" target="_blank">ilhanpolat@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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.<br></div><div class="m_229140919772718240m_-3179666507828815269HOEnZb"><div class="m_229140919772718240m_-3179666507828815269h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 19, 2017 at 5:36 PM, Stephan Hoyer <span dir="ltr"><<a href="mailto:shoyer@gmail.com" target="_blank">shoyer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I answered your question on StackOverflow:<div><a href="https://stackoverflow.com/questions/40694380/forcing-multiplication-to-use-rmul-instead-of-numpy-array-mul-or-byp/44634634#44634634" target="_blank">https://stackoverflow.com/ques<wbr>tions/40694380/forcing-multipl<wbr>ication-to-use-rmul-instead-of<wbr>-numpy-array-mul-or-byp/446346<wbr>34#44634634</a><br></div><div><br></div><div>In brief, you need to set __array_priority__ or __array_ufunc__ on your object.</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_229140919772718240m_-3179666507828815269m_5866064647201672729h5">On Mon, Jun 19, 2017 at 5:27 AM, Ilhan Polat <span dir="ltr"><<a href="mailto:ilhanpolat@gmail.com" target="_blank">ilhanpolat@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_229140919772718240m_-3179666507828815269m_5866064647201672729h5"><div dir="ltr"><div><div><div><div><div><div><div><div><div><div>I will assume some simple linear systems knowledge but the question can be generalized to any operator that implements __mul__ and __rmul__ methods. <br><br></div><div>Motivation: <br></div><div><br>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. <br><br></div>In the typical usecase, suppose you would like to create an n-many parallel connections with the same LTI system sitting at each branch. MATLAB implements this as an elementwise multiplication and returning a multi input multi output(MIMO) system.<br><br></div>G = tf(1,[1,1]);<br></div>eye(3)*G <br><br></div>produces (manually compactified)<br><br>ans =<br> <br>  From input 1 to output...<br>   [    1                          ]<br>   [  ------    ,   0   ,     0    ]<br>   [  s + 1                        ]<br>   [                 1             ]<br>   [  0        ,   ------ ,   0    ]<br>   [               s + 1           ]<br>   [                          1    ]<br>   [  0        ,   0    ,  ------  ]<br>   [                        s + 1  ]<br> <br></div><div>Notice that the result type is of LTI system but, in our context, not a NumPy array with "object" dtype. <br></div><div><br></div>In order to achieve a similar behavior, I would like to let the __rmul__ of G take care of the multiplication. In fact, when I do G.__rmul__(np.eye(3)) I can control what the behavior should be and I receive the exception/result I've put in. However the array never looks for this method and carries out the default array __mul__ behavior. <br><br></div><div>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. <br></div><div><br></div>Is there anything I can do about this without forcing users subclassing or just letting them know about this particular quirk in the documentation? <br><br></div><div>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. <br></div><div><br><br></div>Relevant links just in case<br><br></div>the library : <a href="https://github.com/ilayn/harold/" target="_blank">https://github.com/ilayn/harol<wbr>d/</a><br></div><br>the issue discussion (monologue actually) : <a href="https://github.com/ilayn/harold/issues/7" target="_blank">https://github.com/ilayn/harol<wbr>d/issues/7</a><br><br></div>The question I've asked on SO (but with a rather offtopic answer): <a href="https://stackoverflow.com/q/40694380/4950339" target="_blank">https://stackoverflow.com/q/40<wbr>694380/4950339</a><span class="m_229140919772718240m_-3179666507828815269m_5866064647201672729m_5183147645039811267HOEnZb"><font color="#888888"><br><br><br><div><div><div><div><div><div>ilhan<br></div></div></div></div></div></div></font></span></div>
<br></div></div>______________________________<wbr>_________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/numpy-<wbr>discussion</a><br>
<br></blockquote></div><br></div>