コード例 #1
0
ファイル: test_factors.py プロジェクト: vishalbelsare/SMQTK
 def test_100_random_with_caching(self):
     # Randomly test for prime values <= than 100th prime, NOT resetting the
     # cache each time.
     for _ in range(100):
         r = random.randint(0, max(p100) + 1)
         expected_primes = [p for p in p100 if p <= r]
         actual_primes = factors.sieve_of_eratosthenes(r)
         self.assertListEqual(expected_primes, actual_primes,
                              "Unexpected return for query value: %d" % r)
コード例 #2
0
ファイル: test_factors.py プロジェクト: Kitware/SMQTK
 def test_100_random_with_caching(self):
     # Randomly test for prime values <= than 100th prime, NOT resetting the
     # cache each time.
     for _ in range(100):
         r = random.randint(0, max(p100) + 1)
         expected_primes = [p for p in p100 if p <= r]
         actual_primes = factors.sieve_of_eratosthenes(r)
         self.assertListEqual(expected_primes, actual_primes,
                              "Unexpected return for query value: %d" % r)
コード例 #3
0
ファイル: test_factors.py プロジェクト: Kitware/SMQTK
 def test_15(self):
     self.assertListEqual(
         factors.sieve_of_eratosthenes(15),
         [2, 3, 5, 7, 11, 13]
     )
コード例 #4
0
ファイル: test_factors.py プロジェクト: Kitware/SMQTK
 def test_5(self):
     self.assertListEqual(
         factors.sieve_of_eratosthenes(5),
         [2, 3, 5]
     )
コード例 #5
0
ファイル: test_factors.py プロジェクト: Kitware/SMQTK
 def test_7(self):
     self.assertListEqual(
         factors.sieve_of_eratosthenes(7),
         [2, 3, 5, 7]
     )
コード例 #6
0
ファイル: test_factors.py プロジェクト: Kitware/SMQTK
 def test_2(self):
     self.assertListEqual(
         factors.sieve_of_eratosthenes(2),
         [2]
     )
コード例 #7
0
ファイル: test_factors.py プロジェクト: Kitware/SMQTK
 def test_4(self):
     self.assertListEqual(
         factors.sieve_of_eratosthenes(4),
         [2, 3]
     )
コード例 #8
0
ファイル: test_factors.py プロジェクト: vishalbelsare/SMQTK
 def test_5(self):
     self.assertListEqual(factors.sieve_of_eratosthenes(5), [2, 3, 5])
コード例 #9
0
ファイル: test_factors.py プロジェクト: Kitware/SMQTK
 def test_1(self):
     self.assertListEqual(
         factors.sieve_of_eratosthenes(1),
         []
     )
コード例 #10
0
ファイル: test_factors.py プロジェクト: vishalbelsare/SMQTK
 def test_100_with_caching(self):
     # First ask for a value with 99 prime returns, then a value with 100 to
     # see that we did get that new extra value.
     self.assertListEqual(factors.sieve_of_eratosthenes(540), p100[:-1])
     self.assertListEqual(factors.sieve_of_eratosthenes(541), p100)
コード例 #11
0
ファイル: test_factors.py プロジェクト: Kitware/SMQTK
 def test_100_primes(self):
     self.assertListEqual(factors.sieve_of_eratosthenes(541), p100)
コード例 #12
0
ファイル: test_factors.py プロジェクト: vishalbelsare/SMQTK
 def test_60(self):
     self.assertListEqual(
         factors.sieve_of_eratosthenes(60),
         [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59])
コード例 #13
0
ファイル: test_factors.py プロジェクト: vishalbelsare/SMQTK
 def test_100_primes(self):
     self.assertListEqual(factors.sieve_of_eratosthenes(541), p100)
コード例 #14
0
ファイル: test_factors.py プロジェクト: vishalbelsare/SMQTK
 def test_25(self):
     self.assertListEqual(factors.sieve_of_eratosthenes(25),
                          [2, 3, 5, 7, 11, 13, 17, 19, 23])
コード例 #15
0
ファイル: test_factors.py プロジェクト: vishalbelsare/SMQTK
 def test_15(self):
     self.assertListEqual(factors.sieve_of_eratosthenes(15),
                          [2, 3, 5, 7, 11, 13])
コード例 #16
0
ファイル: test_factors.py プロジェクト: vishalbelsare/SMQTK
 def test_7(self):
     self.assertListEqual(factors.sieve_of_eratosthenes(7), [2, 3, 5, 7])
コード例 #17
0
ファイル: test_factors.py プロジェクト: Kitware/SMQTK
 def test_25(self):
     self.assertListEqual(
         factors.sieve_of_eratosthenes(25),
         [2, 3, 5, 7, 11, 13, 17, 19, 23]
     )
コード例 #18
0
ファイル: test_factors.py プロジェクト: vishalbelsare/SMQTK
 def test_2(self):
     self.assertListEqual(factors.sieve_of_eratosthenes(2), [2])
コード例 #19
0
ファイル: test_factors.py プロジェクト: Kitware/SMQTK
 def test_60(self):
     self.assertListEqual(
         factors.sieve_of_eratosthenes(60),
         [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]
     )
コード例 #20
0
ファイル: test_factors.py プロジェクト: vishalbelsare/SMQTK
 def test_4(self):
     self.assertListEqual(factors.sieve_of_eratosthenes(4), [2, 3])
コード例 #21
0
ファイル: test_factors.py プロジェクト: Kitware/SMQTK
 def test_100_with_caching(self):
     # First ask for a value with 99 prime returns, then a value with 100 to
     # see that we did get that new extra value.
     self.assertListEqual(factors.sieve_of_eratosthenes(540), p100[:-1])
     self.assertListEqual(factors.sieve_of_eratosthenes(541), p100)
コード例 #22
0
ファイル: test_factors.py プロジェクト: vishalbelsare/SMQTK
 def test_1(self):
     self.assertListEqual(factors.sieve_of_eratosthenes(1), [])