Skip to content

Commit 2d2935c

Browse files
Fix testmod string
1 parent 26decf1 commit 2d2935c

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

physics/first_law_of_thermodynamics.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@
2222

2323
def __check_args(argument: float) -> None:
2424
"""
25-
Check that the arguments are valid
25+
Check that the arguments are valid.
26+
>>> __check_args(50.0)
27+
>>> __check_args(-20)
28+
>>> __check_args("50")
29+
Traceback (most recent call last):
30+
...
31+
TypeError: Invalid argument. Should be an integer or float.
2632
"""
2733

2834
# Ensure valid instance
@@ -34,6 +40,16 @@ def __categorize_system(argument_value: float, argument_name: str) -> None:
3440
"""
3541
Categorizes the system based on the work done, heat added/removed,
3642
and internal energy variation.
43+
>>> __categorize_system(0, "work")
44+
The system is isochoric (constant volume).
45+
>>> __categorize_system(50, "heat")
46+
The system is endothermic (absorbing heat).
47+
>>> __categorize_system(-20, "internal_energy_variation")
48+
The internal energy of the system is decreasing. It cooling down.
49+
>>> __categorize_system(10, "invalid")
50+
Traceback (most recent call last):
51+
...
52+
ValueError: Invalid argument name. Should be 'work', 'heat', or 'internal_energy_variation'.
3753
"""
3854

3955
if argument_name == "work":
@@ -60,6 +76,10 @@ def __categorize_system(argument_value: float, argument_name: str) -> None:
6076
elif argument_value < 0:
6177
print("The internal energy of the system is decreasing. It cooling down.")
6278

79+
else:
80+
error_type = "Invalid argument name."
81+
error_msg = "Should be 'work', 'heat', or 'internal_energy_variation'."
82+
raise ValueError(f"{error_type} {error_msg}")
6383

6484
def work(heat: float, internal_energy_variation: float) -> float:
6585
"""

0 commit comments

Comments
 (0)