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
1 answer
32 views

Using ExternalObjects for python iterators

Iterators are a common pattern in python. A trivial example is: example = iter(("apple", "banana", "cherry")) next(example) (yes, of ...
Joshua Schrier's user avatar
0 votes
0 answers
64 views

How do you rate Mathematica and Python in terms of numerical computation? [duplicate]

I often hear, in the physics community, that python is faster and overall better than mathematica for numeric calculations. But this seems very subjective since code badly written in one language can ...
Felipe's user avatar
  • 325
0 votes
1 answer
38 views

What is the fastest way to change Python environment?

We can see all registered Python environments through FindExternalEvaluators["Python"]. But the user interface will use the last registered one. How to ...
Alexey Golyshev's user avatar
1 vote
1 answer
74 views

Removing notebook cache from ExternalEvaluate

Question While working with Python's ExternalEvaluate the intermediate calculation results with Python are stored in the notebook. (...
Anton Antonov's user avatar
2 votes
1 answer
193 views

Python Code to Mathematica for Classical Map of Kicked Top

I am trying to convert this Python code for Classical map of kicked top to Mathematica. For a single trajectory, I am able to ...
user444's user avatar
  • 2,414
1 vote
0 answers
96 views

Convert a string of Python expression into Mathematica expression within Mathematica

While there are many ways to convert a Mathematica expression into other Languages, I was wondering if there is something reverse for Python. There are some discussions in Python groups, but I am ...
BabaYaga's user avatar
  • 1,816
1 vote
1 answer
174 views

Performance of polynomial functions in Mathematica vs Python [closed]

I am trying to compare the performance of Mathematica vs Python for vectorized operations involving polynomials. The data is floatMatrix which has dimensions (...
mmen's user avatar
  • 163
1 vote
0 answers
28 views

Python external evaluator missing first print

Can you confirm this bug when evaluating Python code in Mathmatica? Type > select Python by clicking on the icon on the left then paste the following code and ...
azerbajdzan's user avatar
  • 14.4k
0 votes
0 answers
23 views

Why is ExternalEvaluate running the command Quantity[471.04`, "Kilobytes"] on RaspberryPi

Raspberry Pi 4B with 32 bit Raspberry Pi OS Full: Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux Mathematica for Raspberry Pi 13.1 The command ...
Rudy Potter's user avatar
  • 2,553
0 votes
0 answers
111 views

Where is the Python distribution pre-installed with Wolfram?

I am using the latest version 13.3, does Wolfram comes preinstalled with a python kernel/distribution? I heard that some of the currently working features like sqlite connectivity uses python code, so ...
user13892's user avatar
  • 9,343
0 votes
0 answers
89 views

Mathematica Client Library for Python sometimes can't communicate with Kernel

I have been using the Mathematica client library for Python, but it errors at random some times when running the program, returning: wolframclient.exception.WolframKernelException: Failed to ...
Vibbbb's user avatar
  • 1
3 votes
1 answer
198 views

How to get matplotlib-type ticks? [closed]

Consider the following plot, obtained with the Python plotting library matplotlib: Is it possible to get the plot ticks to have this same style in a Mathematica ...
sam wolfe's user avatar
  • 4,613
0 votes
0 answers
75 views

How to pass variables from Python to Mathematica?

I have a Mathematica code that I want to run via Python using subprocess. The Mathematica code contains two variables that I want to pass through Python. However, when I tried to do that, I always got ...
j.doe's user avatar
  • 123
10 votes
0 answers
287 views

Mathematica 13.3 breaks old socket code

Edit 1: A support case with the identification [CASE:5059026] was created. Edit 2: This has just been confirmed as a bug by Wolfram Research. I have just heard back from Wolfram Research. They have ...
Shredderroy's user avatar
  • 5,249
6 votes
0 answers
602 views

Code for quasi 1D nozzle flows

The quasi-one-dimensional model describing the flow of compressible gas in rocket nozzles is very common. The corresponding equations have a divergent non dimensional form $ \frac{\partial \mathbf{U}}...
Alex Trounev's user avatar
  • 44.1k
7 votes
3 answers
761 views

How to pass values to Python?

I would like to pass Mathematica variable values to Python. But I found that it was not that trivial. For example, a typical way would be: ...
Satoshi Oota's user avatar
3 votes
0 answers
91 views

Using Mathematica ML models in another application

Using Mathematica, I trained and exported some machine learning models with the suggested file extension .wmlf. However, I noticed that these files are stored in HDF5 format. How can I import these ...
Jeremy L's user avatar
0 votes
0 answers
48 views

How to divide a point set into a set of triangles according to a centerpoint?

15 Points in red are randomly generated. The point in blue is called a 'centerpoint', which means any closed half space contains it also contains 15/(2+1)=5 points in red. The question is how can I ...
MING's user avatar
  • 1
5 votes
2 answers
341 views

Is there a built-in equivalent to numpy's fftfreq?

I recently learned that python's numpy package contains a function called fftfreq (documented at numpy.fft.fftfreq) which is ...
Emilio Pisanty's user avatar
2 votes
0 answers
131 views

Convert Wolfram to Python [closed]

Is there any way for python to generate a list and then find a function based on it just like how FindFit works in Wolfram? Preferably I would like the solution to work on Replit or Google Colab. ...
ABRAMOVICH OZ's user avatar
1 vote
0 answers
95 views

How to import specific Python Libraries using External Evaluate

I want to use specific python libraries via the Mathematica frontend. This is possible as follows ...
Asim's user avatar
  • 1,150
3 votes
0 answers
169 views

Can Mathematica's Minimize() function be called inside Python code using Python data?

Summary: I would like to use the Wolfram Client Library for Python to invoke Mathematica's Minimize function directly from within Python, passing to it Python data structures. Details: I have a Python ...
Neil Fazel's user avatar
1 vote
0 answers
41 views

Python np.gradient in Mathematica [duplicate]

Very quick and dirty question. I'm trying to write a program written in python into mathematica and there is a section that uses the gradient function in the numpty python library, ...
Koji's user avatar
  • 61
1 vote
0 answers
61 views

What are ExternalLanguage cells good for? [closed]

You can type > at the beginning of a cell (or right click and choose "insert new cell" - "ExternalLanguage") and then you can choose the ...
azerbajdzan's user avatar
  • 14.4k
6 votes
1 answer
179 views

Python compatible fortran form for complex numbers

I am trying to use the Mathematica output of a complicated expression as input for python. As suggested in this answer, the FortranForm of an expression already ...
sqrt6's user avatar
  • 63
3 votes
2 answers
397 views

Solving hyperbolic equation with parallelization in python by elucidating Mathematica algorithm [closed]

So! I have what seems like a rather basic hyperbolic equation to be solved written in Mathematica, with an integer input ‘n’, for which I am seeking the First {x,y} Integer solution to satisfy the ...
Travis Arlen McCracken's user avatar
3 votes
1 answer
453 views

How to run Wolfram language using Wolfram Client Library for Python in Google colab?

How to run the Wolfram language using Wolfram Client Library for Python in Google colab?
Mainul Islam's user avatar
3 votes
2 answers
477 views

Use python color scale in mathematica density plot

I have a python code for data analysis, that uses the "seismic" color scale for 2D density plots. However, I also need to do some other plots with Mathematica (because of packages etc), for ...
m137's user avatar
  • 357
2 votes
0 answers
88 views

How can we call Mathematica functions from another server using the `wolframscript` Python library?

How can we use the wolframclient Python library to call Mathematica functions when Mathematica is running in an another server? For example, if we have Mathematica ...
GarouDan's user avatar
  • 1,536
0 votes
0 answers
221 views

How can I call the function NSolve from Mathematica in Python?

I would like to use the NSolve function from Mathematica in a Python code to solve a polynomial system of equations. So my question is, whether there is an option to call this kind of function in a ...
Nils's user avatar
  • 1
3 votes
1 answer
148 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 ...
Morgan's user avatar
  • 525
-1 votes
1 answer
100 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?

...
K.Tamang's user avatar
10 votes
1 answer
659 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 ...
JEM_Mosig's user avatar
  • 3,003
0 votes
0 answers
63 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. ...
user444's user avatar
  • 2,414
1 vote
2 answers
775 views

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

In python,I run fft as below: ...
kittygirl's user avatar
  • 707
7 votes
2 answers
411 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 ...
D. Brown's user avatar
  • 304
2 votes
1 answer
255 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 ...
AnotherShruggingPhysicist's user avatar
2 votes
2 answers
239 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 ...
user3397129's user avatar
2 votes
1 answer
136 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 ...
tupoliedro's user avatar
4 votes
2 answers
513 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 ...
Konstantin's user avatar
2 votes
0 answers
94 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 ...
bhopshang's user avatar
  • 739
7 votes
1 answer
220 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)...
user5601's user avatar
  • 3,623
4 votes
2 answers
506 views

Knn graph differences: Mathematica and sklearn

I have this data: Data file I made 8-NN graph as follows: ...
sra's user avatar
  • 697
2 votes
1 answer
174 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 ...
Davi's user avatar
  • 671
3 votes
1 answer
176 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 ...
edgardeitor's user avatar
3 votes
3 answers
1k 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: ...
edgardeitor's user avatar
0 votes
3 answers
586 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 ...
Axha's user avatar
  • 83
7 votes
3 answers
307 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 ...
user108903's user avatar
1 vote
0 answers
333 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 ...
Dan's user avatar
  • 105
1 vote
2 answers
103 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 ...
Nada.M's user avatar
  • 119

1
2 3 4 5