graphically (GUI) test Python scripts like jsfiddle - python

I'm exploring 2D interpolations for the purpose of writing a script in Python. I've been using the PIL (Pillow) modules to quickly display the results of the algorithms - this is best for cases when interactive input isn't necessary (i.e. testing on a random set of points).
For interactive testing I've found jsfiddle to be the most lightweight solution, but I admit it isn't ideal to rewrite functions in another language merely to be able to move points around, and input specific shapes of quads.
simple example, 4 verts drawn at random (JavaScript in JS fiddle; would like to do the same in Python)
What would be a fastest way to play around with a Python script graphically? Is there a Python counterpart of jsfiddle? I googled 'Python fiddle', of course, but it's not what I'm looking for. What I need is a simple canvas implementation and click events support.
Thanks in advance,

Well, there is Python Fiddle, but I think this question is going to be closed by admins as being off-topic on Stack Overflow; see this thread here.
I'd also come to think of Jupyter and Anaconda. The latter includes the former. These will harness matplotlib, amongst others, and Jupyter gives you a Matlab-like interpreter that shows you variable values for each line and you're able to step by step look at those variables and any graphs you are making.

As mentioned in previous answer, there is Jupyter notebook – a software for interactive Python programming including graphical output.
You can run Jupyter locally or on your own server, but there are free cloud versions:
https://colab.research.google.com/
https://notebooks.azure.com/

Related

How best to enable non-programmers to run a Python program

I have written a Python script which models an academic problem which I wish to publish. I will put the source on Github and some academics that just happen to know Python may get my source and play with it themselves. However there are probably more academics that may be interested in the model but that are not python programmers and I would like them to be able to run my model too. Even though they are not programmers they could at least try out editing the values of some of the parameters to see how that affects the results. So now my question is how could I arrange for a non-python programmer to run a Python program as easily (for them) as possible. I would guess that my options may be...
google colab
an online python compiler like this one
compiling the program into an exe (and letting the user set parameters via a config file)
something else?
So now a couple of complications that makes my problem trickier.
The output of the program is graphical and uses matplotlib. As I understand it, the utilities that turn python scripts into exe files struggle or fail altogether when it comes to matplotlib.
The source is split into two separate files, one small neat file which contains the model and the user might like to have a good look at it and get the gist of it even if they're not really a python programmer. And a separate large ugly file which just handles the graphics - an academic would have no interest in this and I'd like to spare them the gory details.
EDIT: I did ask a related question here - but that was all about programmers that won't mind doing things like installing python and using pip... this question is in relation to non-programmers who would not be comfortable doing things like that.
Colab can handle the 2 problems, but you may need to adapt some code.
Matplotlib interface: Colab can display plots just fine. But you may want user to interact with slider, checkbox, dropdown menu. Then, you need to use Colab's own Form UI, or pywidgets. See an example here
2 separate python files: you can convert one of them to a notebook. Then import the other. Or you can create a new notebook that import both files. Here's an example.

Does two python codes running at the same time access same randomness?

I am running 36 jupyter notebooks on AWS instance. The code generates some experimental data based on some probability distribution. I do realize that I cannot multi-thread as it uses the same randomness. I'm not sure if it is the same case if I run the python script separately.
I would like to know if the python code in the background accessing the same randomness?
Currently I'm using numpy.random. I do realize that I can use os.random to avoid this problem. But I really don't prefer it as I have to do a lot of wrap around to get the necessary distribution I require.
Thanks in advance

Import model from 3DSlicer into Unity automatically

For my bachelor thesis I have to convert DICOM data to a 3d model and import this into unity so I can create a virtual reality. So the data out of 3DSlicer has to be updated in Unity automatically. You can say I have to link the two programs. What do you think is the best way to do this? Should I create a Matlab or Python module or is there a better way?
I am sorry if there is already a similar question but I have searched for answers on the internet and unfortunately I couldn't find an answer.
I would really appreciate your help.
Since slicer is compatible to python codes. you can try to access to the unity codes, if you use ubuntu it is probably easier to use a shell script to call the unity functions you need withing the python codes of slicer.
I did it with ANSYS softwares to link two different softwares together and export an output from the first software and pass it to the second software.
Rather than this automatic way, this is a guideline about how to export data from other apps to Unity
https://docs.unity3d.com/Manual/HOWTO-exportFBX.html

Display a live numpy array

In APL, you can trivially bring up a window that shows the contents of a variable whilst your program is running and watch it update live.
This is illustrated by the classic Game of Life video at 5 minutes in.
Is there any similar 'inspector' for Python with support for numpy arrays so I can see step through my array code and see what its doing live?
(Ideally using TK or something portable)
Have you looked at the python debugger? (pdb)
It's not graphical but it is completely portable. Depending what IDE you're using, there might be a visual debugger built in.
(original poster)
I could not find one, so I made one. You can get it here.

AppEngine: Running Python code on the fly

Hello Python developers!
I'm a Java one and I know that there is a way of running Java code on the fly, but my question is, is there any way to do that with Python?
The main goal here is to enable middle-school students to start coding with chromebooks from day one on Python.
I've been looking for some resources, but I got nothing so far.
Thanks a lot!
http://shell.appspot.com might be of your interest. (there's a link to the source code too)
Hey, I just recovered a link to a nice page I used in the past. It shows the execution flow of a Python script. Students I taught found it very useful in terms of comparing with other languages they new already, e.g. Java, how stack and arguments are being passed to the functions, memory allocations, etc:
http://people.csail.mit.edu/pgbovine/python/tutor.html
(click on "Visualize execution" button beneath the window with the code)
IPython allows you to run python interactively from a web environment. You can try a demo here: IPython. You can set this up on a local computer and have you students view it from their machines.
Coderbuddy let's you create and run AppEngine applications online, without having to download the AppEngine SDK, Python, or anything for that matter.
I use that when I do workshops, so I don't have to bother with making sure that everyone has the SDK and proper configurations in their machines. We just go straight to coding. :)

Categories

Resources