id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
12920 Testsuite: allow sharing code between is_bar and _test_bar methods nthiery mvngu "{{{is_method}}} / {{{_test_from_is_method}}}: method wrappers to factor out code between {{{is_bar}}} and {{{_test_bar}}} methods
From the documentation:
The typical usecase for those wrappers is as follow: Consider a
category {{{Foo}}} with a subcategory {{{Bar}}}. {{{Foo}}} wants to
provide a method {{{Foo.ParentMethods.is_bar}}} such that, for {{{F}}}
in {{{Foo()}}}, {{{F.is_bar()}}} returns whether {{{F}}} satisfies all
the properties of {{{Bar()}}}. The method {{{is_bar}}} is allowed to
assume that {{{F}}} indeed satisfies all the properties specified by
{{{Foo()}}}. It may decide to upgrade the category of {{{F}}} to
{{{Bar()}}}.
{{{Bar}}} itself wants to provide a method
{{{Bar.ParentMethod._test_bar}}} which is supposed to do some
reasonable sanity checks on {{{F}}} to determine whether it
satisfies all the properties of {{{Bar}}}. If yes, {{{F._test_bla()}}}
should return None; otherwise it should raise some (hopefully
meaningful) assertion. Note that {{{Bar()}}} will typically
override {{{is_bar}}} by a trivial method that always returns
{{{True}}}.
The purpose of two decorators {{{is_method}}} and
{{{_test_method_from_is}}} is to factor out the logic between the two
related methods {{{F.is_bla()}}} and {{{F._test_bla()}}}. They take as
input a Python function {{{is_bla(self, proof=False, **options)}}}.
This function should proceed as usual for a {{{_test method}}} (see
:class:`TestSuite`). If {{{proof}}} is {{{True}}}, then the answer
should be provably correct. At the end, {{{is_bla}}} should return
{{{None}}}, or a category that will be used to refine the category
of {{{F}}}.
" enhancement needs_work major sage-7.6 misc days38 sage-combinat Nicolas M. Thiéry Franco Saliola N/A