私は配列のリストを持っているので私のコードは動作していないと思う。配列のfinal_list
のリストをマトリックスとして構造化することができ、numba
で受け入れられるようにするには、別の方法がありますか?numbaのリストに配列を追加するのと同等の処理を行うにはどうすればよいですか?
import numpy as np
import matplotlib.pyplot as plt
import numba as nb
N_SPLITS = 1000
@nb.jit(nopython=True)
def logi(x0, r):
x = x0
for n in range(30000):
x = x * r * (1-x)
final_list = [x]
for n in range(N_SPLITS):
final_list.append(final_list[-1] * r * (1 - final_list[-1]))
return np.sort(final_list, axis=0)
r = np.arange(2.4, 4., .001)
for i in range(N_SPLITS):
plt.plot(r, logi(0.5, r)[i], c='k', lw=0.1)
plt.savefig('bifig.pdf')
File "logi.py", line 18, in <module>
plt.plot(r, logi(0.5, r)[i], c='k', lw=0.1)
File "/usr/local/lib/python2.7/site-packages/numba/dispatcher.py", line 330, in _compile_for_args
raise e
numba.errors.TypingError: Caused By:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/numba/compiler.py", line 235, in run
stage()
File "/usr/local/lib/python2.7/site-packages/numba/compiler.py", line 449, in stage_nopython_frontend
self.locals)
File "/usr/local/lib/python2.7/site-packages/numba/compiler.py", line 805, in type_inference_stage
infer.propagate()
File "/usr/local/lib/python2.7/site-packages/numba/typeinfer.py", line 767, in propagate
raise errors[0]
TypingError: Invalid usage of BoundFunction(list.append for list(float64)) with parameters (array(float64, 1d, C))
* parameterized
File "logi.py", line 13
[1] During: resolving callee type: BoundFunction(list.append for list(float64))
[2] During: typing of call at logi.py (13)
Failed at nopython (nopython frontend)
Invalid usage of BoundFunction(list.append for list(float64)) with parameters (array(float64, 1d, C))
* parameterized
File "logi.py", line 13
[1] During: resolving callee type: BoundFunction(list.append for list(float64))
[2] During: typing of call at logi.py (13)