First time here? Check out the FAQ!

Ask Your Question
1

I try to make a class derived from IntegerMod_abstract but simply calling the super().__init__ already fails.

asked 0 years ago

Jan Peeters gravatar image

updated 0 years ago

eric_g gravatar image

I don't know where to start. See the example code. Even when i implement set_from_mpz i get the same error.

from sage.rings.finite_rings.integer_mod import IntegerMod_abstract

class IntegerMod_centered(IntegerMod_abstract):
    def __init__(self, parent, value):
        super().__init__(parent, value)

R=Zmod(10)
IntegerMod_centered(R,5)

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
NotImplementedError: must be defined in child class
Exception ignored in: 'sage.rings.finite_rings.integer_mod.IntegerMod_abstract.set_from_mpz'
Traceback (most recent call last):
  File "<string>", line 5, in __init__
NotImplementedError: must be defined in child class
<repr(<__main__.IntegerMod_centered at 0x7f5caf4ad7c0>) failed: RecursionError: maximum recursion depth exceeded>
Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 0 years ago

You need to define the method set_from_mpz in your new class: the __init__ method for IntegerMod_abstract calls it, but it's not defined in IntegerMod_abstract — it's defined separately in each class that inherits from that one. This is what the error message

Exception ignored in: 'sage.rings.finite_rings.integer_mod.IntegerMod_abstract.set_from_mpz'
Traceback (most recent call last):
  File "<string>", line 5, in __init__
NotImplementedError: must be defined in child class

means.

(I am not a Cython expert, so there may be other requirements in addition when trying to base a class on a Cython class.)

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

1 follower

Stats

Asked: 0 years ago

Seen: 283 times

Last updated: Dec 01 '24