-
-
Notifications
You must be signed in to change notification settings - Fork 47.8k
updated physics/archimedes_principle.py #10479
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
Changes from 31 commits
1427fe3
0608c40
7457b25
b1ef5a3
c957bd7
07502c8
ead4f47
c18b39d
cb006c3
ab04734
69487f3
6a741dc
d13c09d
18df9ba
63734b9
aa5f176
9779c1a
aa4d4e8
7bb663f
52c2cb8
643958b
65f5851
7f14ab9
c05ed7c
886fb5d
97b89cd
a1c783a
1c2b7b2
5aa65b8
59e9c01
37cc5a4
cf56671
802a381
208932d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,8 @@ | |
""" | ||
|
||
|
||
# Acceleration Constant on Earth (unit m/s^2) | ||
g = 9.80665 | ||
# Acceleration Constant on Earth (unit m/s^2) imported from scipy | ||
from scipy.constants import g | ||
|
||
|
||
def archimedes_principle( | ||
|
@@ -30,13 +30,27 @@ def archimedes_principle( | |
4885.3 | ||
>>> archimedes_principle(fluid_density=997, volume=0.7) | ||
6844.061035 | ||
>>> archimedes_principle(fluid_density=997, volume=-0.7) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: Impossible Object volume | ||
>>> archimedes_principle(fluid_density=0, volume=0.7) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: Impossible fluid density | ||
>>> archimedes_principle(fluid_density=997, volume=0.7, gravity=0) | ||
0.0 | ||
>>> archimedes_principle(fluid_density=997, volume=0.7, gravity=-9.8) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: Impossible Gravity | ||
""" | ||
|
||
if fluid_density <= 0: | ||
raise ValueError("Impossible fluid density") | ||
if volume < 0: | ||
if volume <= 0: | ||
raise ValueError("Impossible Object volume") | ||
if gravity <= 0: | ||
if gravity < 0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert these changes. It is useful to be able to make theoretical calculations even if we are unable to reproduce those conditions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should I remove the tests as well or just make the signs as they were before? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests need to follow the code. It is OK to have the tests but their output must pass. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The numerical tests are passing. Just added some more tests to see for when the inputs are invalid physically as in negative gravity, non positive volume and non positive density as they were already in the original code by the author. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please check @cclauss There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dude! There are 215 pull requests open. Perhaps we will get to review this one. |
||
raise ValueError("Impossible Gravity") | ||
|
||
return fluid_density * gravity * volume | ||
|
Uh oh!
There was an error while loading. Please reload this page.