0

It seems that PyCLIPS converts very large numbers to int before translating them.

See here for conversion Python -> CLIPS

def _py2cl(o):
    """convert Python data to a well-formed tuple"""
    t1 = type(o)
    if t1 in (int, long):
        return (_c.INTEGER, int(o))

But also here for conversion CLIPS -> Python

...
def _cl2py(o):
    """convert a well-formed tuple to one of the CLIPS wrappers"""
    if o is None: return None
    elif type(o) == tuple and len(o) == 2:
        if o[0] == _c.INTEGER:
            return Integer(o[1])
...


...
# 1) numeric types
class Integer(int):
    """extend an int for use with CLIPS"""
    def __repr__(self):
        return "<Integer %s>" % int.__repr__(self)
    def __add__(self, o):
        return Integer(int(self) + int(o))
...

Am I right that there is no type for long, neither in CLIPS nor in PyCLIPS? Is everything casted (truncated) to int? Is this a bug?

I am asking because passing the value 6442901632 from CLIPS to python, via a python-call becomes the value 0x7fffffff in python. Or is my 32bit Python causing the issue?

How can I pass values that are bigger than python's int from CLIPS to python via PyClips?

Amittai Shapira
  • 3,749
  • 1
  • 30
  • 54
langlauf.io
  • 3,009
  • 2
  • 28
  • 45
  • What CLIPS version are you on? – user2357112 Dec 12 '16 at 19:59
  • @user2357112 Is there a quick way to find out using PyCLIPS? I re-used the folder `pyclips\build\lib.win32-2.7\clips` from an old installation. This way I avoided the tricky installation process of PyCLIPS. I am running Windows 7 64bit. – langlauf.io Dec 12 '16 at 20:03
  • @user2357112 I ran the Linux cmd tool 'strings' on the file `_clips.pyd` and got `V6.20`, `CLIPS (V6.24 06/15/06)`, `V6.00` as well as `V6.20` – langlauf.io Dec 12 '16 at 20:15
  • Try upgrading. 64-bit integers were added to CLIPS in a later version. – user2357112 Dec 12 '16 at 21:03
  • @user2357112 By default, PyCLIPS installs version 6.24. The `setup.py` of PyCLIPS is complex and seems to be adapted to work with 6.24 (only?). Do you know how to install PyCLIPS with a CLIPS in a later version? – langlauf.io Dec 13 '16 at 12:09
  • Dunno. I've never used it; I just Googled CLIPS and found the 64-bit integer thing in the 6.30 changelog. – user2357112 Dec 13 '16 at 15:46
  • Thanks for your hint. It is indeed the problem of clips. So you were right I verified it – langlauf.io Dec 13 '16 at 15:48
  • 1
    Some information on a 6.3 patch for PyCLIPS: https://sourceforge.net/p/pyclips/feature-requests/21/ – Gary Riley Dec 13 '16 at 23:32

0 Answers0