Skip to content

Commit

Permalink
Disallow running neuclease if numexpr is installed.
Browse files Browse the repository at this point in the history
See #3
  • Loading branch information
stuarteberg committed Apr 12, 2019
1 parent b8930a0 commit c0a2318
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions neuclease/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,33 @@ def configure_default_logging():
root_logger.handlers = []
root_logger.addHandler(handler)
root_logger.setLevel(logging.INFO)

try:
import numexpr
except ImportError:
pass
else:
import textwrap
msg = textwrap.dedent("""\
Cannot use this library in an environment in which numexpr is installed.
Please do not use this library in an environment in which numexpr is installed.
This library relies on pandas eval() and pandas query() to compare uint64 types,
which is not supported by the numexpr library.
If numexpr is present, pandas will use it by default in eval() and query(),
rather than using query(..., parser='python').
Using numexpr leads to errors like this one:
>>> df = pd.DataFrame([[1,2]], columns=list('ab'), dtype=np.uint64)
>>> df.query('a == b')
TypeError: Iterator operand 1 dtype could not be cast from dtype('uint64') to dtype('int64') according to the rule 'safe'
In the future, this library will be patched to avoid using uint64 types altogether,
and this error will be removed.
See: https://github.com/janelia-flyem/neuclease/issues/3
""")
raise AssertionError(msg)

0 comments on commit c0a2318

Please sign in to comment.