Aluriak / clyngor

Handy python wrapper around Potassco's Clingo ASP solver.
GNU General Public License v3.0
34 stars 7 forks source link

__str__ method of Atom in as_pyasp fails if arguments are of different types #16

Closed cfrioux closed 5 years ago

cfrioux commented 5 years ago

Pyasp supports having a str and a int as arguments for an atom (Term). Apparently clyngor.as_pyasp does not. Here is a MWE:

from pyasp import *
from clyngor.as_pyasp import TermSet, Atom
elem = 'plop'
weight = 2
cofactors_pyasp = Term('cofactor', ["\""+elem+"\"",+weight])
cofactors_clyngor = Atom('cofactor', ["\""+elem+"\"",+weight])
print(cofactors_pyasp)
print(cofactors_clyngor)

gives the following error for the clyngor version:

Traceback (most recent call last):
  File "../menetools/test_print.py", line 10, in <module>
    print(cofactors_clyngor)
  File "/Users/cfrioux/wd/scripts/MeneTools/venv_clyngor/lib/python3.7/site-packages/clyngor/as_pyasp.py", line 32, in __str__
    return '{}({})'.format(self.predicate, ','.join(self.arguments))
TypeError: sequence item 1: expected str instance, int found

whereas the pyasp version gives:

cofactor("plop",2)
Aluriak commented 5 years ago

That's an obvious problem ; will fix this tomorrow !