-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
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
Added Mirror Formulae Equation #9717
Conversation
|
You might need to use https://docs.python.org/3/library/math.html#math.isclose to make your doctests work on all platforms. |
Hello ! Thanks for looking into my PR, but i am really confused on how to implement the math.isclose() function in this case since it returns a boolean value. I would be very grateful if you can help me with how to implement it. In the meantime I did try using the round() function, since it gives a more simplified answer, would love to know if that's ok or I should change it to the math.isclose() function. |
|
I will recheck where I'm going wrong and commit the changes soon. |
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.
physics/mirror_formulae.py
Outdated
""" | ||
|
||
<<<<<<< HEAD | ||
======= |
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.
An error occurred while parsing the file: physics/mirror_formulae.py
Traceback (most recent call last):
File "/opt/render/project/src/algorithms_keeper/parser/python_parser.py", line 146, in parse
reports = lint_file(
^^^^^^^^^^
libcst._exceptions.ParserSyntaxError: Syntax Error @ 61:3.
parser error: error at 60:2: expected one of (, *, +, -, ..., AWAIT, EOF, False, NAME, NUMBER, None, True, [, break, continue, lambda, match, not, pass, ~
=======
^
I have resolved the issue, Please let me know if any more changes are to be made ! 😄 |
physics/mirror_formulae.py
Outdated
@@ -57,13 +57,13 @@ | |||
|
|||
""" | |||
|
|||
|
|||
from math import isclose |
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.
Please move this import into the doctest so that the linter does not get confused.
>>> isclose(object_distance(30, 20), -60.0) | ||
True | ||
>>> isclose(object_distance(10.5, 11.7), 102.375) | ||
True |
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.
I do not think we need is_close() here. Let’s only use it where we need to.
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.
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.
Ok. We need is_close()
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.
Is there anything else I should add/change ?, or just have to wait till PR is merged ?
Nice one!! |
Thank You, I'm looking forward add more 😄 |
Problems... https://github.com/TheAlgorithms/Python/actions/runs/6415330109/job/17417072625?pr=9778#step:6:716 |
>>> from math import isclose | ||
>>> isclose(focal_length(9.5, 6.7), 3.929012346) | ||
True | ||
>>> focal_length(0, 20) |
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.
>>> focal_length(0, 20) # doctest: +NORMALIZE_WHITESPACE
>>> from math import isclose | ||
>>> isclose(object_distance(10.5, 11.7), 102.375) | ||
True | ||
>>> object_distance(90, 0) |
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.
# doctest: +NORMALIZE_WHITESPACE
>>> from math import isclose | ||
>>> isclose(image_distance(1.5, 6.7), 1.932692308) | ||
True | ||
>>> image_distance(0, 0) |
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.
# doctest: +NORMALIZE_WHITESPACE
Can you please make a new PR with those three comments added so the build tests pass? |
Yes, I will do it right now |
I have created a added ( Normalize Whitespace ) and created the Pull request. |
* Python mirror_formulae.py is added to the repository * Changes done after reading readme.md * Changes for running doctest on all platforms * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Change 2 for Doctests * Changes for doctest 2 * updating DIRECTORY.md --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Describe your change:
This PR adds an algorithm involving the Mirror formulae for finding, the Focal Length, Object Distance from mirror, Image Distance form the mirror.
Checklist: