I've now posted a README file on Github for installing the necessary Python libraries, in order to make this work, because there is a "gotcha" or two.
Regarding Numpy, I'll repost a comment that I made a month back in reply to somebody asking if it was usual to find that learning Numpy techniques was slow going:
I remember running PASCAL back in the '80s on an 8-bit home computer (Amstrad CPC6128) and being really impressed with the concept of structured programming rather than the GOTOs and GOSUBs that I'd been using. So that was my first computing paradigm shift, which I found really easy to adjust to, probably because I was young then, and I've remained with that paradigm, whatever the programming language, until just recently. So yes, lots of loops.
When I learned Python, I did the same thing, of course. Here's a Cosine "Mandelbrot Set" that I made to test my knowledge of Python structures and graphical display (using Tkinter).
I'd been aware of numpy, but I assumed that there were many types of nested loop structures that were impossible to "vectorize", certainly in the case of the mandelbrot set, so numpy would only be useable in a few specific cases.
I would discover that I was wrong about that in time. The change was gradual. No sudden change of thinking. I just learned more about numpy with time, learning new numpy commands when I did happen to write something that used numpy. Then I'd think can such-and-such be done in numpy? I'd do a Google search of the docs and Stack Overflow, and find that yes it can.
I've now rewritten that Mandelbrot Set script using Numpy. It creates the same image as the previous script, except a whole lot faster.
One problem with numpy scripts is that they are almost unreadable to anybody that's not familiar with numpy. There is a certain elegance with "vectorizing" an algorithm that way, but there are pros and cons.
Anyway, in my opinion you'll get there if you want to, but just expect it to take a bit of time.
The "imaginary unit". Mathematics uses "i" for the imaginary unit, but electrical engineers use "j" to avoid confusing it with "I" for current. Python uses the electrical engineering convention. There was a "bug" logged to change it to "i", but that didn't happen. Python's creator, Guido van Rossum, said:
This will not be fixed. For one thing, the letter 'i' or upper case 'I' look too much like digits. The way numbers are parsed either by the language parser (in source code) or by the built-in functions (int, float, complex) should not be localizable or configurable in any way; that's asking for huge disappointments down the road. If you want to parse complex numbers using 'i' instead of 'j', you have plenty of solutions available already.
[deleted]
Swipecat [OP] 26 points · Oct 2019
I've now posted a README file on Github for installing the necessary Python libraries, in order to make this work, because there is a "gotcha" or two.
Regarding Numpy, I'll repost a comment that I made a month back in reply to somebody asking if it was usual to find that learning Numpy techniques was slow going:
I remember running PASCAL back in the '80s on an 8-bit home computer (Amstrad CPC6128) and being really impressed with the concept of structured programming rather than the GOTOs and GOSUBs that I'd been using. So that was my first computing paradigm shift, which I found really easy to adjust to, probably because I was young then, and I've remained with that paradigm, whatever the programming language, until just recently. So yes, lots of loops.
When I learned Python, I did the same thing, of course. Here's a Cosine "Mandelbrot Set" that I made to test my knowledge of Python structures and graphical display (using Tkinter).
https://pastebin.com/znkqNDZV
Creates this image.
https://i.imgur.com/0dp2qGK.jpg
I'd been aware of numpy, but I assumed that there were many types of nested loop structures that were impossible to "vectorize", certainly in the case of the mandelbrot set, so numpy would only be useable in a few specific cases.
I would discover that I was wrong about that in time. The change was gradual. No sudden change of thinking. I just learned more about numpy with time, learning new numpy commands when I did happen to write something that used numpy. Then I'd think can such-and-such be done in numpy? I'd do a Google search of the docs and Stack Overflow, and find that yes it can.
I've now rewritten that Mandelbrot Set script using Numpy. It creates the same image as the previous script, except a whole lot faster.
https://pastebin.com/usF7tgF6
One problem with numpy scripts is that they are almost unreadable to anybody that's not familiar with numpy. There is a certain elegance with "vectorizing" an algorithm that way, but there are pros and cons.
Anyway, in my opinion you'll get there if you want to, but just expect it to take a bit of time.
SuspiciousScript 1 points · Oct 2019
Hello! Quick question about this code — where does the
jin line 11 (plane = x + 1j * y) come from? It's definitely not something I've seen before.Swipecat [OP] 3 points · Oct 2019
The "imaginary unit". Mathematics uses "i" for the imaginary unit, but electrical engineers use "j" to avoid confusing it with "I" for current. Python uses the electrical engineering convention. There was a "bug" logged to change it to "i", but that didn't happen. Python's creator, Guido van Rossum, said:
So the "plane" in
plane = x + 1j * y...means the "complex plane".
SuspiciousScript 1 points · Oct 2019
Huh, I never knew that was a feature in the language. Thanks!