some_elements and TestSuite

29 views
Skip to first unread message

Martin R

unread,
Jun 29, 2026, 7:46:14 AM (yesterday) Jun 29
to sage-devel
Dear all,

I have a problem with the interaction of `TestSuite` and some_elements.  Let me illustrate the problem by example.  Below is the definition of `_test_graded_components`, which looks reasonable.  However, for some `SetsWithGrading`, the grading set' `some_elements` yields degrees which are way too large.

E.g., AtomicSpecies("X") is graded by `IntegerVectors(1)`, where `some_elements` yields the first 100 integers.  Constructing `AtomicSpecies("X").graded_component([8])` takes already a few seconds.

Is the intention to make `graded_component` always return a lazy set?

Martin

        def _test_graded_components(self, **options):
            r"""
            Test that some graded components of ``self`` are parent with
            initialized category and that the parent has a properly implemented
            ``grading()`` method.

            EXAMPLES::

                sage: SetsWithGrading().example()._test_graded_components()
            """
            tester = self._tester(**options)
            for grade in self.grading_set().some_elements():
                G = self.graded_component(grade)
                if self in EnumeratedSets():
                    tester.assertIn(G, EnumeratedSets())
                else:
                    tester.assertIn(G, Sets())
                for elt in G.some_elements():
                    tester.assertEqual(self.grading(elt), grade)

Travis Scrimshaw

unread,
1:53 AM (10 hours ago) 1:53 AM
to sage-devel
Hi Martin,
   I think the _test_graded_components() method should have an additional option to specify which grades to test in order to give the more control to whomever is running the tests. This would be analogous to TestSuite(X).run(elements=foo), and would follow that implementation too. Perhaps call the argument "grading_elements"?

Best,
Travis
Reply all
Reply to author
Forward
0 new messages