-
-
Notifications
You must be signed in to change notification settings - Fork 46.7k
Drawing Julia sets #4382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drawing Julia sets #4382
Conversation
Added Julia sets drawing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
Hi alexn11, I couldn't find the images produced by your program neither on the Wikipedia article nor through a short google search. Do you know of such a website to have a visual confirmation that the program does what it is supposed to do? |
Hi algobytewise, |
Thanks for the prompt response. Visually it looks fine. Correct me if I'm wrong, but I think for the examples you picked, it's not important to have two plots per example (one for the absolute value & one whether it escapes) because there is not much of a color gradient for the absolute value. Since it's in the directory You still need to add the type-hints for mypy. https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md has some basic information on that. By the way, I get the following warnings: |
Thanks a lot, your remarks are very helpful. |
I think the type is not "numpy.array" but "numpy.ndarray". |
Added online sources for comparison. Added more examples of fractal Julia sets. Added all type hints. Only show one picture Silented RuntuleWarning's (there's no way of avoiding them and they're not an issue per se)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing all the changes. I'm not sure that it's a good idea to just hide the RuntimeWarnings. I haven't looked at the code in detail, but I imagine that having an overflow might make the difference whether a pixel is categorized as above or below the escape_radius, resulting in a bug. Maybe that's the reason why the last example is dotted while the example on the website has solid colored sections.
An easy solution might be to change the array-type to 64 bit, see https://stackoverflow.com/questions/7559595/python-runtimewarning-overflow-encountered-in-long-scalars. Maybe reducing the number of iterations might also do the trick. Otherwise you may have to implement a check in the code whether the numbers are getting too big and maybe stop the iteration-process for the concerned values.
I'm also getting the following errors from flake-8 test. I guess some of the comment-lines are too long & need to be separated into several lines.
julia_sets.py:3:89: E501 line too long (388 > 88 characters)
julia_sets.py:6:89: E501 line too long (92 > 88 characters)
julia_sets.py:8:89: E501 line too long (208 > 88 characters)
julia_sets.py:12:1: F401 'typing.NewType' imported but unused
julia_sets.py:12:1: F401 'typing.Union' imported but unused
julia_sets.py:65:89: E501 line too long (108 > 88 characters)
Yes you're right for the dotted graph. I've made a new version that replace nans and infinites with a large value. Reducing the number of iterations would decrease the quality of the output. I was looking for a way to have numpy replace overflows etc with a specific value without raising the warning (while continuing array computations) but couldn't find any. Given the way the loop is implemented, the runtime warnings are unavoidable. I think this is fine as long as we are aware of why these warnings occur. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
Your solution is definitely a progress but I'm not sure that it fully solves the problem. Have a look at the following example: z_0 = numpy.array([[2, 3]])
z_final = iterate_function(
eval_quadratic_polynomial,
0,
10,
z_0,
) The final value is |
One solution that comes to my mind is to apply the eval_function not to the array as a whole but to individual values. While iterating you could check whether the value crosses the escape radius and then break the loop for this value. This way you should never get close to overflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
Type of expected output value for iterate function int array -> complex array (throws an error on test)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
@alexn11 Please take a look:
|
- More accurate type for tests cases in eval_quadratic_polynomial and iterate_function - added more characters for variables c & z in eval_quadratic_polynomial and eval_exponential to silent bot warnings
Thanks for pointing these out. There was some typing issue. Should be resolved now. |
Blocked by black
Co-authored-by: John Law <[email protected]>
Co-authored-by: John Law <[email protected]>
Co-authored-by: John Law <[email protected]>
Co-authored-by: John Law <[email protected]>
Co-authored-by: John Law <[email protected]>
Co-authored-by: John Law <[email protected]>
Co-authored-by: John Law <[email protected]>
Co-authored-by: John Law <[email protected]>
@algorithms-keeper review-all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your pull request!🤩Looks good to me. While we're waiting for the final checks, feel free to improve anything you want.
Great! Thank you very much for the edits! |
* Added Julia sets drawing * Forgot the .py extension * Update julia_sets.py Added online sources for comparison. Added more examples of fractal Julia sets. Added all type hints. Only show one picture Silented RuntuleWarning's (there's no way of avoiding them and they're not an issue per se) * Added doctest example for "show_results" * Filtering Nan's and infinites * added 1 missing type hint * in iterate_function, convert to dtype=complex64 * RuntimeWarning (fine) filtering * Type hint, test for ignore_warnings function, typo in header * Update julia_sets.py Type of expected output value for iterate function int array -> complex array (throws an error on test) * Update julia_sets.py - More accurate type for tests cases in eval_quadratic_polynomial and iterate_function - added more characters for variables c & z in eval_quadratic_polynomial and eval_exponential to silent bot warnings * Function def formatting Blocked by black * Update julia_sets.py * Update fractals/julia_sets.py Co-authored-by: John Law <[email protected]> * Update fractals/julia_sets.py Co-authored-by: John Law <[email protected]> * Update fractals/julia_sets.py Co-authored-by: John Law <[email protected]> * Update fractals/julia_sets.py Co-authored-by: John Law <[email protected]> * Update fractals/julia_sets.py Co-authored-by: John Law <[email protected]> * Update fractals/julia_sets.py Co-authored-by: John Law <[email protected]> * Update fractals/julia_sets.py Co-authored-by: John Law <[email protected]> * added more doctests for eval_exponential * Update fractals/julia_sets.py Co-authored-by: John Law <[email protected]> Co-authored-by: John Law <[email protected]>
Describe your change:
Drawing Julia sets
Checklist:
Fixes: #{$ISSUE_NO}
.