Questions tagged [python]

Questions about interfacing with, or features inspired or demonstrated by Python--a programming language featuring a dynamic type system, automatic memory management, and a comprehensive standard library.

Filter by
Sorted by
Tagged with
0
votes
3answers
265 views

Python recursive bisection algorithm to Mathematica

I've been sitting on this problem for a while and i am kind of stuck. I am pretty new to Mathematica and have been trying to implement a recusive Algorithm, which splits/bisects a list of items in ...
7
votes
2answers
129 views

Can I stop the python interpreter appearing?

I am using version 12.1.1.0 on OS X 10.13. Every so often, a Python interpreter cell appears: I think I am probably summoning it by inadvertently pressing ">" (due to clumsy typing). Or ...
0
votes
0answers
55 views

ExternalEvaluate not working for Python

I tried installing the necessary packages and apparently anaconda already had it. When I ran the FindExternalEvaluator command I got But when I ran ...
1
vote
2answers
63 views

Random interior points of a demi circle [closed]

I am trying to write a code in Mathematica that allows me to find random points in this half circle by knowing the center and the radius. Each time I test something I find myself with a point out of ...
1
vote
0answers
38 views

Storing python output to variables in Wolfram

Would like to use the external language input in python to save variables I can potentially use in Mathematica. Any chance there is a way to do this? I do understand there might be a solution with ...
1
vote
2answers
74 views

Mathematica-Python interfacing: time lag in importing Python output in Mathematica

GOAL: I want to do a part of computation in Mathematica, write a text file (I call it INPUT.txt) containing the result from this partial calculation. Then I want to import this text file (INPUT.txt) ...
4
votes
2answers
240 views

Within Mathematica, how to export the output of python code to the Mathematica expression?

I run some Python code in the external code cell as following: The above Python code produced the result (as shown with red [1]...
1
vote
0answers
58 views

Wolfram Kernel and Elastic Beanstalk?

I've got a python project that uses the wolframclient library that I want to deploy onto AWS elastic beanstalk. I've tried installing Wolfram Engine through ssh, but wolframclient is having issues ...
1
vote
0answers
28 views

How to run a Mathematica package (.m) (which depends on Notation` package) via Python using "Wolfram Client Library for Python"?

In How to run a Mathematica package (.m) from Python using the “Wolfram Client Library for Python”?, I was able to get the basicPackage` example to work, but ran ...
4
votes
2answers
224 views

How to export expression in mathematica to python [closed]

I have an expression in Mathematica; I want to convert this expression into python readable format. how to do this? ...
2
votes
0answers
44 views

wolframclient library and DJango

I'm working on a project where a Django server needs to evaluate Wolfram Language code. Has anyone done this or know the best way to go about it? I've got something working, using a static class with ...
0
votes
1answer
47 views

Exporting complex exponential float arrays to Python

A question related to a previous question. The answer in the previous question works well for simple complex arrays but not when considering arrays with exponential float coefficients as in the ...
2
votes
0answers
32 views

Possible error in DeviceOpen["Serial", ...]

I'm using Mathematica to interface with a Feather M4 Express running Circuitpython. Presently, the M4 is sending "hello" to the serial console in 1 second intervals. It also has an on-...
0
votes
0answers
25 views

External Evaluate Conversion method

One can run a command for example in python using ExternalEvaluate ...
18
votes
3answers
1k views

How can I use Python's SciPy and NumPy functions in Mathematica to find the minimum of a function?

I have written my code in Mathematica, final aim of this code is to find the minimum of a function. I found that FindMinimum and ...
20
votes
2answers
933 views

How to make Mathematica read in CSV as fast as Python's Pandas

I have many big CSV files for processing in Mathematica. And each time loading them into Mathematica takes a long time. Meanwhile, it takes much less time using Pandas under Python. For example, ...
0
votes
1answer
65 views

Why doesn't WolframClient output InputForm?

I'm trying to make a wrapper REPL for the free Wolfram Engine (on Cygwin, there are a bit of I/O issues) in Python, so I am using the wolframclient library. However, whenever I use ...
1
vote
1answer
54 views

Editing complex arrays for export to Python

Quick question, can anyone advise on an efficient way to convert complex arrays with complex part denoted '${I}$' in Mathematica to '$j$' (as used in Python) and curly brackets '{}' replaced with '[]' ...
11
votes
1answer
299 views

WriteString to TCP socket appears to be broken in Mathematica 12.3

I have a large codebase in which some functions make calls to Python TCP servers. The code used to work perfectly in Mathematica 12.2, but has not worked since I ...
2
votes
1answer
114 views

Python to Mathematica code bug

I have an assignment in Mathematica, which I've already solved using Python and it's a bit hard to convert the code. Here's what I have done so far: ...
2
votes
0answers
42 views

Exporting packages containing "Python Code" cells

I created a notebook with Python code cells (evaluated using External Evaluate) as can be created by typing > at the beginning of a cell. (And choosing Python ...
3
votes
0answers
61 views

Create "Python Code" cells using custom executable

In https://mathematica.stackexchange.com/a/155815/45020 it is explained how to run cells using a custom virtual environment. How can I quickly create a cell that is evaluated using this environment. ...
0
votes
2answers
43 views

Create list of functions, domains, and iterate over (compare to Python code)

In Mathematica, I want to do a mass export of many different animated plots of specific functions with different domains. Because I don't necessarily want the plots to always have exactly the same ...
2
votes
1answer
271 views

Python's ':' equivalent in mathematica

I need to translate these two lines to mathematica from python ...
0
votes
0answers
129 views

Missing Dependencies for Python

I have some python code that I'd like to try to use in my Mathematica notebook. I have tried following the setup guide but I have run into some trouble (Mac). The Mathematica setup documentation says ...
0
votes
1answer
94 views

How to call Python Methods from Mathematica employing ExternalEvaluate?

This question is about the compatibility of methods written in Python and ExternalEvaluate from Mathematica. ExternalEvaluate allows Python functions to be called from Mathematica. For example, the ...
0
votes
0answers
30 views

How to use conda environments in StartExternalSession?

I am trying to get a conda python environment to run in Mathematica under Windows. It includes the following packages (in case you want to reproduce): ...
1
vote
1answer
95 views

Run a code in Fortran, C++, or Python in Wolfram Mathematica 12 on Mac OS [closed]

I would like to run an external code, written in Fortran, C++, or Python, within Wolfram Mathematica 12 on my MAC OS. I looked up on Internet and I tried to read the WSTP documentation on Wolfram ...
5
votes
1answer
148 views

Importing Mathematica defined function in python to do further computations. [Mathematica-Python interfacing]

Say I have a function FUN defined in Mathemtica notebook: ...
6
votes
1answer
137 views

How to compress a string in Mathematica so that it can decompressed in python

I need to compress a string into some format so that I can pass it along on the command line and avoid writing it to file (which would require locking files to prevent simultaneous writes so I prefer ...
3
votes
1answer
240 views

Formatting Imported Complex Arrays from Python (csv. files)

Just a short question, I am trying to import a complex array (matrix) from Python to Mathematica by first writing to a csv. file. When I Import the csv. array to Mathematica it is in a form (matrix ...
7
votes
1answer
139 views

Performance of select from a 3d list - Mathematica slower than Python

I am creating a random 3d data set in Matematica 12.1. Then I am selecting all points that are in a certain range of one axis. The same I am doing in Python (same computer, Python 3.8.5, numpy 1.19.2) ...
1
vote
1answer
74 views

ExternalEvaluate Python: Cannot import local file

I am trying to use ExternalEvaluate for a Python session. For some reason I cannot import a file from there that I can import successfully when I call python some ...
6
votes
1answer
115 views

Exporting Associations (containing lists and strings as keys and values) to python dictionaries

Since Mathematica Associations are similar objects to python dictionaries I think there should be an easy way to export a Mathematica ...
0
votes
0answers
47 views

How to go from a Pareto Distribution in Scipy to a Pareto Distribution in Mathematica?

Assume that I have fitted a Pareto distribution via Scipy and have gotten the following parameters: ...
2
votes
0answers
73 views

Resources on python programming for Mathematica programmers

Are there any good guides to programming in python for people who are already very familiar to Mathematica. I understand that for some things the canonical python approach is different and it is good ...
0
votes
0answers
38 views

Kernel crashes on invoking Python prompt

Apologies if this is a naive question. A typing error keeps crashing the kernel. My typing error is to start a line with ">", unintentionally invoking Python. The problem is that this ...
1
vote
1answer
90 views

WolframClient Converting Output Of Solve To Sympy

I'm trying to convert the output of WolframClient to Python. Here's a toy example: ...
1
vote
1answer
76 views

Periodic Boundary Condition for a List

Please take attention to a list as: data={6,12,5,8}; It may be interesting in Python if i=0, then ...
0
votes
1answer
61 views

How to find a numerical solution for a differential equation with constraints?

I want first to apologize for my poor english level ^^ Let me present my issue. I want resolve numerically (I use Python) for x in [0;1] the following differential equation : $$dy/dx = a(y - y^2) $$ ...
4
votes
2answers
239 views

Wolfram Client Library: Cannot establish connection with Kernel in second Python function

I have recently started using the Wolfram Client Library (WCL) for Python in my Linux machine in order to automate running a Mathematica notebook many times. I have an Anaconda environment ...
0
votes
1answer
123 views

Adopt Mathematica codes for circumscribed and inscribed ellipsoids to related sets

Users Daniel Huber and Dominic have provided an interesting answer each to the question JohnEllipsoids of constructing circumscribing and inscribing ellipsoids for a certain three-dimensional convex ...
0
votes
0answers
88 views

What's going on in this Newton-Raphson algorithm?

I'm looking at this post, over on Mathematics SE. I'll summarize here: A signal with a known velocity, c is emitted by some source. We're given the coordinates of ...
1
vote
1answer
47 views

External evaluations — selecting one of several Python versions

I have several Python versions installed and registered to Mathematica: FindExternalEvaluators["Python"] When I run the following code which one of ...
2
votes
1answer
163 views

How to run Python script with an argument?

I want to run Python script with argument 'arg' > python app.py arg Without 'arg' it works like ...
0
votes
1answer
50 views

save a mathematica expression with Root[] as Python expression?

I want to convert a Mathematica expression that uses Root[] to Python (open to using sympy if needed). The expression is: ...
1
vote
0answers
50 views

How to run Facebook Prophet in Mathematica?

I would like to use the Facebook Prophet API for timeseries forecasting in Mathematica. I'm trying to make a function prophetM which takes a list of date, and integer pairs (or a Timeseries object), ...
3
votes
1answer
98 views

Issue while evaluating Mathematica expressions from Python [closed]

This is a follow up to my question posted here I am trying to run the code posted here as an answer in the above-mentioned link here from Python I tried, ...
0
votes
1answer
81 views

Problem while running Mathematica code from Python using wolframclient library

This is a follow up to my previous post here I am trying to run a function from Python using wolframclient. The input arguments are passed from Python as Python ...
1
vote
1answer
83 views

Passing python data types as function arguments

I've a few python data types ...

1
2 3 4 5