Ideally you should be able to just do np.array(Matrix(...),
dtype=float) (or dtype=int) to create a numpy array with a native
dtype. But it looks like there is a bug that prevents it from working
(https://github.com/sympy/sympy/issues/14943). So for now you can use

from sympy import matrix2numpy
matrix2numpy(M, dtype=float)

Aaron Meurer

On Thu, Jul 19, 2018 at 1:25 AM, Math newbie <[email protected]> wrote:
> Let's say I have a matrix M in the SymPy Matrix class, how may I create a
> Numpy array variable that takes the same values as in M?
>
> I tried np.array(M). But its dtype=Object which is strange and I am not sure
> what does it mean.
>
> Any idea would be extremely helpful! Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/baf3cffc-c2d6-477e-b8f5-5eef71a9f886%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6JdHG0Goy0oC5jwx9Pt2WNKxWNNvOsKNypvwGU0fDRavg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to