Added Mirror Formulae Equation#9717
Added Mirror Formulae Equation#9717cclauss merged 13 commits intoTheAlgorithms:masterfrom vipinkarthic:master
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.
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 reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto 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.
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
| """ | ||
|
|
||
|
|
||
| from math import isclose |
There was a problem hiding this comment.
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.
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.
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.
>>> 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.
# 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.
# 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. |


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: