Skip to content

Achieve python 3.x compatibility + resolve TypeError of 'safe' casting from np.int64 types#6

Open
dansuh17 wants to merge 1 commit intombortnyck:masterfrom
dansuh17:master
Open

Achieve python 3.x compatibility + resolve TypeError of 'safe' casting from np.int64 types#6
dansuh17 wants to merge 1 commit intombortnyck:masterfrom
dansuh17:master

Conversation

@dansuh17
Copy link
Copy Markdown

@dansuh17 dansuh17 commented Jan 15, 2018

Mainly detecting ImportError and assigning replaceable function existing in python 3.x libraries.

try:
    from itertools import izip
except ImportError:  # python 3.x
    izip = zip
    xrange = range

Done in response to #3 .


Also fixes TypeError of message:

Traceback (most recent call last):
  File "test.py", line 12, in <module>
    db.query(fp_q)
  File "/Users/user/qfp/qfp/db.py", line 151, in query
    fp.match_candidates = self._find_match_candidates(fp)
  File "/Users/user/qfp/qfp/db.py", line 172, in _find_match_candidates
    self._filter_candidates(conn, c, qQuad, filtered)
  File "/Users/user/qfp/qfp/db.py", line 206, in _filter_candidates
    if not 1 / (1 + e) <= qQuad.A.y / cQuad.A.y <= 1 / (1 - e):
TypeError: ufunc 'true_divide' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Which happens if data are INSERTed while having type np.int64 or other numerical numpy types.
In order to store the actual numerical value, call .item() to the np-typed variables reference.

@dansuh17 dansuh17 changed the title Achieve python 3.x compatibility. Achieve python 3.x compatibility + resolve TypeError of 'safe' casting from np.int64 types Jan 18, 2018
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.

1 participant