Skip to content

Commit

Permalink
Fix doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenny2github committed Jul 4, 2022
1 parent 9cd01b5 commit d0f999c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions multivectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def idxs_to_names(idxs: Index, sep: str = '') -> str:
>>> idxs_to_names(2)
'z'
>>> idxs_to_names((0, 2, 3), sep='*')
'x*y*w'
'x*z*w'
"""
idxs = idxs_to_idxs(idxs)
if max(idxs) > 3:
Expand Down Expand Up @@ -399,7 +399,7 @@ def __getitem__(self, grades: Index) -> MultiVector:
>>> (1 + 2*x + 3*x*y)[:2]
(1.0 + 2.0 * x)
>>> (1 + 2*x + 3*x*y)[1:]
(2.0 * x + 4.0 * x*y)
(2.0 * x + 3.0 * x*y)
"""
if isinstance(grades, slice):
stop = (max(map(len, self.termdict.keys())) + 1) \
Expand Down Expand Up @@ -449,7 +449,7 @@ def __str__(self) -> str:
if self.grade is not None:
((bases, scalar),) = self.termdict.items()
if bases == ():
return str(scalar)
return f'{scalar:.2f}'
names = idxs_to_names(bases)
return f'{scalar:.2f}{names!s}'
return '(' + ' + '.join(map(str, self.terms)) + ')'
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ version = {attr = "multivectors.__version__"}
[tool.pytest.ini_options]
addopts = [
"--doctest-modules",
"--doctest-glob=*.md"
"--doctest-glob=*.rst"
]

0 comments on commit d0f999c

Please sign in to comment.