diff options
author | BonfaceKilz | 2021-10-26 08:48:30 +0300 |
---|---|---|
committer | GitHub | 2021-10-26 08:48:30 +0300 |
commit | 0cfff99e22155b6b15e23cbeff596f5f8f08709c (patch) | |
tree | c831f28534ebf6432972e107dbd6da5daef81088 /tests/unit/test_data_helpers.py | |
parent | 5440bfcd6940db08c4479a39ba66dbc802b2c426 (diff) | |
parent | c13afb3af166d2b01e4f9fd9b09bb231f0a63cb1 (diff) | |
download | genenetwork3-0cfff99e22155b6b15e23cbeff596f5f8f08709c.tar.gz |
Merge pull request #46 from genenetwork/partial-correlations
Partial correlations
Diffstat (limited to 'tests/unit/test_data_helpers.py')
-rw-r--r-- | tests/unit/test_data_helpers.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/unit/test_data_helpers.py b/tests/unit/test_data_helpers.py new file mode 100644 index 0000000..1eec3cc --- /dev/null +++ b/tests/unit/test_data_helpers.py @@ -0,0 +1,37 @@ +""" +Test functions in gn3.data_helpers +""" + +from unittest import TestCase + +from gn3.data_helpers import partition_all + +class TestDataHelpers(TestCase): + """ + Test functions in gn3.data_helpers + """ + + def test_partition_all(self): + """ + Test that `gn3.data_helpers.partition_all` partitions sequences as expected. + + Given: + - `num`: The number of items per partition + - `items`: A sequence of items + When: + - The arguments above are passed to the `gn3.data_helpers.partition_all` + Then: + - Return a new sequence with partitions, each of which has `num` + items in the same order as those in `items`, save for the last + partition which might have fewer items than `num`. + """ + for count, items, expected in ( + (1, [0, 1, 2, 3], ((0,), (1,), (2,), (3,))), + (3, (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), + ((0, 1, 2), (3, 4, 5), (6, 7, 8), (9, ))), + (4, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + ((0, 1, 2, 3), (4, 5, 6, 7), (8, 9))), + (13, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9), ))): + with self.subTest(n=count, items=items): + self.assertEqual(partition_all(count, items), expected) |