Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error inheriting DynGraph #105

Open
tyrael147 opened this issue Apr 15, 2021 · 0 comments
Open

Error inheriting DynGraph #105

tyrael147 opened this issue Apr 15, 2021 · 0 comments

Comments

@tyrael147
Copy link

Hi,
I have been trying to create a sub class inheriting from DynGraph to implement some desired functionality:

import dynetx as dn
class myDynGraph(dn.DynGraph):
    # custom new method  
    def myMethod(self):
          pass

but when I instantiate the new class G = myDynGraph(), I have the following error:

  File "/home/glarrea/miniconda3/envs/this_is_a_test_dev/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3417, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-4-da889620d25d>", line 1, in <module>
    a = myGraph()
  File "/home/glarrea/miniconda3/envs/this_is_a_test_dev/lib/python3.8/site-packages/dynetx/classes/dyngraph.py", line 121, in __init__
    super(self.__class__, self).__init__(data, **attr)
  File "/home/glarrea/miniconda3/envs/this_is_a_test_dev/lib/python3.8/site-packages/dynetx/classes/dyngraph.py", line 121, in __init__
    super(self.__class__, self).__init__(data, **attr)
  File "/home/glarrea/miniconda3/envs/this_is_a_test_dev/lib/python3.8/site-packages/dynetx/classes/dyngraph.py", line 121, in __init__
    super(self.__class__, self).__init__(data, **attr)
  [Previous line repeated 2981 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object

Modifying line 121 of dynetx/classes/dyngraph.py from :

121 super(self.__class__, self).__init__(data, **attr)
to:
121 super(DynGraph, self).__init__(data, **attr) worked for me.

Is there another way of inheriting without modifying the source code?

Thank you for the answer,

Gustavo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant