Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit f1f67d3

Browse files
author
Matthias Koeppe
committed
FreeModuleCoBasis: Add _test_iter_len
1 parent 1e69c0e commit f1f67d3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/sage/tensor/modules/free_module_basis.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ def __iter__(self):
9090
def _test_iter_len(self, **options):
9191
r"""
9292
Test that __iter__ and __len__ work correctly.
93+
94+
EXAMPLES::
95+
96+
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
97+
sage: e = M.basis('e')
98+
sage: e._test_iter_len()
99+
93100
"""
94101
tester = self._tester(**options)
95102
g = iter(self)
@@ -416,6 +423,28 @@ def __init__(self, basis, symbol, latex_symbol=None, indices=None,
416423
self.set_name(symbol, latex_symbol=latex_symbol, indices=indices,
417424
latex_indices=latex_indices, index_position='up')
418425

426+
def _test_iter_len(self, **options):
427+
r"""
428+
Test that __iter__ and __len__ work correctly.
429+
430+
This method overrides ``Basis_abstract`` so that containment
431+
of elements in the dual of ``self.free_module()`` is tested instead.
432+
433+
EXAMPLES::
434+
435+
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
436+
sage: e = M.basis('e')
437+
sage: f = e.dual_basis()
438+
sage: f._test_iter_len()
439+
440+
"""
441+
tester = self._tester(**options)
442+
g = iter(self)
443+
b = list(g)
444+
for x in b:
445+
tester.assertTrue(x in self.free_module().dual())
446+
tester.assertEqual(len(b), len(self))
447+
tester.assertEqual(len(b), self.free_module().rank())
419448

420449
def _repr_(self):
421450
r"""

0 commit comments

Comments
 (0)