Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in Count iterator #73

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
python-version: '3.11'
- name: Install dependencies and local packages
run: python -m pip install sphinx pydata-sphinx-theme sphinx-autoapi sphinx-design
run: python -m pip install sphinx pydata-sphinx-theme "sphinx-autoapi != 3.4.0" sphinx-design
- name: Build HTML documentation with Sphinx
run: |
make html
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
python-version: '3.11'
- name: Install dependencies and local packages
run: python -m pip install sphinx pydata-sphinx-theme sphinx-autoapi sphinx-design
run: python -m pip install sphinx pydata-sphinx-theme "sphinx-autoapi != 3.4.0" sphinx-design
- name: Build HTML documentation with Sphinx
run: |
make html
Expand Down
2 changes: 1 addition & 1 deletion src/tempe/data_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def __iter__(self):
i = self.start
while True:
yield i
i += 1
i += self.step

def __len__(self):
return None
Expand Down
56 changes: 56 additions & 0 deletions tests/tempe/test_data_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <[email protected]>
#
# SPDX-License-Identifier: MIT

import unittest

from tempe.data_view import Count


class TestCount(unittest.TestCase):

def test_count(self):
"""Test count starts and steps as expected."""

count = Count(10, 5)
count_iter = iter(count)

self.assertEqual(next(count_iter), 10)
self.assertEqual(next(count_iter), 15)
self.assertEqual(next(count_iter), 20)

def test_count_getitem(self):
"""Test count getitem works as expected."""

count = Count(10, 5)

self.assertEqual(count[0], 10)
self.assertEqual(count[1], 15)
self.assertEqual(count[2], 20)

def test_count_default(self):
"""Test count default starts and steps as expected."""

count = Count()
count_iter = iter(count)

self.assertEqual(next(count_iter), 0)
self.assertEqual(next(count_iter), 1)
self.assertEqual(next(count_iter), 2)

def test_count_default_getitem(self):
"""Test count default getitem works as expected."""

count = Count()

self.assertEqual(count[0], 0)
self.assertEqual(count[1], 1)
self.assertEqual(count[2], 2)


if __name__ == "__main__":
result = unittest.main()
if not result.wasSuccessful():
import sys

sys.exit(1)
Loading