Indeed, my question is related to pedagogical reasons. Even if my code is simple, it uses the import machinery that I would like to not use. Le 27 nov. 2014 22:31, "Nils Bruin" <nbr...@sfu.ca> a écrit :
> On Thursday, November 27, 2014 1:08:30 PM UTC-8, projetmbc wrote: >> >> Hello. >> >> Is it possible to do the same thing as the following code in "pure" Sage >> coding ? >> >> *Christophe BAL* >> *Enseignant de mathématiques en Lycée* >> *et développeur Python amateur* >> >> *--**------**------**--- **CODE **---**------**------**--* >> *import matplotlib.pyplot as plt* >> *import numpy as np* >> *from sympy import binomial* >> >> *nmax = 200* >> >> *im = np.zeros((nmax+1, nmax+1, 3))* >> >> *for n in range(nmax):* >> * for k in range(n+1):* >> * if binomial(n, k) % 2 == 1:* >> * im[k, n] = (255, 255, 255)* >> >> *im = im.astype(np.uint8)* >> >> *plt.imshow(im)* >> *plt.axis('off')* >> *plt.show()* >> > > All these components are part of sage. Hence, if you do: > > sage: preparser(False) #this may not be necessary, but it guarantees your > code isn't subtly differently interpreted > <paste in your code> > > it'll work. > > The matplotlib in sage is normally not compiled to support its "show" > method (wxPython is missing from sage's python), but you can use > plt.savefig("fig.pdf") to save the image you just produced, which you can > then view with any pdf viewer. > > > -- > You received this message because you are subscribed to the Google Groups > "sage-support" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-support+unsubscr...@googlegroups.com. > To post to this group, send email to sage-support@googlegroups.com. > Visit this group at http://groups.google.com/group/sage-support. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.