-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from flexiblepower/fix/support-python-3.8
adapt code to work in Python 3.8
- Loading branch information
Showing
10 changed files
with
85 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def pairwise(arr : list): | ||
for i in range(max(len(arr) - 1,0)): | ||
yield (arr[i], arr[i+1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from unittest import TestCase | ||
|
||
from s2python.utils import pairwise | ||
|
||
class PairwiseTest(TestCase): | ||
def test_empty(self): | ||
# Arrange | ||
input_array = [] | ||
|
||
# Act | ||
pairs = list(pairwise(input_array)) | ||
|
||
# Assert | ||
self.assertEqual(len(pairs), 0) | ||
|
||
def test_len_2(self): | ||
# Arrange | ||
input_array = [1,2] | ||
|
||
# Act | ||
pairs = list(pairwise(input_array)) | ||
|
||
# Assert | ||
self.assertEqual(pairs, [(1,2)]) | ||
|
||
def test_odd(self): | ||
# Arrange | ||
input_array = [1,2,3] | ||
|
||
# Act | ||
pairs = list(pairwise(input_array)) | ||
|
||
# Assert | ||
self.assertEqual(pairs, [(1,2), (2,3)]) | ||
|
||
def test_even(self): | ||
# Arrange | ||
input_array = [1,2,3,4] | ||
|
||
# Act | ||
pairs = list(pairwise(input_array)) | ||
|
||
# Assert | ||
self.assertEqual(pairs, [(1,2), (2,3), (3,4)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters