waylonflinn / weblas

GPU Powered BLAS for Browsers :gem:
MIT License
702 stars 43 forks source link

error in $npm run data #44

Closed railsagainstignorance closed 6 years ago

railsagainstignorance commented 6 years ago

HI, I tried stepping through the Testing instructions, and bumped into this:

$ npm run data

> weblas@0.9.1 data C:\Users\cgath\dev\railsagainstignorance\weblas
> node test/data/generate.js

Traceback (most recent call last):
  File "generate.py", line 84, in <module>
    for i in range(len(names)):
TypeError: object of type 'map' has no len()
railsagainstignorance commented 6 years ago

So this is a Python 2 vs 3 thing. map() in python 3 returns a generator, instead of a list as in Python 2. You can wrap the map calls in list() (or don't use map) in order to end up with a list as originally intended. In generate.py

        names = list(map(lambda i: default_names[i], range(len(options['in']))))

        all_exist = False
        for name in names:
            all_exist = all_exist & os.path.exists(directory + name)

        if all_exist:
            matrices = list(map(lambda name : binary_matrix.read(directory + name), names))
        else:
waylonflinn commented 6 years ago

Thanks for reporting this. I'll push a fix tomorrow!

waylonflinn commented 6 years ago

Fixed in aeb9dc8