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

Cleanup imports in common.py, lstm.py, extract exceptions #154

Merged
merged 11 commits into from
Jan 23, 2017
Merged

Conversation

kba
Copy link
Collaborator

@kba kba commented Nov 15, 2016

  • Move exceptions to its own module
  • Make all imports explicit, so static code analysis tools like pyflakes can help
  • remove redundant deprecated decorators
  • Remove old load_components
  • Remove old draw_pseg/draw_aligned

kba added 5 commits November 15, 2016 02:56
They haven't been in use for a while and not working currently
Neither is used and there is another implementation in toplevel.py
Obsolete now and won't work with current codebase
import cPickle
from ocrolib.exceptions import (BadClassLabel, BadInput, FileNotFound,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should move down to third block (first-party imports).

import pylab
from pylab import imshow
from scipy.ndimage import morphology,measurements
from pylab import (clf, cm, ginput, gray, imshow, ion, subplot, where)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got a branch that removes pylab imports; should I open a PR for that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean https://github.com/QuLogic/ocropy/commits/standard-import? Sure, open a PR with the pertinent commits, looks really helpful, I'll happily merge/cherry-pick.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the one; though I just noticed that it's based on the Python 3 work, so it'll be a pain to cherry-pick. Should get that in ASAP and then the rest would be easier.


import numpy
from numpy import *
from numpy import (amax, amin, array, bitwise_and, clip, dtype, mean, minimum,
nan, ndarray, sin, sqrt, zeros)
Copy link
Contributor

@QuLogic QuLogic Nov 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch also standardizes these imports too...
(See below comment.)

import PIL

from default import getlocal
from toplevel import *
from toplevel import (checks, ABINARY2, AINT2, AINT3, BOOL, DARKSEG, GRAYSCALE,
LIGHTSEG, LINESEG, PAGESEG)
import chars
import codecs
import ligatures
import lstm
import morph
import multiprocessing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should move up to first block (standard library imports).

@zuphilip
Copy link
Collaborator

I see that the exceptions are deleted in ocrolib/common.py but I don't see another module with them. Is that (new) file missing here?

@kba kba changed the title Cleanup common.py Cleanup common.py, lstm.py, extract exceptions Nov 15, 2016
@kba kba changed the title Cleanup common.py, lstm.py, extract exceptions Cleanup imports in common.py, lstm.py, extract exceptions Nov 15, 2016
@zuphilip zuphilip mentioned this pull request Jan 23, 2017
@kba kba merged commit ad8b9af into master Jan 23, 2017
@zuphilip zuphilip mentioned this pull request Feb 1, 2017
@zuphilip zuphilip deleted the cleanup-common branch May 8, 2017 05:26
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

Successfully merging this pull request may close these issues.

3 participants