GPU-Puzzles icon indicating copy to clipboard operation
GPU-Puzzles copied to clipboard

NameError: name 'unit_y' is not defined

Open renhaofan opened this issue 3 years ago • 11 comments

After run: problem.show() in my local environment

NameError                                 Traceback (most recent call last)
/tmp/ipykernel_1818177/1878365812.py in <module>
      5     "Map", map_test, [a], out, threadsperblock=Coord(SIZE, 1), spec=map_spec
      6 )
----> 7 problem.show()

~/code/mycode/GPU-Puzzles/lib.py in show(self, sparse)
    389         self.score(results)
    390         return draw_results(results, self.name,
--> 391                             self.threadsperblock.x, self.threadsperblock.y, sparse)
    392 
    393     def check(self):

~/code/mycode/GPU-Puzzles/lib.py in draw_results(results, name, tpbx, tpby, sparse)
    256     blocks = []
    257     locations = []
--> 258     base = draw_base(*results[Coord(0, 0)][Coord(0, 0)])
    259     for block, inner in results.items():
    260         dia = base

~/code/mycode/GPU-Puzzles/lib.py in draw_base(_, a, c, out)
    227 
    228 def draw_base(_, a, c, out):
--> 229     inputs = vcat([draw_table(d) for d in a], 2.0).center_xy()
    230     shared_tables = [[draw_table(c2.refs[i]) for i in range(1, c.rounds())] for c2 in c.caches]
    231     shareds = grid(shared_tables, 1.0).center_xy()

~/code/mycode/GPU-Puzzles/lib.py in <listcomp>(.0)
    227 
    228 def draw_base(_, a, c, out):
--> 229     inputs = vcat([draw_table(d) for d in a], 2.0).center_xy()
    230     shared_tables = [[draw_table(c2.refs[i]) for i in range(1, c.rounds())] for c2 in c.caches]
    231     shareds = grid(shared_tables, 1.0).center_xy()

~/code/mycode/GPU-Puzzles/lib.py in draw_table(tab)
    211         tab = table(tab.name, *tab.size)
    212     tab = tab.line_width(0.05)
--> 213     return tab.beside((t + vstrut(0.5)), -unit_y)
    214 
    215 

NameError: name 'unit_y' is not defined

And problem.check() no error, it's nice.

renhaofan avatar Jul 15 '22 07:07 renhaofan

I think you installed an old version of chalk. Can you make sure you install the one from my branch (command is in the notebook).

srush avatar Jul 15 '22 13:07 srush

I think you installed an old version of chalk. Can you make sure you install the one from my branch (command is in the notebook).

Actually after run command pip install -qqq git+https://github.com/danoneata/chalk@srush-patch-1, nothing happened. So I open the repo danoneata/chalk, then follow the guidence, run the command conda install -c conda-forge chalk-diagrams

My chalk version:

$ conda list | grep chalk
chalk-diagrams            0.1.2              pyhd8ed1ab_0    conda-forge

renhaofan avatar Jul 17 '22 01:07 renhaofan

I try to run command pip install git+https://github.com/danoneata/chalk@srush-patch-1, But an error occurred:

 × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [13 lines of output]
      Traceback (most recent call last):
        File "/tmp/pip-install-ofq9w8yg/planar_3384c07b07cb49e694e3d9f59655d633/setup.py", line 11, in <module>
          from distutils.command.build_py import build_py_2to3 as build_py
      ImportError: cannot import name 'build_py_2to3' from 'distutils.command.build_py' (/home/steve/.conda/envs/py37/lib/python3.7/site-packages/setuptools/_distutils/command/build_py.py)
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "<string>", line 36, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-ofq9w8yg/planar_3384c07b07cb49e694e3d9f59655d633/setup.py", line 14, in <module>
          raise ImportError("build_py_2to3 not found in distutils - it is required for Python 3.x")
      ImportError: build_py_2to3 not found in distutils - it is required for Python 3.x
      [end of output]

And my python version is totally the same with Colab.

>>> sys.version
'3.7.13 (default, Mar 29 2022, 02:18:16) \n[GCC 7.5.0]'

renhaofan avatar Jul 17 '22 01:07 renhaofan

Ah thanks. This is a bug with one of the chalk dependencies. I will fix it there.

Sorry about that.

srush avatar Jul 17 '22 15:07 srush

Okay, this issue should be fixed now. Could you try it again?

srush avatar Jul 17 '22 16:07 srush

Thanks in advance.

I create a new py37 virtual environment. Then tried again, but not work due to the same error mentioned above.

renhaofan avatar Jul 18 '22 02:07 renhaofan

I also get the same error. unit_y is not defined. Where would this come from?

GdMacmillan avatar Jul 20 '22 18:07 GdMacmillan

@GdMacmillan can you confirm that you installed Chalk from GitHub, as in the first notebook cell?

srush avatar Jul 20 '22 19:07 srush

I met this problem before, but solved by:

  1. creating a conda env with Python version 3.9 (I suppose <=3.10 are acceptable because build_py_2to3 was removed from distutils for higher versions)
  2. install setuptools<=57.5.0 for the same reason above
  3. pip install git+https://github.com/danoneata/chalk@srush-patch-1

btw, I did above with requirements.txt which would make setting up environment easier

ch1y0q avatar Jan 16 '23 12:01 ch1y0q

I'm running into this too fwiw. Using the git patch didn't resolve it outof the box - haven't tried limiting the python version per @ch1y0q yet. Would be good if we could get this working with the latest official version of chalk.

austinvhuang avatar Mar 13 '23 03:03 austinvhuang

Oh, I'll fix this up and make sure they are compatible.

srush avatar Mar 13 '23 14:03 srush