Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 syntax error #447

Closed
cclauss opened this issue Sep 21, 2018 · 4 comments
Closed

1 syntax error #447

cclauss opened this issue Sep 21, 2018 · 4 comments
Assignees

Comments

@cclauss
Copy link
Contributor

cclauss commented Sep 21, 2018

flake8 testing of https://github.com/apachecn/AiLearning on Python 3.7.0

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./src/py3.x/dl/perceptron.py:192:22: F821 undefined name 'train_and_perceptron'
    and_perceptron = train_and_perceptron()
                     ^
./src/py3.x/16.RecommenderSystems/test_基于用户.py:74:28: F821 undefined name 'u'
    for v, wuv in sorted(W[u].items, key=itemgetter(1), reverse=True)[0:K]:
                           ^
./src/py3.x/16.RecommenderSystems/test_基于用户.py:74:73: F821 undefined name 'K'
    for v, wuv in sorted(W[u].items, key=itemgetter(1), reverse=True)[0:K]:
                                                                        ^
./src/py3.x/16.RecommenderSystems/test_lfm.py:12:16: F821 undefined name 'items_pool'
        item = items_pool[random.randint(0, len(items_pool) - 1)]
               ^
./src/py3.x/16.RecommenderSystems/test_lfm.py:12:49: F821 undefined name 'items_pool'
        item = items_pool[random.randint(0, len(items_pool) - 1)]
                                                ^
./src/py3.x/16.RecommenderSystems/test_lfm.py:23:14: F821 undefined name 'InitModel'
    [P, Q] = InitModel(user_items, F)
             ^
./src/py3.x/16.RecommenderSystems/test_lfm.py:26:23: F821 undefined name 'RandSelectNegativeSamples'
            samples = RandSelectNegativeSamples(items)
                      ^
./src/py3.x/16.RecommenderSystems/test_lfm.py:28:29: F821 undefined name 'Predict'
                eui = rui - Predict(user, item)
                            ^
./src/py3.x/16.RecommenderSystems/test_基于物品.py:10:18: F821 undefined name 'users'
        for i in users:
                 ^
./src/py3.x/16.RecommenderSystems/test_基于物品.py:12:22: F821 undefined name 'users'
            for j in users:
                     ^
./src/py3.x/16.RecommenderSystems/test_基于物品.py:21:18: F821 undefined name 'v'
            W[u][v] = cij / math.sqrt(N[i] * N[j])
                 ^
./src/py3.x/16.RecommenderSystems/test_基于物品.py:30:18: F821 undefined name 'users'
        for i in users:
                 ^
./src/py3.x/16.RecommenderSystems/test_基于物品.py:32:22: F821 undefined name 'users'
            for j in users:
                     ^
./src/py3.x/16.RecommenderSystems/test_基于物品.py:41:18: F821 undefined name 'v'
            W[u][v] = cij / math.sqrt(N[i] * N[j])
                 ^
./src/py3.x/16.RecommenderSystems/test_evaluation_model.py:22:16: F821 undefined name 'GetRecommendation'
        rank = GetRecommendation(user, N)
               ^
./src/py3.x/16.RecommenderSystems/test_evaluation_model.py:36:16: F821 undefined name 'GetRecommendation'
        rank = GetRecommendation(user, N)
               ^
./src/py3.x/16.RecommenderSystems/test_evaluation_model.py:51:16: F821 undefined name 'GetRecommendation'
        rank = GetRecommendation(user, N)
               ^
./src/py3.x/16.RecommenderSystems/test_evaluation_model.py:68:16: F821 undefined name 'GetRecommendation'
        rank = GetRecommendation(user, N)
               ^
./src/py3.x/nlp/6.LDA/demo.py:13:14: F821 undefined name 'corpora'
dictionary = corpora.Dictionary(train)
             ^
./src/py2.x/dl/perceptron.py:62:68: E999 SyntaxError: invalid syntax
        return self.activator(reduce(lambda a, b: a + b,map(lambda (x, w): x * w, zip(input_vec, self.weights)), 0.0) + self.bias)
                                                                   ^
1     E999 SyntaxError: invalid syntax
19    F821 undefined name 'GetRecommendation'
20
@jiangzhonglian
Copy link
Member

老哥,有心了,谢谢帮忙规范代码

@cclauss cclauss changed the title 33 syntax errors 2 syntax errors Sep 30, 2018
@cclauss cclauss changed the title 2 syntax errors 1 syntax error Sep 30, 2018
@cclauss
Copy link
Contributor Author

cclauss commented Sep 30, 2018

OK... This last one is a bit tougher...
https://github.com/apachecn/AiLearning/blob/dev/src/py2.x/dl/perceptron.py#L62

Python 2:

  • lambda x, w: x # OK
  • lambda (x, w): x # OK

Python 3:

  • lambda x, w: x # OK
  • lambda (x, w): x # Syntax Error!

@jiangzhonglian
Copy link
Member

@chenyyx 瑶妹,看看这个问题

@chenyyx
Copy link
Contributor

chenyyx commented Oct 8, 2018

@jiangzhonglian ok,我看一下哈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants