Reasoning TypeError: a __bases__ item causes an inheritance cycle

classic Classic list List threaded Threaded
5 messages Options
rdk
Reply | Threaded
Open this post in threaded view
|

Reasoning TypeError: a __bases__ item causes an inheritance cycle

rdk
Hi Jean-Baptiste,

I have come across a different error while running HermiT.
The reasoner starts to work correctly but at some point it breaks, throwing the following error:

Traceback (most recent call last):
  File "C:\Users\R\Google Drive\PhD\PhD_ONTO-GRAMMARS\00_DEVELOPER\002_Python_VEnvs\KB_Tests\Geom-Onto_creator.py", line 475, in <module>
    with geom: sync_reasoner()
  File "C:\Users\R\GOOGLE~1\PhD\PHD_ON~1\00_DEV~1\002_PY~1\KB_Tests\lib\site-packages\owlready2\reasoning.py", line 154, in sync_reasoner
    child.is_a.reinit(new_is_a)
  File "C:\Users\R\GOOGLE~1\PhD\PHD_ON~1\00_DEV~1\002_PY~1\KB_Tests\lib\site-packages\owlready2\util.py", line 57, in reinit
    def reinit(self, l):          old = list(self); super().__init__(l)       ; self._callback(self._obj, old)
  File "C:\Users\R\GOOGLE~1\PhD\PHD_ON~1\00_DEV~1\002_PY~1\KB_Tests\lib\site-packages\owlready2\entity.py", line 206, in _class_is_a_changed
    Class.__bases__ = bases
  File "C:\Users\R\GOOGLE~1\PhD\PHD_ON~1\00_DEV~1\002_PY~1\KB_Tests\lib\site-packages\owlready2\entity.py", line 434, in __setattr__
    super().__setattr__(attr, value)
  File "C:\Users\R\GOOGLE~1\PhD\PHD_ON~1\00_DEV~1\002_PY~1\KB_Tests\lib\site-packages\owlready2\entity.py", line 192, in __setattr__
    type.__setattr__(Class, attr, value)
TypeError: a __bases__ item causes an inheritance cycle
[Finished in 3.4s with exit code 1]


Do you have any idea of what might be causing this error?

Best regards,

Rui
Reply | Threaded
Open this post in threaded view
|

Re: Reasoning TypeError: a __bases__ item causes an inheritance cycle

Jiba
Administrator
Hi,

> TypeError: a __bases__ item causes an inheritance cycle
> [Finished in 3.4s with exit code 1]*
>
> Do you have any idea of what might be causing this error?


I think the reasoning results in an inheritance cycle, for example A is B, B is a C and C is a D. This is allowed in OWL ontology, but not supported by Python (or any object-oriented language).

It is quite probable that the cycle is not intended and results in a modelling error. In this case, you should edit the ontology with Protégé, execute HermiT and see were is the cycle and whether it is the desired result or not. In Protégé, the cycle may results in many equivalent classes.

Best regards,
Jean-Baptiste Lamy
MCF, LIMICS, Université Paris 13

> Hi Jean-Baptiste,
>
> I have come across a different error while running HermiT.
> The reasoner starts to work correctly but at some point it breaks, throwing
> the following error:
>
> *Traceback (most recent call last):
>   File "C:\Users\R\Google
> Drive\PhD\PhD_ONTO-GRAMMARS\00_DEVELOPER\002_Python_VEnvs\KB_Tests\Geom-Onto_creator.py",
> line 475, in <module>
>     with geom: sync_reasoner()
>   File
> "C:\Users\R\GOOGLE~1\PhD\PHD_ON~1\00_DEV~1\002_PY~1\KB_Tests\lib\site-packages\owlready2\reasoning.py",
> line 154, in sync_reasoner
>     child.is_a.reinit(new_is_a)
>   File
> "C:\Users\R\GOOGLE~1\PhD\PHD_ON~1\00_DEV~1\002_PY~1\KB_Tests\lib\site-packages\owlready2\util.py",
> line 57, in reinit
>     def reinit(self, l):          old = list(self); super().__init__(l)      
> ; self._callback(self._obj, old)
>   File
> "C:\Users\R\GOOGLE~1\PhD\PHD_ON~1\00_DEV~1\002_PY~1\KB_Tests\lib\site-packages\owlready2\entity.py",
> line 206, in _class_is_a_changed
>     Class.__bases__ = bases
>   File
> "C:\Users\R\GOOGLE~1\PhD\PHD_ON~1\00_DEV~1\002_PY~1\KB_Tests\lib\site-packages\owlready2\entity.py",
> line 434, in __setattr__
>     super().__setattr__(attr, value)
>   File
> "C:\Users\R\GOOGLE~1\PhD\PHD_ON~1\00_DEV~1\002_PY~1\KB_Tests\lib\site-packages\owlready2\entity.py",
> line 192, in __setattr__
>     type.__setattr__(Class, attr, value)
> TypeError: a __bases__ item causes an inheritance cycle
> [Finished in 3.4s with exit code 1]*
>
> Do you have any idea of what might be causing this error?
>
> Best regards,
>
> Rui
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://owlready.8326.n8.nabble.com/Reasoning-TypeError-a-bases-item-causes-an-inheritance-cycle-tp180.html
> To start a new topic under Owlready, email [hidden email]
> To unsubscribe from Owlready, visit
rdk
Reply | Threaded
Open this post in threaded view
|

Re: Reasoning TypeError: a __bases__ item causes an inheritance cycle

rdk
Hi Jean-Baptiste,

Thanks for the clarification.
I have since edited the ontology in Protégé and ran HermiT whithin Protégé: no sign of cycles happening.
Adding some new classes with property restrictions didn't result in many equivalent classes: the reasoner worked as expected.

Best regards,
Rui
Reply | Threaded
Open this post in threaded view
|

Re: Reasoning TypeError: a __bases__ item causes an inheritance cycle

Jiba
Administrator
Hello,

Could you send me the ontology, so I can test?

This might also be related to the same problem that we discussed by email (VectorX being of type VectorX).

Kind regards,
Jean-Baptiste Lamy
MCF, LIMICS, Université Paris 13
rdk
Reply | Threaded
Open this post in threaded view
|

Re: Reasoning TypeError: a __bases__ item causes an inheritance cycle

rdk
Hi Jean-Baptiste,

Thank you for your replies.
I think that might be the case.

The strange thing is that situation (VectorX being of type VectorX) is created by the reasoner, not a coded assertion.
I will send you an e-mail with the ontology and the code that creates it.

Best regards,

Rui de Klerk