Skip to content

Doctest Error Correction of mirror_formulae.py #9782

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

Merged
merged 17 commits into from
Oct 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change 2 for Doctests
  • Loading branch information
vipinkarthic committed Oct 5, 2023
commit 0ed896b61b9b7d5d8a79d9062d0b92d65774625e
10 changes: 8 additions & 2 deletions physics/mirror_formulae.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@

"""

from math import isclose

def focal_length(distance_of_object: float, distance_of_image: float) -> float:
"""
>>> isclose(focal_length(10, 20), 6.666666666666667)
>>> from math import isclose
>>> isclose(focal_length(10, 20), 6.66666666666666)
True
>>> from math import isclose
>>> isclose(focal_length(9.5, 6.7), 3.929012346)
True
>>> focal_length(0, 20)
Expand All @@ -81,8 +83,10 @@ def focal_length(distance_of_object: float, distance_of_image: float) -> float:

def object_distance(focal_length: float, distance_of_image: float) -> float:
"""
>>> from math import isclose
>>> isclose(object_distance(30, 20), -60.0)
True
>>> from math import isclose
>>> isclose(object_distance(10.5, 11.7), 102.375)
True
>>> object_distance(90, 0)
Expand All @@ -102,8 +106,10 @@ def object_distance(focal_length: float, distance_of_image: float) -> float:

def image_distance(focal_length: float, distance_of_object: float) -> float:
"""
>>> from math import isclose
>>> isclose(image_distance(10, 40), 13.33333333)
True
>>> from math import isclose
>>> isclose(image_distance(1.5, 6.7), 1.932692308)
True
>>> image_distance(0, 0)
Expand Down