Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use array in lambdify #7284

Closed
asmeurer opened this issue Mar 16, 2014 · 10 comments · Fixed by #7811
Closed

Always use array in lambdify #7284

asmeurer opened this issue Mar 16, 2014 · 10 comments · Fixed by #7811
Labels
Milestone

Comments

@asmeurer
Copy link
Member

See #2987 (comment) and #2931. We should just always use array, and print matrix multiplication as np.dot. We should revert the change from #2987. If you really want to use np.matrix, you can use the namespace option of lambdify.

This should be done before the next release, at least the reversion of #2987 so that we don't add a new API that will then be removed.

@jcrist
Copy link
Member

jcrist commented Mar 17, 2014

I'm currently working on this. As expressions are evaluated before lambdify uses them, matrix multiplication in a lambda expression doesn't seem to occur (the return is a matrix/array). The only time I can think of that matrix multiplication may be used would be if someone tried to lambdify an expression using MatrixSymbol. Trying this on version 0.75 errors out due to a bad lambda representation of MatrixSymbol. Should this feature be added?

@asmeurer
Copy link
Member Author

Or MatMul, even with an ImmutableMatrix.

@asmeurer
Copy link
Member Author

As it remains unevaluated by default.

@jcrist
Copy link
Member

jcrist commented Mar 21, 2014

The only way I can seem to manage to generate a MatMul expression is with multiplication between a MatrixSymbol, and something else. Multiplying two ImmutableMatrix objects evaluates, rather than returning a MatMul (unless that's not what you're saying).

@asmeurer
Copy link
Member Author

In [6]: MatMul(Matrix([[1, 2], [3, 4]]), Matrix([1, 2]))
Out[6]:
⎡1  2⎤⋅⎡1⎤
⎢    ⎥ ⎢ ⎥
⎣3  4⎦ ⎣2⎦

This will also happen if you replace a MatrixSymbol with an actual matrix in an expression (see #2962)

@jcrist
Copy link
Member

jcrist commented Mar 22, 2014

Hmmm. Didn't realize you could create a MatMul object directly. The fix proposed in PR 7293 still fixes this issue though. Works for any MatMul object.

@jcrist
Copy link
Member

jcrist commented Aug 13, 2014

Silly github, closing issues automatically just because people mention them in pull requests. The first part of this is fixed (removal of kwarg, use numpy.array). The second part (printing array using numpy.dot for all MatrixExpr types) still needs to be done.

@jcrist jcrist reopened this Aug 13, 2014
@jcrist
Copy link
Member

jcrist commented Sep 11, 2014

I think this can be deferred until later. It's at least no longer critical, as the array portion is taken care of. Appropriately handling matrix operations requires more changes than I have I have time to implement right now.

I'm deferring this to 0.7.7, and removing the critical status.

@jcrist jcrist modified the milestones: 0.7.6, 0.7.7 Sep 11, 2014
@asmeurer
Copy link
Member Author

0.7.7, now 1.0, is coming up. What needs to be done here?

@asmeurer
Copy link
Member Author

See #7853 and #9191.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants