Skip to content

AttributeError on serializing database #15

@thomas-daniels

Description

@thomas-daniels

Python 3.11.3, on the working branch.

I initially came across this error when running the wikimovies experiment, but it is reproducible with a minimal example:

from tensorlog import comline
db = comline.parseDBSpec("inputs/train-250.cfacts")
db.serialize("test.db")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/thomas/.local/lib/python3.11/site-packages/tensorlog-1.2.5-py3.11.egg/tensorlog/matrixdb.py", line 314, in serialize
    self.serializeDataTo(os.path.join(direc,"db.mat"))
  File "/home/thomas/.local/lib/python3.11/site-packages/tensorlog-1.2.5-py3.11.egg/tensorlog/matrixdb.py", line 329, in serializeDataTo
    self._saveMatDictWithScipy(fileLike,d)
  File "/home/thomas/.local/lib/python3.11/site-packages/tensorlog-1.2.5-py3.11.egg/tensorlog/matrixdb.py", line 348, in _saveMatDictWithScipy
    scipy.io.savemat(fileLike,d,do_compression=True)
  File "/usr/lib/python3.11/site-packages/scipy/io/matlab/_mio.py", line 300, in savemat
    MW.put_variables(mdict)
  File "/usr/lib/python3.11/site-packages/scipy/io/matlab/_mio5.py", line 884, in put_variables
    self._matrix_writer.write_top(var, name.encode('latin1'), is_global)
                                       ^^^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'encode'

(This also happens with cfacts files that are a lot more trivial than the wikimovies one, so it does not appear to be database-specific.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions