christiangoltz / shaape

Shaape is an ascii art to image converter designed to be used with asciidoc.
Other
106 stars 19 forks source link

TypeError: 'int' object is not iterable #20

Open markus70 opened 6 years ago

markus70 commented 6 years ago

On Ubuntu 18.04 I get the following error with any input file from the example:

$ pip install shaape
Collecting shaape
  Downloading https://files.pythonhosted.org/packages/eb/c1/6f3ec749881f165746202b268826d4758d4cc196db8f10e1a0a40634e4b8/shaape-1.1.1.tar.gz
Collecting PyYAML (from shaape)
  Downloading https://files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz (270kB)
    100% |████████████████████████████████| 276kB 2.4MB/s 
Collecting networkx (from shaape)
  Downloading https://files.pythonhosted.org/packages/f3/f4/7e20ef40b118478191cec0b58c3192f822cace858c19505c7670961b76b2/networkx-2.2.zip (1.7MB)
    100% |████████████████████████████████| 1.7MB 426kB/s 
Collecting decorator>=4.3.0 (from networkx->shaape)
  Downloading https://files.pythonhosted.org/packages/bc/bb/a24838832ba35baf52f32ab1a49b906b5f82fb7c76b2f6a7e35e140bac30/decorator-4.3.0-py2.py3-none-any.whl
Building wheels for collected packages: shaape, PyYAML, networkx
  Running setup.py bdist_wheel for shaape ... done
  Stored in directory: .cache/pip/wheels/18/d6/ce/f9b02770de479b0a1581b097f9ab2e60dba6811a5d93aff08c
  Running setup.py bdist_wheel for PyYAML ... done
  Stored in directory: .cache/pip/wheels/ad/da/0c/74eb680767247273e2cf2723482cb9c924fe70af57c334513f
  Running setup.py bdist_wheel for networkx ... done
  Stored in directory: .cache/pip/wheels/68/f8/29/b53346a112a07d30a5a84d53f19aeadaa1a474897c0423af91
Successfully built shaape PyYAML networkx
Installing collected packages: PyYAML, decorator, networkx, shaape
Successfully installed PyYAML-3.13 decorator-4.3.0 networkx-2.2 shaape-1.1.1
$ cat > test.shaape
+-+  +-+   /\
 \ \/  |  +  +-
  \    |  |
   +---+ -+
$ shaape test.shaape 
Traceback (most recent call last):
  File ".local/bin/shaape", line 6, in <module>
    shaape.run.run()
  File ".local/lib/python2.7/site-packages/shaape/run.py", line 124, in run
    shaape.run()
  File ".local/lib/python2.7/site-packages/shaape/run.py", line 78, in run
    parser.run(raw_data, objects)
  File ".local/lib/python2.7/site-packages/shaape/overlayparser.py", line 137, in run
    minimum_cycles = planar_cycles(component)
  File ".local/lib/python2.7/site-packages/shaape/graphalgorithms.py", line 117, in planar_cycles
    node = next_neighbor(path)
  File ".local/lib/python2.7/site-packages/shaape/graphalgorithms.py", line 84, in next_neighbor
    return graph.edges()[0][0]
  File ".local/lib/python2.7/site-packages/networkx/classes/reportviews.py", line 929, in __getitem__
    u, v = e
TypeError: 'int' object is not iterable
christiangoltz commented 6 years ago

Hey markus, first of all, thanks for using this tool. I wrote this several years ago and I am not actively maintaining it anymore, because I have a lot of stuff on my plate since then. You are welcome to submit a pull request which I would happily merge if it solves your problem.

(The input file looks okay to my eyes, so it probably is a bug)

ggrossetie commented 5 years ago

I can reproduce this issue:

Traceback (most recent call last):
  File "/usr/local/bin/shaape", line 4, in <module>
    __import__('pkg_resources').run_script('shaape==1.1.1', 'shaape')
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 719, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1511, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/shaape-1.1.1-py2.7.egg/EGG-INFO/scripts/shaape", line 6, in <module>

  File "build/bdist.linux-x86_64/egg/shaape/run.py", line 124, in run
  File "build/bdist.linux-x86_64/egg/shaape/run.py", line 78, in run
  File "build/bdist.linux-x86_64/egg/shaape/overlayparser.py", line 137, in run
  File "build/bdist.linux-x86_64/egg/shaape/graphalgorithms.py", line 117, in planar_cycles
  File "build/bdist.linux-x86_64/egg/shaape/graphalgorithms.py", line 84, in next_neighbor
  File "/usr/local/lib/python2.7/dist-packages/networkx/classes/reportviews.py", line 929, in __getitem__
    u, v = e
TypeError: 'int' object is not iterable
python --version
Python 2.7.15rc1

@christiangoltz Python 2.7 is supported right ?

I've added a few print to understand what's going on:

components 
<generator object connected_component_subgraphs at 0x7f4e43ad5640>
component
<class 'networkx.classes.graph.Graph'>

shaape/graphalgorithms.py:84

graph.edges()
[(((5.5, 3.5),miter,True), ((5.5, 3),miter,True)), (((5.5, 3.5),miter,True), ((5, 3.5),miter,True)), (((5.5, 1.5),miter,True), ((5.5, 2),miter,True)), (((5.5, 1.5),miter,True), ((5, 1.5),miter,True)), (((5, 3.5),miter,True), ((5.5, 3.5),miter,False)), (((5, 3.5),miter,True), ((4, 3.5),miter,True)), (((2, 3.5),miter,True), ((3, 3.5),miter,True)), (((2, 3.5),miter,True), ((1.5, 3.5),miter,True)), (((3, 3.5),miter,True), ((2, 3.5),miter,True)), (((3, 3.5),miter,True), ((4, 3.5),miter,True)), (((3, 1.5),miter,True), ((2, 1.5),miter,True)), (((3, 1.5),miter,True), ((4, 1.5),miter,True)), (((5.5, 2),miter,True), ((5.5, 3),miter,True)), (((5.5, 2),miter,True), ((5.5, 1.5),miter,True)), (((2, 1.5),miter,True), ((3, 1.5),miter,True)), (((2, 1.5),miter,True), ((1.5, 1.5),miter,True)), (((1.5, 3.5),miter,True), ((2, 3.5),miter,True)), (((1.5, 3.5),miter,True), ((1.5, 3),miter,True)), (((5, 1.5),miter,True), ((5.5, 1.5),miter,True)), (((5, 1.5),miter,True), ((4, 1.5),miter,True)), (((1.5, 1.5),miter,True), ((2, 1.5),miter,True)), (((1.5, 1.5),miter,True), ((1.5, 2),miter,True)), (((1.5, 3),miter,True), ((1.5, 3.5),miter,True)), (((1.5, 3),miter,True), ((1.5, 2),miter,True)), (((4, 1.5),miter,True), ((3, 1.5),miter,True)), (((4, 1.5),miter,True), ((5, 1.5),miter,True)), (((5.5, 3),miter,True), ((5.5, 3.5),miter,True)), (((5.5, 3),miter,True), ((5.5, 2),miter,True)), (((1.5, 2),miter,True), ((1.5, 3),miter,True)), (((1.5, 2),miter,True), ((1.5, 1.5),miter,True)), (((4, 3.5),miter,True), ((3, 3.5),miter,True)), (((4, 3.5),miter,True), ((5, 3.5),miter,True))]
<class 'networkx.classes.reportviews.OutEdgeView'>

networkx/classes/reportviews.py:929

e
0
<type 'int'>

I can try to fix this issue but I need some guidance as I'm not really familiar with the code. Do you know what the variable e should look like ?

Maybe something has changed in networkx ?

Thanks :wink: