First time here? Check out the FAQ!

Ask Your Question
1

polynomial ring instance check

asked 13 years ago

araichev gravatar image

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

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 13 years ago

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
Preview: (hide)
link

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: 13 years ago

Seen: 388 times

Last updated: Jan 18 '12