Error in docs example ‘reasoning-ready’ ontology

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

Error in docs example ‘reasoning-ready’ ontology

Enzo
I'm going through all the docs and I'm learning lots.
I'm using anaconda python 3.6.4

I found the following when I run

AllDifferent(acetaminophen, amoxicillin, clavulanic_acid)

I get an error:  TypeError: 'ActivePrinciple' object is not iterable

See below the full report.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-b2241fcfac6e> in <module>()
----> 1 AllDifferent(acetaminophen, amoxicillin, clavulanic_acid)

~/anaconda3/lib/python3.6/site-packages/owlready2/disjoint.py in __init__(self, entities, ontology, bnode)
     41       self.storid      = bnode
     42       self._list_bnode = None
---> 43       self.entities = self.Properties = self.individuals = CallbackList(entities, self, AllDisjoint._callback)
     44
     45     if not LOADING: self._create_triples()

~/anaconda3/lib/python3.6/site-packages/owlready2/util.py in __init__(self, l, obj, callback)
     49   __slots__ = ["_obj", "_callback"]
     50   def __init__(self, l, obj, callback):
---> 51     super().__init__(l)
     52     self._obj      = obj
     53     self._callback = callback

TypeError: 'ActivePrinciple' object is not iterable
Reply | Threaded
Open this post in threaded view
|

Re: Error in docs example ‘reasoning-ready’ ontology

Jiba
Administrator
Hello,

AllDifferent normally expects a list, so the right syntax is:

        AllDifferent([acetaminophen, amoxicillin, clavulanic_acid])

(notice the "[]")

I've searched the doc for the problem you mention, but I was unable to find it. Could you give me the link of the filename? Are you sure you are not reading the doc for OwlReady version 1? (in version 1, AllDifferent did not expect a list, this is a change in version 2).

Best regards,
Jean-Baptiste Lamy