Skip to content

Commit d3ee053

Browse files
committed
Fix some more numpy tests
1 parent 0a8c086 commit d3ee053

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

electronics/circular_convolution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def circular_convolution(self) -> list[float]:
5454
>>> convolution.first_signal = [1, -1, 2, 3, -1]
5555
>>> convolution.second_signal = [1, 2, 3]
5656
>>> convolution.circular_convolution()
57-
[8, -2, 3, 4, 11]
57+
[8.0, -2.0, 3.0, 4.0, 11.0]
5858
5959
"""
6060

fractals/julia_sets.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
def eval_exponential(c_parameter: complex, z_values: np.ndarray) -> np.ndarray:
4141
"""
4242
Evaluate $e^z + c$.
43-
>>> eval_exponential(0, 0)
43+
>>> float(eval_exponential(0, 0))
4444
1.0
4545
>>> abs(eval_exponential(1, np.pi*1.j)) < 1e-15
4646
True
@@ -98,20 +98,20 @@ def iterate_function(
9898
9999
>>> iterate_function(eval_quadratic_polynomial, 0, 3, np.array([0,1,2])).shape
100100
(3,)
101-
>>> np.round(iterate_function(eval_quadratic_polynomial,
101+
>>> complex(np.round(iterate_function(eval_quadratic_polynomial,
102102
... 0,
103103
... 3,
104-
... np.array([0,1,2]))[0])
104+
... np.array([0,1,2]))[0]))
105105
0j
106-
>>> np.round(iterate_function(eval_quadratic_polynomial,
106+
>>> complex(np.round(iterate_function(eval_quadratic_polynomial,
107107
... 0,
108108
... 3,
109-
... np.array([0,1,2]))[1])
109+
... np.array([0,1,2]))[1]))
110110
(1+0j)
111-
>>> np.round(iterate_function(eval_quadratic_polynomial,
111+
>>> complex(np.round(iterate_function(eval_quadratic_polynomial,
112112
... 0,
113113
... 3,
114-
... np.array([0,1,2]))[2])
114+
... np.array([0,1,2]))[2]))
115115
(256+0j)
116116
"""
117117

maths/gaussian.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77

88
def gaussian(x, mu: float = 0.0, sigma: float = 1.0) -> float:
99
"""
10-
>>> gaussian(1)
10+
>>> float(gaussian(1))
1111
0.24197072451914337
1212
13-
>>> gaussian(24)
13+
>>> float(gaussian(24))
1414
3.342714441794458e-126
1515
16-
>>> gaussian(1, 4, 2)
16+
>>> float(gaussian(1, 4, 2))
1717
0.06475879783294587
1818
19-
>>> gaussian(1, 5, 3)
19+
>>> float(gaussian(1, 5, 3))
2020
0.05467002489199788
2121
2222
Supports NumPy Arrays
@@ -29,7 +29,7 @@ def gaussian(x, mu: float = 0.0, sigma: float = 1.0) -> float:
2929
5.05227108e-15, 1.02797736e-18, 7.69459863e-23, 2.11881925e-27,
3030
2.14638374e-32, 7.99882776e-38, 1.09660656e-43])
3131
32-
>>> gaussian(15)
32+
>>> float(gaussian(15))
3333
5.530709549844416e-50
3434
3535
>>> gaussian([1,2, 'string'])
@@ -47,13 +47,13 @@ def gaussian(x, mu: float = 0.0, sigma: float = 1.0) -> float:
4747
...
4848
OverflowError: (34, 'Result too large')
4949
50-
>>> gaussian(10**-326)
50+
>>> float(gaussian(10**-326))
5151
0.3989422804014327
5252
53-
>>> gaussian(2523, mu=234234, sigma=3425)
53+
>>> float(gaussian(2523, mu=234234, sigma=3425))
5454
0.0
5555
"""
56-
return float(1 / sqrt(2 * pi * sigma**2) * exp(-((x - mu) ** 2) / (2 * sigma**2)))
56+
return 1 / sqrt(2 * pi * sigma**2) * exp(-((x - mu) ** 2) / (2 * sigma**2))
5757

5858

5959
if __name__ == "__main__":

other/bankers_algorithm.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ def __need_index_manager(self) -> dict[int, list[int]]:
8787
This function builds an index control dictionary to track original ids/indices
8888
of processes when altered during execution of method "main"
8989
Return: {0: [a: int, b: int], 1: [c: int, d: int]}
90-
>>> (BankersAlgorithm(test_claim_vector, test_allocated_res_table,
91-
... test_maximum_claim_table)._BankersAlgorithm__need_index_manager()
92-
... ) # doctest: +NORMALIZE_WHITESPACE
90+
>>> {key: [int(x) for x in value] in key, value in
91+
... BankersAlgorithm(test_claim_vector, test_allocated_res_table,
92+
... test_maximum_claim_table)._BankersAlgorithm__need_index_manager()
93+
... .items()} # doctest: +NORMALIZE_WHITESPACE
9394
{0: [1, 2, 0, 3], 1: [0, 1, 3, 1], 2: [1, 1, 0, 2], 3: [1, 3, 2, 0],
9495
4: [2, 0, 0, 3]}
9596
"""

0 commit comments

Comments
 (0)