Skip to content

Commit

Permalink
Remove ground truth length (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
VascoSch92 authored Dec 29, 2023
2 parents 59b062c + 6eb00a8 commit 20d508f
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 36 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ The version is represented by three digits: a.b.c.
---
## Unreleased

ENHANCEMENT:
- sequentium.tests.sequence_tests_suite.py: self.ground_truth_length is removed as we can perform same tests without it.

---
## [0.0.0] - 2023-12-28
Expand Down
7 changes: 3 additions & 4 deletions tests/sequence_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class SequenceTestSuite:
is_finite: bool = False
is_periodic: bool = False
ground_truth: List[int] = None
ground_truth_length: int = None

def test_sequence_name(self):
"""Test if the sequence's name matches the expected value."""
Expand All @@ -43,7 +42,7 @@ def test_is_periodic(self):
def test_len(self):
"""Test the length of the sequence, considering finiteness."""
if self.sequence.is_finite:
assert len(self.sequence) == self.ground_truth_length
assert len(self.sequence) == len(self.ground_truth)
else:
with pytest.raises(InfiniteSequenceError):
len(self.sequence)
Expand Down Expand Up @@ -84,8 +83,8 @@ def test_as_list(self):
"""Test if the as_list method returns the expected subsequence for various start and stop indices."""
error_msg = ''
count = 0
for j in range(self.ground_truth_length - 1):
for i in range(j, self.ground_truth_length):
for j in range(len(self.ground_truth) - 1):
for i in range(j, len(self.ground_truth)):
if self.sequence[j:i] != self.ground_truth[j:i]:
error_msg += f"{count}. Expected: {self.ground_truth[j:i]}. " \
f"Got {self.sequence[j:i]}!\n" \
Expand Down
10 changes: 0 additions & 10 deletions tests/tests_integer_sequences/test_explicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class TestA000027(SequenceTestSuite):
sequence = A000027()
sequence_name = 'natural numbers'
ground_truth = list(range(100))
ground_truth_length = len(ground_truth)


class TestA000217(SequenceTestSuite):
Expand All @@ -17,14 +16,12 @@ class TestA000217(SequenceTestSuite):
276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903,
946, 990, 1035, 1081, 1128, 1176, 1225, 1275, 1326, 1378, 1431,
]
ground_truth_length = len(ground_truth)


class TestA000290(SequenceTestSuite):
sequence = A000290()
sequence_name = 'square numbers'
ground_truth = [n**2 for n in range(100)]
ground_truth_length = len(ground_truth)


class TestA000326(SequenceTestSuite):
Expand All @@ -36,7 +33,6 @@ class TestA000326(SequenceTestSuite):
1080, 1162, 1247, 1335, 1426, 1520, 1617, 1717, 1820, 1926,
2035, 2147, 2262, 2380, 2501, 2625, 2752, 2882, 3015, 3151,
]
ground_truth_length = len(ground_truth)


class TestA000384(SequenceTestSuite):
Expand All @@ -47,7 +43,6 @@ class TestA000384(SequenceTestSuite):
1128, 1225, 1326, 1431, 1540, 1653, 1770, 1891, 2016, 2145, 2278, 2415, 2556, 2701, 2850, 3003, 3160, 3321,
3486, 3655, 3828, 4005, 4186, 4371, 4560,
]
ground_truth_length = len(ground_truth)


class TestA001045(SequenceTestSuite):
Expand All @@ -58,21 +53,18 @@ class TestA001045(SequenceTestSuite):
699051, 1398101, 2796203, 5592405, 11184811, 22369621, 44739243, 89478485, 178956971, 357913941, 715827883,
1431655765, 2863311531, 5726623061, 11453246123,
]
ground_truth_length = len(ground_truth)


class TestA003215(SequenceTestSuite):
sequence = A003215()
sequence_name = 'hex numbers'
ground_truth = [1, 7, 19, 37, 61, 91, 127, 169, 217]
ground_truth_length = len(ground_truth)


class TestA005408(SequenceTestSuite):
sequence = A005408()
sequence_name = 'odd numbers'
ground_truth = [2 * index + 1 for index in range(50)]
ground_truth_length = len(ground_truth)


class TestA014551(SequenceTestSuite):
Expand All @@ -83,11 +75,9 @@ class TestA014551(SequenceTestSuite):
1048577, 2097151, 4194305, 8388607, 16777217, 33554431, 67108865, 134217727, 268435457, 536870911, 1073741825,
2147483647, 4294967297, 8589934591,
]
ground_truth_length = len(ground_truth)


class TestA033999(SequenceTestSuite):
sequence = A033999()
sequence_name = 'sequence of powers of -1'
ground_truth = [(-1)**index for index in range(50)]
ground_truth_length = len(ground_truth)
3 changes: 0 additions & 3 deletions tests/tests_integer_sequences/test_finite.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ class TestA001228(FiniteSequenceTestSuite):
1255205709190661721292800, 4154781481226426191177580544000000,
808017424794512875886459904961710757005754368000000000,
]
ground_truth_length = len(ground_truth)


class TestA003173(FiniteSequenceTestSuite):
sequence = A003173()
sequence_name = 'Heegner numbers'
ground_truth = [1, 2, 3, 7, 11, 19, 43, 67, 163]
ground_truth_length = len(ground_truth)


class TestCollatzSequence(FiniteSequenceTestSuite):
sequence = CollatzSequence(start_value=19)
sequence_name = 'Collatz sequence'
ground_truth = [19, 58, 29, 88, 44, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]
ground_truth_length = len(ground_truth)
5 changes: 0 additions & 5 deletions tests/tests_integer_sequences/test_periodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class TestA087204(PeriodicSequenceTestSuite):
-2, -1, 1, 2, 1, -1, -2, -1, 1, 2, 1, -1, -2, -1, 1, 2, 1, -1, -2, -1, 1, 2, 1, -1, -2, -1, 1, 2, 1, -1, -2,
-1, 1, 2, 1, -1, -2, -1, 1,
]
ground_truth_length = len(ground_truth)


class TestA128834(PeriodicSequenceTestSuite):
Expand All @@ -25,7 +24,3 @@ class TestA128834(PeriodicSequenceTestSuite):
0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0,
-1, -1, 0, 1, 1,
]
ground_truth_length = len(ground_truth)



2 changes: 0 additions & 2 deletions tests/tests_integer_sequences/test_property_defined.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class TestA000040(SequenceTestSuite):
sequence = A000040()
sequence_name = 'prime numbers'
ground_truth = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]
ground_truth_length = len(ground_truth)


class TestA002808(SequenceTestSuite):
Expand All @@ -17,4 +16,3 @@ class TestA002808(SequenceTestSuite):
39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 68, 69,
70, 72, 74, 75, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88,
]
ground_truth_length = len(ground_truth)
12 changes: 0 additions & 12 deletions tests/tests_integer_sequences/test_recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class TestA000032(SequenceTestSuite):
64079, 103682, 167761, 271443, 439204, 710647, 1149851, 1860498, 3010349, 4870847, 7881196, 12752043, 20633239,
33385282, 54018521, 87403803,
]
ground_truth_length = len(ground_truth)


class TestA000045(SequenceTestSuite):
Expand All @@ -21,7 +20,6 @@ class TestA000045(SequenceTestSuite):
10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309,
3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155,
]
ground_truth_length = len(ground_truth)


class TestA000073(SequenceTestSuite):
Expand All @@ -32,7 +30,6 @@ class TestA000073(SequenceTestSuite):
121415, 223317, 410744, 755476, 1389537, 2555757, 4700770, 8646064, 15902591, 29249425, 53798080, 98950096,
181997601, 334745777, 615693474, 1132436852,
]
ground_truth_length = len(ground_truth)


class TestA000078(SequenceTestSuite):
Expand All @@ -43,7 +40,6 @@ class TestA000078(SequenceTestSuite):
283953, 547337, 1055026, 2033628, 3919944, 7555935, 14564533, 28074040, 54114452, 104308960, 201061985,
387559437, 747044834, 1439975216, 2775641472,
]
ground_truth_length = len(ground_truth)


class TestA000129(SequenceTestSuite):
Expand All @@ -54,7 +50,6 @@ class TestA000129(SequenceTestSuite):
6625109, 15994428, 38613965, 93222358, 225058681, 543339720, 1311738121, 3166815962, 7645370045, 18457556052,
44560482149, 107578520350, 259717522849,
]
ground_truth_length = len(ground_truth)


class TestA001591(SequenceTestSuite):
Expand All @@ -65,7 +60,6 @@ class TestA001591(SequenceTestSuite):
203513, 400096, 786568, 1546352, 3040048, 5976577, 11749641, 23099186, 45411804, 89277256, 175514464,
345052351, 678355061, 1333610936, 2621810068,
]
ground_truth_length = len(ground_truth)


class TestA001592(SequenceTestSuite):
Expand All @@ -76,7 +70,6 @@ class TestA001592(SequenceTestSuite):
233904, 463968, 920319, 1825529, 3621088, 7182728, 14247536, 28261168, 56058368, 111196417, 220567305,
437513522, 867844316, 1721441096, 3414621024,
]
ground_truth_length = len(ground_truth)


class TestA002203(SequenceTestSuite):
Expand All @@ -87,7 +80,6 @@ class TestA002203(SequenceTestSuite):
7761798, 18738638, 45239074, 109216786, 263672646, 636562078, 1536796802, 3710155682, 8957108166, 21624372014,
52205852194, 126036076402, 304278004998,
]
ground_truth_length = len(ground_truth)


class TestA079262(SequenceTestSuite):
Expand All @@ -109,7 +101,6 @@ class TestA104144(SequenceTestSuite):
129792, 259328, 518145, 1035269, 2068498, 4132920, 8257696, 16499120, 32965728, 65866496, 131603200, 262947072,
525375999, 1049716729, 2097364960,
]
ground_truth_length = len(ground_truth)


class TestA122189(SequenceTestSuite):
Expand All @@ -120,7 +111,6 @@ class TestA122189(SequenceTestSuite):
124946, 248888, 495776, 987568, 1967200, 3918592, 7805695, 15548665, 30972384, 61695880, 122895984, 244804400,
487641600, 971364608, 1934923521,
]
ground_truth_length = len(ground_truth)


class TestA214733(SequenceTestSuite):
Expand All @@ -131,5 +121,3 @@ class TestA214733(SequenceTestSuite):
61126, -16951, -166427, 217280, 282001, -933841, 87838, 2713685, -2977199, -5163856, 14095453, 1396115,
-43682474, 39494129, 91553293, -210035680,
]
ground_truth_length = len(ground_truth)

0 comments on commit 20d508f

Please sign in to comment.