Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • graph-tool graph-tool
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 48
    • Issues 48
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Please use the issue tracker only to report bugs (i.e. errors in the library that need to be fixed) or feature requests.

For questions about how to compile, install or use the library, please use instead the web forum at https://forum.skewed.de/c/graph-tool.


(If unsure, use the forum first.)


IMPORTANT: When opening new issues, please choose the BUG template from the drop-down menu, and fill out the required information.

  • Tiago Peixoto
  • graph-toolgraph-tool
  • Issues
  • #190
Closed
Open
Issue created Oct 09, 2014 by Joel Moberg@joelmo

Pickling BlockState

I have tried to figure out why pickling a BlockState doesn't work for me, here is the code I tried:

from graph_tool import collection
from graph_tool.community import minimize_blockmodel_dl
import cPickle as pickle
g = collection.data['polbooks']
block = minimize_blockmodel_dl(g)
pickle.dump(block, open(u'block.p', u'wb'))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-42-72ab45d5f5f1> in <module>()
      4 g = collection.data['polbooks']
      5 block = minimize_blockmodel_dl(g)
----> 6 pickle.dump(block, open(u'block.p', u'wb'))

/usr/lib/python2.7/copy_reg.pyc in _reduce_ex(self, proto)
     82             dict = None
     83     else:
---> 84         dict = getstate()
     85     if dict:
     86         return _reconstructor, args, dict

/usr/lib/python2.7/dist-packages/graph_tool/__init__.pyc in __getstate__(self)
   2155         state = dict()
   2156         sio = BytesIO()
-> 2157         stream = gzip.open(sio, mode="wb")
   2158         self.save(stream, "gt")
   2159         stream.close()

/usr/lib/python2.7/gzip.pyc in open(filename, mode, compresslevel)
     32 
     33     """
---> 34     return GzipFile(filename, mode, compresslevel)
     35 
     36 class GzipFile(io.BufferedIOBase):

/usr/lib/python2.7/gzip.pyc in __init__(self, filename, mode, compresslevel, fileobj, mtime)
     92             mode += 'b'
     93         if fileobj is None:
---> 94             fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
     95         if filename is None:
     96             # Issue #13781: os.fdopen() creates a fileobj with a bogus name

TypeError: coercing to Unicode: need string or buffer, _io.BytesIO found


graph_tool.__version__
'2.2.36dev (commit f4111815, Thu Sep 25 17:22:05 2014 +0200)'

Does the same code work for you?

Assignee
Assign to
Time tracking