Ticket #178 (closed defect: invalid)

Opened 6 years ago

Last modified 6 years ago

networkx matplotlib chaco incompatibility

Reported by: danhomerick@… Owned by: aric
Priority: normal Milestone:
Component: networkx Version:
Severity: normal Keywords:
Cc:

Description

See the bug report submitted to the Enthought Chaco project: https://svn.enthought.com/enthought/ticket/1710

Copied below:


Adding the line:

import networkx

will cause even the chaco/examples/new_tutorial/tut1.py script to fail with a "TypeError??: 'trans_affine' object is unindexable" exception.

This is on Linux (Ubuntu) with Python 2.5, networkx 0.37 (latest release), and Chaco 3.0.0, and matplotlib 0.91 (version available in the Ubuntu repository).

It only occurs when matplotlib is installed. Removing matplotlib allows you to import networkx without issue. Interestingly, using 'import matplotlib' in the same script does not cause any problems.

Traceback: homerick@homerick-laptop ~/P/c/e/new_tutorial> python tut1.py Traceback (most recent call last):

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/enable/abstract_window.py", line 340, in _paint

self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/enable/component.py", line 416, in draw

self._draw(gc, view_bounds, mode)

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/enable/component.py", line 728, in _draw

self._dispatch_draw(layer, gc, view_bounds, mode)

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/enable/container.py", line 310, in _dispatch_draw

my_handler(gc, view_bounds, mode)

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/enable/container.py", line 349, in _draw_container_underlay

self._draw_underlay(gc, view_bounds, mode)

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/enable/component.py", line 844, in _draw_underlay

underlay.overlay(self, gc, view_bounds, mode)

File "/usr/lib/python2.5/site-packages/Chaco-3.0.0-py2.5-linux-i686.egg/enthought/chaco/axis.py", line 245, in overlay

self._draw_component(gc, view_bounds, mode, component)

File "/usr/lib/python2.5/site-packages/Chaco-3.0.0-py2.5-linux-i686.egg/enthought/chaco/axis.py", line 271, in _draw_component

self._compute_labels(gc)

File "/usr/lib/python2.5/site-packages/Chaco-3.0.0-py2.5-linux-i686.egg/enthought/chaco/axis.py", line 614, in _compute_labels

ctm = gc.get_ctm()

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/kiva/agg/agg.py", line 855, in get_ctm

return (tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5])

TypeError??: 'trans_affine' object is unindexable Traceback (most recent call last):

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/enable/abstract_window.py", line 340, in _paint

self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/enable/component.py", line 416, in draw

self._draw(gc, view_bounds, mode)

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/enable/component.py", line 728, in _draw

self._dispatch_draw(layer, gc, view_bounds, mode)

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/enable/container.py", line 310, in _dispatch_draw

my_handler(gc, view_bounds, mode)

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/enable/container.py", line 349, in _draw_container_underlay

self._draw_underlay(gc, view_bounds, mode)

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/enable/component.py", line 844, in _draw_underlay

underlay.overlay(self, gc, view_bounds, mode)

File "/usr/lib/python2.5/site-packages/Chaco-3.0.0-py2.5-linux-i686.egg/enthought/chaco/axis.py", line 245, in overlay

self._draw_component(gc, view_bounds, mode, component)

File "/usr/lib/python2.5/site-packages/Chaco-3.0.0-py2.5-linux-i686.egg/enthought/chaco/axis.py", line 271, in _draw_component

self._compute_labels(gc)

File "/usr/lib/python2.5/site-packages/Chaco-3.0.0-py2.5-linux-i686.egg/enthought/chaco/axis.py", line 614, in _compute_labels

ctm = gc.get_ctm()

File "/usr/lib/python2.5/site-packages/Enable-3.0.1-py2.5-linux-i686.egg/enthought/kiva/agg/agg.py", line 855, in get_ctm

return (tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5])

TypeError??: 'trans_affine' object is unindexable

Attachments

tut1.py (2.1 KB) - added by danhomerick@… 6 years ago.
'chaco/examples/new_tutorial/tut1.py' with an 'import networkx' statement added

Change History

Changed 6 years ago by danhomerick@…

'chaco/examples/new_tutorial/tut1.py' with an 'import networkx' statement added

comment:1 Changed 6 years ago by aric

  • Status changed from new to assigned

All of the networkx interaction with matplotlib is in the single file https://networkx.lanl.gov/browser/networkx/trunk/networkx/drawing/nx_pylab.py

So you can see what is being loaded there. If you don't want to load matplotlib automatically edit the init.py file in the drawing directory.

It looks like there might be some kind of Agg backend mismatch? Between chaco and matplotlib?

comment:2 Changed 6 years ago by danhomerick@…

I'm able to get the error by just importing matplotlib.pylab in the tutorial file, so networkx isn't involved except for that it's importing pylab.

I'm not sure of what's general policy -- should I close this ticket, or leave it to you to do so?

comment:3 Changed 6 years ago by aric

  • Status changed from assigned to closed
  • Resolution set to invalid
Note: See TracTickets for help on using tickets.