22# This software is distributed under the terms of the MIT License.
33# Author: Pavel Kirienko <[email protected] > 44
5- import typing
65import random
76import itertools
87from ._symbolic import NullaryOperator , validate_numerically
@@ -140,7 +139,7 @@ def _unittest_repetition() -> None:
140139 )
141140 assert op .min == 7 * 3
142141 assert op .max == 17 * 3
143- assert set (op .expand ()) == set (map (sum , itertools .combinations_with_replacement ([7 , 11 , 17 ], 3 ))) # type: ignore
142+ assert set (op .expand ()) == set (map (sum , itertools .combinations_with_replacement ([7 , 11 , 17 ], 3 )))
144143 assert set (op .expand ()) == {21 , 25 , 29 , 31 , 33 , 35 , 39 , 41 , 45 , 51 }
145144 assert set (op .modulo (7 )) == {0 , 1 , 2 , 3 , 4 , 5 , 6 }
146145 assert set (op .modulo (8 )) == {1 , 3 , 5 , 7 }
@@ -149,15 +148,15 @@ def _unittest_repetition() -> None:
149148 for _ in range (1 ):
150149 child = NullaryOperator (random .randint (0 , 100 ) for _ in range (random .randint (1 , 10 )))
151150 k = random .randint (0 , 10 )
152- ref = set (map (sum , itertools .combinations_with_replacement (child .expand (), k ))) # type: ignore
151+ ref = set (map (sum , itertools .combinations_with_replacement (child .expand (), k )))
153152 op = RepetitionOperator (child , k )
154153 assert set (op .expand ()) == ref
155154
156155 assert op .min == min (child .expand ()) * k
157156 assert op .max == max (child .expand ()) * k
158157
159158 div = random .randint (1 , 64 )
160- assert set (op .modulo (div )) == {typing . cast ( int , x ) % div for x in ref }
159+ assert set (op .modulo (div )) == {x % div for x in ref }
161160
162161 validate_numerically (op )
163162
@@ -173,9 +172,9 @@ def _unittest_range_repetition() -> None:
173172 assert op .max == 17 * 3
174173 assert set (op .expand ()) == (
175174 {0 }
176- | set (map (sum , itertools .combinations_with_replacement ([7 , 11 , 17 ], 1 ))) # type: ignore
177- | set (map (sum , itertools .combinations_with_replacement ([7 , 11 , 17 ], 2 ))) # type: ignore
178- | set (map (sum , itertools .combinations_with_replacement ([7 , 11 , 17 ], 3 ))) # type: ignore
175+ | set (map (sum , itertools .combinations_with_replacement ([7 , 11 , 17 ], 1 )))
176+ | set (map (sum , itertools .combinations_with_replacement ([7 , 11 , 17 ], 2 )))
177+ | set (map (sum , itertools .combinations_with_replacement ([7 , 11 , 17 ], 3 )))
179178 )
180179 assert set (op .expand ()) == {0 , 7 , 11 , 14 , 17 , 18 , 21 , 22 , 24 , 25 , 28 , 29 , 31 , 33 , 34 , 35 , 39 , 41 , 45 , 51 }
181180 assert set (op .modulo (7 )) == {0 , 1 , 2 , 3 , 4 , 5 , 6 }
@@ -197,10 +196,7 @@ def _unittest_range_repetition() -> None:
197196 k_max = random .randint (0 , 10 )
198197 ref = set (
199198 itertools .chain (
200- * (
201- map (sum , itertools .combinations_with_replacement (child .expand (), k )) # type: ignore
202- for k in range (k_max + 1 )
203- )
199+ * (map (sum , itertools .combinations_with_replacement (child .expand (), k )) for k in range (k_max + 1 ))
204200 )
205201 )
206202 op = RangeRepetitionOperator (child , k_max )
@@ -210,7 +206,7 @@ def _unittest_range_repetition() -> None:
210206 assert op .max == max (child .expand ()) * k_max
211207
212208 div = random .randint (1 , 64 )
213- assert set (op .modulo (div )) == {typing . cast ( int , x ) % div for x in ref }
209+ assert set (op .modulo (div )) == {x % div for x in ref }
214210
215211 validate_numerically (op )
216212
0 commit comments