Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Appel d'un sous-process qui ne marche pas (?)

1 réponse
Avatar
Fabrice Delente
Bonsoir.

J'ai écrit un petit script python qui doit appeler maxima (système de calcul
formel).

Lorsque mon script appelle maxima de cette manière :

os.system("/usr/local/bin/maxima -q -b out.max")

j'obtiens ceci :

solve([f(0.5)=5,f(4)=2,f(5)=0,at(diff(f(x),x,1),x=4)=0,at(diff(f(x),x,1),x=3)=at(diff(g(x),x,1),x=3)],[a1,a2,b2,c2,d2,e2])
(%i1) batch(out.max)

batching #p/usr/local/testSpace/workspace/systemParser/src/out.max
(%o2) out.max

Maxima trouve bien out.max lorsque le script est exécuté, car si je mets
outo.max à la place de out.max, maxima se plaint que le fichier n'existe pas.

Lorsque j'exécute la commande /usr/local/bin/maxima -q -b out.max dans une
console en me plaçant dans le répertoire qui contient out.max, j'obtiens

(%i1) batch(out.max)

batching #p/usr/local/testSpace/workspace/systemParser/src/out.max
(%i2) display2d : false
(%o2) false
(%i3) g(x):=a1*x^0
(%o3) g(x):=a1*x^0
(%i4) f(x):=e2*x^4+d2*x^3+c2*x^2+b2*x^1+a2*x^0
(%o4) f(x):=e2*x^4+d2*x^3+c2*x^2+b2*x^1+a2*x^0
(%i5) solve([f(0.5) = 5,f(4) = 2,f(5) = 0,at(diff(f(x),x,1),x = 4) = 0,
at(diff(f(x),x,1),x = 3) = at(diff(g(x),x,1),x = 3)],
[a1,a2,b2,c2,d2,e2])

'rat' replaced 1.0 by 1/1 = 1.0

'rat' replaced 0.5 by 1/2 = 0.5

'rat' replaced 0.25 by 1/4 = 0.25

'rat' replaced 0.125 by 1/8 = 0.125

'rat' replaced 0.0625 by 1/16 = 0.0625
(%o5) [[a1 = %r1,a2 = 38650/9261,b2 = 10960/3087,c2 = -41462/9261,
d2 = 4436/3087,e2 = -1328/9261]]
(%i6) ev(g(x),%o5)
(%o6) %r1
(%i7) ev(f(x),%o5)
(%o7) -1328*x^4/9261+4436*x^3/3087-41462*x^2/9261+10960*x/3087+38650/9261


Est-ce d^u à une erreur de ma part dans le code python ? Faut-il utiliser
autre chose que os.system, ou initialiser certaines variables
d'environnement ?

Merci.

À bientôt.

--
Fabrice DELENTE

SVP, ne m'envoyez pas de pièces jointes aux formats Word, PowerPoint, RTF
(formats propriétaires). Utilisez des formats libres comme txt, html, ou
OpenOffice.Org, ou un format ouvert comme PDF. Merci. Voir
http://www.gnu.org/philosophy/no-word-attachments.fr.html

1 réponse

Avatar
Fabrice Delente
Fabrice Delente wrote:
Tout marche, j'avais juste oublié un .close() sur le fichier...

À bientôt.

--
Fabrice DELENTE

SVP, ne m'envoyez pas de pièces jointes aux formats Word, PowerPoint, RTF
(formats propriétaires). Utilisez des formats libres comme txt, html, ou
OpenOffice.Org, ou un format ouvert comme PDF. Merci. Voir
http://www.gnu.org/philosophy/no-word-attachments.fr.html