ocropus-archive / DUP-ocropy

Python-based tools for document analysis and OCR
Apache License 2.0
3.42k stars 591 forks source link

Fix regression in ocropus-gpageseg #251 #252

Closed jze closed 7 years ago

jze commented 7 years ago

I looks as if pylab.find and np.where work slightly different.

amitdo commented 7 years ago

https://github.com/tmbdev/ocropy/commit/a154e6360cd8#diff-0e349d933e2d87621d932d2ae80cf70aL272

QuLogic commented 7 years ago

Please do not start using the pylab interface again.

kba commented 7 years ago

Thanks for reporting and sorry for the regression.

IIUC, pylab.find does this:

def find(condition):
    "Return the indices where ravel(condition) is true"
    res, = np.nonzero(np.ravel(condition))
    return res

Does s,np.find/np.nonzero(np.ravel, fix the issue?

jze commented 7 years ago

Yes, it also works without pylab.

kba commented 7 years ago

LGTM, thank you.

@zuphilip In https://github.com/tmbdev/ocropy/commit/a154e6360cd8e15c8c7cd5c2ce225c0ebed9d424 this was the only place where pylab.find was replaced by np.where, right?

@jze If you provide the source images and CLI invocation, we could add a test to prevent this kind of error in the future

stweil commented 7 years ago

In a154e63 this was the only place where pylab.find was replaced by np.where, right?

Yes.

zuphilip commented 7 years ago

Merged. Thank you very much @jze for the work and everybody here for the discussion!