Return false or raise error on some situations

46 views
Skip to first unread message

Jori Mäntysalo

unread,
Dec 4, 2016, 2:59:47 AM12/4/16
to sage-...@googlegroups.com
Currently

Posets.PentagonPoset().is_antichain_of_poset([2,3,'junk'])

returns False and

Posets.PentagonPoset().is_antichain_of_poset(['junk',2,3])

raises an error. At https://trac.sagemath.org/ticket/19078 I and Travis
have different opinion about which one is the right answer. So please give
your opinion.

* * *

I think we all agree that this should be consistent, and something like
is_induced_subposet() should also behave in the same way.

--
Jori Mäntysalo

Travis Scrimshaw

unread,
Dec 4, 2016, 8:54:41 AM12/4/16
to sage-devel
To clarify slightly, I want both cases to return False, whereas Jori wants both cases to raise an error. Same reasoning for me as is_similar for matrices.

Best,
Travis

Jeroen Demeyer

unread,
Dec 5, 2016, 1:57:52 AM12/5/16
to sage-...@googlegroups.com
On 2016-12-04 08:59, Jori Mäntysalo wrote:
> Currently
>
> Posets.PentagonPoset().is_antichain_of_poset([2,3,'junk'])
>
> returns False and
>
> Posets.PentagonPoset().is_antichain_of_poset(['junk',2,3])
>
> raises an error. At https://trac.sagemath.org/ticket/19078 I and Travis
> have different opinion about which one is the right answer. So please
> give your opinion.

I would vote for both cases to give an error. When some user does
Posets.PentagonPoset().is_antichain_of_poset(['junk',2,3]) it is most
likely to be an error. I don't see much usefulness of a "False" answer
here. I understand the mathematical argument why you want to return
False to a yes/no question, but that argument only works because it
returns a boolean. In general, when the input to some function a priori
makes no sense, an error should be raised.

Jeroen.
Reply all
Reply to author
Forward
0 new messages