Skip to content

Fix doctest tracebacks #7558

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 1 commit into from
Oct 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 1 addition & 5 deletions conversions/pressure_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ def pressure_conversion(value: float, from_type: str, to_type: str) -> float:
0.019336718261000002
>>> pressure_conversion(4, "wrongUnit", "atm")
Traceback (most recent call last):
File "/usr/lib/python3.8/doctest.py", line 1336, in __run
exec(compile(example.source, filename, "single",
File "<doctest __main__.pressure_conversion[8]>", line 1, in <module>
pressure_conversion(4, "wrongUnit", "atm")
File "<string>", line 67, in pressure_conversion
...
ValueError: Invalid 'from_type' value: 'wrongUnit' Supported values are:
atm, pascal, bar, kilopascal, megapascal, psi, inHg, torr
"""
Expand Down
8 changes: 4 additions & 4 deletions electronics/carrier_concentration.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ def carrier_concentration(
('hole_conc', 1440.0)
>>> carrier_concentration(electron_conc=1000, hole_conc=400, intrinsic_conc=1200)
Traceback (most recent call last):
File "<stdin>", line 37, in <module>
...
ValueError: You cannot supply more or less than 2 values
>>> carrier_concentration(electron_conc=-1000, hole_conc=0, intrinsic_conc=1200)
Traceback (most recent call last):
File "<stdin>", line 40, in <module>
...
ValueError: Electron concentration cannot be negative in a semiconductor
>>> carrier_concentration(electron_conc=0, hole_conc=-400, intrinsic_conc=1200)
Traceback (most recent call last):
File "<stdin>", line 44, in <module>
...
ValueError: Hole concentration cannot be negative in a semiconductor
>>> carrier_concentration(electron_conc=0, hole_conc=400, intrinsic_conc=-1200)
Traceback (most recent call last):
File "<stdin>", line 48, in <module>
...
ValueError: Intrinsic concentration cannot be negative in a semiconductor
"""
if (electron_conc, hole_conc, intrinsic_conc).count(0) != 1:
Expand Down
6 changes: 3 additions & 3 deletions electronics/electric_power.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ def electric_power(voltage: float, current: float, power: float) -> tuple:
result(name='power', value=6.0)
>>> electric_power(voltage=2, current=4, power=2)
Traceback (most recent call last):
File "<stdin>", line 15, in <module>
...
ValueError: Only one argument must be 0
>>> electric_power(voltage=0, current=0, power=2)
Traceback (most recent call last):
File "<stdin>", line 19, in <module>
...
ValueError: Only one argument must be 0
>>> electric_power(voltage=0, current=2, power=-4)
Traceback (most recent call last):
File "<stdin>", line 23, in <modulei
...
ValueError: Power cannot be negative in any electrical/electronics system
>>> electric_power(voltage=2.2, current=2.2, power=0)
result(name='power', value=4.84)
Expand Down
3 changes: 1 addition & 2 deletions maths/nevilles_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def neville_interpolate(x_points: list, y_points: list, x0: int) -> list:
104.0
>>> neville_interpolate((1,2,3,4,6), (6,7,8,9,11), '')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
...
...
TypeError: unsupported operand type(s) for -: 'str' and 'int'
"""
n = len(x_points)
Expand Down