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
1 vote
0 answers
27 views

WolframClient output convert to python complex array

I encountered the following issue with WolframClient. I have a my.function file which contains some function that takes some ...
user avatar
  • 503
-1 votes
1 answer
68 views

I have a (4,4,4) dimensional array which are the distribution values. The x, y and z axis range are given. Can you plot 3d heatmap?

...
user avatar
10 votes
1 answer
230 views

How to use Python functions in Mathematica functions in Python notebooks?

I want to plot things with Mathematica, inside an ipynb Python notebook. I can easily plot functions that are expressed in the Wolfram Language, e.g. with ...
user avatar
  • 2,791
1 vote
2 answers
96 views

getting rid of complex numbers in a solution list

I have the following list: [0.312712544956844, 0.287641445144978 - 0.306854031390629*I, 0.287641445144978 + 0.306854031390629*I] I would like to get rid of the ...
user avatar
  • 19
0 votes
0 answers
34 views

Error while using External Evaluator (Python)

In the above screenshot, I've shared the installed and registered version of python. However, when I try to use it, it ends up with an error. ...
user avatar
  • 319
1 vote
2 answers
562 views

Mathematica `fourier` get different result with python `np.fft` [closed]

In python,I run fft as below: ...
user avatar
  • 697
7 votes
2 answers
255 views

Calling a Python class function from ExternalEvaluate

I am attempting to use ExternalEvaluate to use some python packages (ARC) to save me some effort in performing the calculations in Mathematica, and for the most part I think it works as intended. The ...
user avatar
  • 113
0 votes
0 answers
66 views

How to create an animating torus using mathematica or python? [duplicate]

I want to create this animating torus using mathematica or python. If anyone knows how to make this please try to explain the steps. Thank you zo much.
user avatar
2 votes
1 answer
225 views

Wolfram Engine beginner's question: how to Sum?

I really like the idea of the Wolfram Engine, and in particular using it via the python client library. However, I've having trouble understanding the syntax for even simple commands: is there some ...
user avatar
2 votes
2 answers
213 views

Defining a function recursively

I want to construct polynomials (or just function) $f_n$ from $f_{n-1}$ using mathematica. For some kind of reason, I didn't manage to do this. So basically something like a recurrence table, but for ...
user avatar
2 votes
1 answer
76 views

ExternalEvaluate not running the whole Python file

I have the following 'test.py' written in Python: import numpy as np f = open('normals.txt', 'r') content = f.read() print(content) and I want to execute it from ...
user avatar
4 votes
2 answers
353 views

How to transfer a list as a Python function argument

This issue was already discussed here, but the answer is unclear yet. I use very simple Python function for converting a string list to upper case ...
user avatar
2 votes
0 answers
56 views

How can I import datasets from TensorFlow datasets into mathematica?

TensorFlow datasets are available at https://www.tensorflow.org/datasets. I wonder if there's a way to directly import any of those datasets directly into Mathematica 12. I tried ...
user avatar
  • 515
7 votes
1 answer
195 views

Exactly recreating image NetEncoder output

I need to run an exported NetChain in ONNX, surprisingly the model exports and runs successfully, but there's a discrepancy in the image loading stage (the NetEncoder'ing that must be written manually)...
user avatar
  • 3,720
4 votes
2 answers
214 views

Knn graph differences: Mathematica and sklearn

I have this data: Data file I made 8-NN graph as follows: ...
user avatar
  • 633
2 votes
1 answer
114 views

Python packages inside Mathematica's notebook: problem with sympy [closed]

With Mathematica's notebook, sometimes I hit the > key at the beginning of a new line and start writing python code. I can call and use the standard package ...
user avatar
  • 641
3 votes
1 answer
121 views

Problem when translating from LaTeX to Mathematica

I have a code in Python that makes some calculations for different reaction-diffusion equations. I am trying to let the user define the variables and parameters of the system. The problem is that, for ...
user avatar
2 votes
3 answers
503 views

Read sympy expression in .txt file as Mathematica input

I have a Python file that has a variable defined using sympy. For instance, let us take the following (crazy) example that I could have eventually since I am automatizing a routine: ...
user avatar
0 votes
3 answers
399 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 ...
user avatar
  • 53
7 votes
2 answers
147 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 ...
user avatar
0 votes
0 answers
97 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 ...
user avatar
  • 75
1 vote
2 answers
72 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 ...
user avatar
  • 119
1 vote
0 answers
73 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 ...
user avatar
1 vote
2 answers
105 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) ...
user avatar
  • 157
4 votes
2 answers
303 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]...
user avatar
  • 1,250
1 vote
0 answers
66 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 ...
user avatar
1 vote
0 answers
63 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 ...
user avatar
  • 493
6 votes
2 answers
961 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? ...
user avatar
  • 1,649
3 votes
0 answers
54 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 ...
user avatar
0 votes
1 answer
71 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 ...
user avatar
  • 271
2 votes
0 answers
34 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-...
user avatar
0 votes
0 answers
32 views

External Evaluate Conversion method

One can run a command for example in python using ExternalEvaluate ...
user avatar
  • 3,553
18 votes
3 answers
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 ...
user avatar
22 votes
2 answers
1k 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, ...
user avatar
  • 4,157
0 votes
1 answer
74 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 ...
user avatar
  • 103
1 vote
1 answer
133 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 '[]' ...
user avatar
  • 271
11 votes
1 answer
336 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 ...
user avatar
  • 4,677
2 votes
1 answer
116 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: ...
user avatar
  • 133
2 votes
0 answers
45 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 ...
user avatar
  • 3,553
3 votes
0 answers
75 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. ...
user avatar
  • 3,553
0 votes
2 answers
65 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 ...
user avatar
  • 571
2 votes
1 answer
303 views

Python's ':' equivalent in mathematica

I need to translate these two lines to mathematica from python ...
user avatar
  • 31
0 votes
0 answers
256 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 ...
user avatar
0 votes
1 answer
111 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 ...
user avatar
1 vote
0 answers
60 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): ...
user avatar
  • 967
1 vote
1 answer
131 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 ...
user avatar
  • 403
5 votes
1 answer
174 views

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

Say I have a function FUN defined in Mathemtica notebook: ...
user avatar
  • 157
6 votes
1 answer
177 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 ...
user avatar
  • 3,553
3 votes
1 answer
467 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 ...
user avatar
  • 271
7 votes
1 answer
161 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) ...
user avatar
  • 11.3k

1
2 3 4 5