Ask Your Question
1

polynomial ring instance check

asked 2012-01-18 17:32:10 +0100

araichev gravatar image

Hi there, folks. How do i check if something is an instance of a polynomial ring (univariate or multivariate)?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-01-18 19:17:52 +0100

Volker Braun gravatar image

First of all, do you really need to? Just allow any input, if it does not have the methods you are calling then you will get a suitable AttributeError exception thrown. AKA duck-typing.

If you are sure that you actually have to check the type, use the convenience functions:

sage: from sage.rings.polynomial.polynomial_ring import is_PolynomialRing
sage: is_PolynomialRing('string')
False
sage: from sage.rings.polynomial.multi_polynomial_ring import is_MPolynomialRing
sage: is_MPolynomialRing('string')                                              
False
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-01-18 17:32:10 +0100

Seen: 345 times

Last updated: Jan 18 '12