-
Notifications
You must be signed in to change notification settings - Fork 593
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
Standardize Imports I, #176 #206
Conversation
Some imports are not anymore used because the models or other data files are not anymore downloaded with this script. Some uncommented parts are now deleted.
The import statements for the main commands ocropus-* are standardized: * Put different import statements into different lines * Group them into (1) standard imports, (2) third party imports, (3) local modules * Avoid the "from pylab import *" * Use rather "import numpy as np", "import matplotlib.pyplot as plt" Moreover, some unused import statements were deleted and a very few nits for readibility are done. This work is heavily based on the work by @QuLogic in the branch https://github.com/QuLogic/ocropy/commits/standard-import All commands from the current pipeline are tested to still work in the usual calls (especially run-test and run-rtrain).
I tried to automatically check the addition of a namespace to the relevant functions (i.e. these are the ones I found so far in the ocropus code) with these lines:
|
Looks good. Any updates on this? We can also use importmagic to automatically fix imports. |
ocropus-dewarp
Outdated
lnorm.measure(amax(line)-line) | ||
line = lnorm.normalize(line,cval=amax(line)) | ||
lnorm.measure(np.amax(line)-line) | ||
line = lnorm.normalize(line,cval=np.amax(line)) | ||
scipy.misc.imsave(base+".dew.png",line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need scipy
here, cf. Travis output.
ocropus-linegen
Outdated
c = array([w/2.0,h/2]) | ||
d = c-dot(m,c)+array([randn()*delta,randn()*delta]) | ||
c = np.array([w/2.0,h/2]) | ||
d = c-dot(m,c)+np.array([np.random.randn()*delta,np.random.randn()*delta]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NameError: global name 'dot' is not defined
-> Thus, I guess this should be np.dot(...)
@ChillarAnand Any checking with |
importmagic doesnt work out of the box. I have written a wrapper script and it works only on Python 3. Any timeline for this PR? |
Okay, I understand. Actually, we still concentrate on Python 2 and the PR you mentioned is for a separate Python 3 branch. In general it might be hard work to have the whole OCRopus work for Python 2 and Python 3. |
# Conflicts: # ocropus-nlbin
Wow, that was fast :-) I hope that no error was created in the last round of solving merge conflict, because I didn't test it myself much, but simply relied on Travis and the extended tests we have now... |
But seriously, if we'll see regressions from this, it will be fairly obvious, missing imports or undeclared vars. |
The import statements for the main commands ocropus-* are
standardized:
imports, (3) local modules
Moreover, some unused import statements were deleted and a very
few nits for readibility are done.
This work is heavily based on the work by @QuLogic in the branch
https://github.com/QuLogic/ocropy/commits/standard-import
See also #176 .
All commands from the current pipeline are tested to still work
in the usual calls (especially run-test and run-rtrain). Even more, the
outputs before and afterwards is exactly the same.