Ask Your Question
0

Why doesn't show() render latex properly?

asked 5 years ago

eod gravatar image

updated 5 years ago

The following code:

import numpy as np

P = np.matrix('0 0 20 20; 0 20 20 0')

show(P)

Gives me the output

[[𝟢𝟢𝟸𝟢𝟸𝟢]
 [𝟢𝟸𝟢𝟸𝟢𝟢]]

In old sage, I guess around 6.0 or something, the show() command would render a proper latex matrix. I.e like you would see in a mathematics textbook.

Is there any way I can get this functionality back?

Thanks.

Edit: I'm using Sage 9.0 v 0.6.0 on Windows.

Preview: (hide)

1 Answer

Sort by Β» oldest newest most voted
2

answered 5 years ago

rburing gravatar image

I don't know how it used to work, but the way I understand it is that NumPy's matrix type is not a SageMath data type, so it doesn't support SageMath's latex rendering (in particular, it doesn't have a _latex_() method).

So just convert to a SageMath data type first:

sage: show(matrix(P))

(002020020200)

Preview: (hide)
link

Comments

Hmm, the matrix command gives me an error in jupyter for both sage 8.0 an 9.0 -- but it works in the console. Any idea why?

eod gravatar imageeod ( 5 years ago )

What is the error?

rburing gravatar imagerburing ( 5 years ago )

When I try to use the matrix command I get:

TypeError: 'numpy.ndarray' object is not callable

eod gravatar imageeod ( 5 years ago )

What code do you use as input, exactly?

rburing gravatar imagerburing ( 5 years ago )

For example "matrix([[1,2],[3,4]])" as copied from the sagemath docs.

eod gravatar imageeod ( 5 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 5 years ago

Seen: 615 times

Last updated: Feb 19 '20