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

Error importing with 32-bit windows 7 #9

Closed
LMBooth opened this issue Sep 13, 2021 · 2 comments
Closed

Error importing with 32-bit windows 7 #9

LMBooth opened this issue Sep 13, 2021 · 2 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@LMBooth
Copy link

LMBooth commented Sep 13, 2021

Hi there,

I've been playing with antropy on my main home machine and have come to use the same code on a 32-bit windows 7 machine which has inccured an import error.

Currently using Python 3.8.10 32-bit. Can this be fixed or is it likely i'm in need of going to a 64-bit version?

The traceback is as follow:

Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:34:34) [MSC v.1928 32 bit (
Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import antropy
Traceback (most recent call last):
  File "C:\Python38\lib\site-packages\numba\core\errors.py", line 776, in new_er
ror_context
    yield
  File "C:\Python38\lib\site-packages\numba\core\lowering.py", line 235, in lowe
r_block
    self.lower_inst(inst)
  File "C:\Python38\lib\site-packages\numba\core\lowering.py", line 380, in lowe
r_inst
    val = self.lower_assign(ty, inst)
  File "C:\Python38\lib\site-packages\numba\core\lowering.py", line 556, in lowe
r_assign
    return self.lower_expr(ty, value)
  File "C:\Python38\lib\site-packages\numba\core\lowering.py", line 1084, in low
er_expr
    res = self.lower_call(resty, expr)
  File "C:\Python38\lib\site-packages\numba\core\lowering.py", line 815, in lowe
r_call
    res = self._lower_call_normal(fnty, expr, signature)
  File "C:\Python38\lib\site-packages\numba\core\lowering.py", line 1055, in _lo
wer_call_normal
    res = impl(self.builder, argvals, self.loc)
  File "C:\Python38\lib\site-packages\numba\core\base.py", line 1194, in __call_
_
    res = self._imp(self._context, builder, self._sig, args, loc=loc)
  File "C:\Python38\lib\site-packages\numba\core\base.py", line 1224, in wrapper

    return fn(*args, **kwargs)
  File "C:\Python38\lib\site-packages\numba\np\unsafe\ndarray.py", line 31, in c
odegen
    res = _empty_nd_impl(context, builder, arrty, shapes)
  File "C:\Python38\lib\site-packages\numba\np\arrayobj.py", line 3468, in _empt
y_nd_impl
    arrlen_mult = builder.smul_with_overflow(arrlen, s)
  File "C:\Python38\lib\site-packages\llvmlite\ir\builder.py", line 50, in wrapp
ed
    raise ValueError("Operands must be the same type, got (%s, %s)"
ValueError: Operands must be the same type, got (i32, i64)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python38\lib\site-packages\antropy\__init__.py", line 4, in <module>
    from .fractal import *
  File "C:\Python38\lib\site-packages\antropy\fractal.py", line 304, in <module>

    def _dfa(x):
  File "C:\Python38\lib\site-packages\numba\core\decorators.py", line 226, in wr
apper
    disp.compile(sig)
  File "C:\Python38\lib\site-packages\numba\core\dispatcher.py", line 979, in co
mpile
    cres = self._compiler.compile(args, return_type)
  File "C:\Python38\lib\site-packages\numba\core\dispatcher.py", line 141, in co
mpile
    status, retval = self._compile_cached(args, return_type)
  File "C:\Python38\lib\site-packages\numba\core\dispatcher.py", line 155, in _c
ompile_cached
    retval = self._compile_core(args, return_type)
  File "C:\Python38\lib\site-packages\numba\core\dispatcher.py", line 168, in _c
ompile_core
    cres = compiler.compile_extra(self.targetdescr.typing_context,
  File "C:\Python38\lib\site-packages\numba\core\compiler.py", line 686, in comp
ile_extra
    return pipeline.compile_extra(func)
  File "C:\Python38\lib\site-packages\numba\core\compiler.py", line 428, in comp
ile_extra
    return self._compile_bytecode()
  File "C:\Python38\lib\site-packages\numba\core\compiler.py", line 492, in _com
pile_bytecode
    return self._compile_core()
  File "C:\Python38\lib\site-packages\numba\core\compiler.py", line 471, in _com
pile_core
    raise e
  File "C:\Python38\lib\site-packages\numba\core\compiler.py", line 462, in _com
pile_core
    pm.run(self.state)
  File "C:\Python38\lib\site-packages\numba\core\compiler_machinery.py", line 34
3, in run
    raise patched_exception
  File "C:\Python38\lib\site-packages\numba\core\compiler_machinery.py", line 33
4, in run
    self._runPass(idx, pass_inst, state)
  File "C:\Python38\lib\site-packages\numba\core\compiler_lock.py", line 35, in
_acquire_compile_lock
    return func(*args, **kwargs)
  File "C:\Python38\lib\site-packages\numba\core\compiler_machinery.py", line 28
9, in _runPass
    mutated |= check(pss.run_pass, internal_state)
  File "C:\Python38\lib\site-packages\numba\core\compiler_machinery.py", line 26
2, in check
    mangled = func(compiler_state)
  File "C:\Python38\lib\site-packages\numba\core\typed_passes.py", line 396, in
run_pass
    lower.lower()
  File "C:\Python38\lib\site-packages\numba\core\lowering.py", line 138, in lowe
r
    self.lower_normal_function(self.fndesc)
  File "C:\Python38\lib\site-packages\numba\core\lowering.py", line 192, in lowe
r_normal_function
    entry_block_tail = self.lower_function_body()
  File "C:\Python38\lib\site-packages\numba\core\lowering.py", line 221, in lowe
r_function_body
    self.lower_block(block)
  File "C:\Python38\lib\site-packages\numba\core\lowering.py", line 235, in lowe
r_block
    self.lower_inst(inst)
  File "C:\Python38\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Python38\lib\site-packages\numba\core\errors.py", line 786, in new_er
ror_context
    raise newerr.with_traceback(tb)
numba.core.errors.LoweringError: Failed in nopython mode pipeline (step: native
lowering)
Operands must be the same type, got (i32, i64)

File "lib\site-packages\antropy\fractal.py", line 313:
def _dfa(x):
    <source elided>

    for i_n, n in enumerate(nvals):
    ^

During: lowering "array.70 = call empty_func.71(size_tuple.69, func=empty_func.7
1, args=(Var(size_tuple.69, fractal.py:313),), kws=[], vararg=None, target=None)
" at C:\Python38\lib\site-packages\antropy\fractal.py (313)
>>>
@LMBooth LMBooth changed the title Error on import for 32-bit windows 7 Error importing with 32-bit windows 7 Sep 13, 2021
@raphaelvallat raphaelvallat self-assigned this Sep 15, 2021
@raphaelvallat raphaelvallat added the invalid This doesn't seem right label Sep 15, 2021
@raphaelvallat
Copy link
Owner

Hi @LMBooth,

Thanks for opening the issue. I believe the source of the error is in the Numba source code and not AntroPy (see also similar issue here). Indeed, I do not define the integer type anywhere in the _dfa function:

antropy/antropy/fractal.py

Lines 303 to 336 in 96c28d2

@jit('f8(f8[:])', nopython=True)
def _dfa(x):
"""
Utility function for detrended fluctuation analysis
"""
N = len(x)
nvals = _log_n(4, 0.1 * N, 1.2)
walk = np.cumsum(x - x.mean())
fluctuations = np.zeros(len(nvals))
for i_n, n in enumerate(nvals):
d = np.reshape(walk[:N - (N % n)], (N // n, n))
ran_n = np.array([float(na) for na in range(n)])
d_len = len(d)
trend = np.empty((d_len, ran_n.size))
for i in range(d_len):
slope, intercept = _linear_regression(ran_n, d[i])
trend[i, :] = intercept + slope * ran_n
# Calculate root mean squares of walks in d around trend
# Note that np.mean on specific axis is not supported by Numba
flucs = np.sum((d - trend) ** 2, axis=1) / n
# https://github.com/neuropsychology/NeuroKit/issues/206
fluctuations[i_n] = np.sqrt(np.mean(flucs))
# Filter zero
nonzero = np.nonzero(fluctuations)[0]
fluctuations = fluctuations[nonzero]
nvals = nvals[nonzero]
if len(fluctuations) == 0:
# all fluctuations are zero => we cannot fit a line
dfa = np.nan
else:
dfa, _ = _linear_regression(np.log(nvals), np.log(fluctuations))
return dfa

Therefore, I'm not sure if there's anything we can do in the AntroPy source code to fix this 😬

Thanks,
Raphael

@LMBooth
Copy link
Author

LMBooth commented Sep 15, 2021

Thankyou for your hasty reply! I thought this may have been the case, Luckily it was whilst i was on a temporary machine so will not be a persistant issue for me.

I'll close the issue, thanks again!

@LMBooth LMBooth closed this as completed Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants