rbf = scipy.interpolate.Rbf(x, y, z, function="linear")
として補間をする際に
ValueError: object arrays are not supported
となることがあります。
しかし普通に計算を行う時、この関数に代入する値はarrayのはずですし、実際に簡単な計算では問題がありません。
どのような時にこのエラーが生じるのでしょうか。
以下エラー画面です
python
1 2 3 4--------------------------------------------------------------------------- 5ValueError Traceback (most recent call last) 6<ipython-input-17-31a9ccce0e38> in <module>() 7 29 zlabel = 'diff' 8 30 9---> 31 twodim_colorPlot(df_up, xlabel, ylabel, zlabel) 10 11<ipython-input-17-31a9ccce0e38> in twodim_colorPlot(dataframe, xlabel, ylabel, zlabel) 12 13 xi, yi = np.meshgrid(xi, yi) 13 14 # Interpolate 14---> 15 rbf = scipy.interpolate.Rbf(x, y, z, function="linear") 15 16 zi = rbf(xi, yi) 16 17 plt.imshow(zi, vmin=-3.0, vmax=z.max(), origin='lower', 17 18/opt/conda/lib/python3.5/site-packages/scipy/interpolate/rbf.py in __init__(self, *args, **kwargs) 19 220 20 221 self.A = self._init_function(r) - np.eye(self.N)*self.smooth 21--> 222 self.nodes = linalg.solve(self.A, self.di) 22 223 23 224 def _call_norm(self, x1, x2): 24 25/opt/conda/lib/python3.5/site-packages/scipy/linalg/basic.py in solve(a, b, sym_pos, lower, overwrite_a, overwrite_b, debug, check_finite) 26 78 """ 27 79 a1 = _asarray_validated(a, check_finite=check_finite) 28---> 80 b1 = _asarray_validated(b, check_finite=check_finite) 29 81 if len(a1.shape) != 2 or a1.shape[0] != a1.shape[1]: 30 82 raise ValueError('expected square matrix') 31 32/opt/conda/lib/python3.5/site-packages/scipy/_lib/_util.py in _asarray_validated(a, check_finite, sparse_ok, objects_ok, mask_ok, as_inexact) 33 188 if not objects_ok: 34 189 if a.dtype is np.dtype('O'): 35--> 190 raise ValueError('object arrays are not supported') 36 191 if as_inexact: 37 192 if not np.issubdtype(a.dtype, np.inexact): 38 39ValueError: object arrays are not supported 40
汚くて申し訳ないのですが、以下x,y,zの配列の中身です。
配列数は最初の3行にあるように全て239です。
python
1(51,) 2(51,) 3(51,) 4x [0.018945105316441533 0.038376366719427735 0.05750917295661107 5 0.07629006442075704 0.09372811488304386 0.10912612525702123 6 0.12464768410205995 0.1413839103561751 0.1596741410585453 7 0.1759184069399719 0.19322446824327125 0.210691567977937 8 0.22845655409586113 0.24650226430391914 0.2650497977458401 9 0.28341059279725256 0.30264726163880595 0.3222909503597119 10 0.3415180146407486 0.36120344192936826 0.38097870683137053 11 0.4009628258714799 0.42071656620799663 0.4406341693717701 12 0.46057715168858765 7.0988221152911e-05 0.016278620751618286 13 0.03259693073674304 0.04967192015954666 0.06507510572727315 14 0.08193216437272284 0.09923561811615711 0.1166556734303942 15 0.13416924413319617 0.15192331989390162 0.1698669427742076 16 0.18819732013519314 0.20692007261808368 0.22520352719918568 17 0.24386166995327074 0.2629546458428124 0.28222526836647466 18 0.3019660404290296 0.32129576570338003 0.34105888899009573 19 0.36088646826753823 0.3807677427842703 0.40067699957871794 20 0.42061491923715927 0.4407819226122955 0.4605310364633991] 21y [0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 22 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 23 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7] 24z [10.855443501464377 17.32098343302835 26.042603408852838 41.038506548558644 25 70.16328746849081 122.47967297128532 173.39153348258986 210.49479953909872 26 232.2054583878787 271.49097031518374 303.25305276344363 332.0475954482092 27 357.4557031061652 379.67248029342215 399.59488853067387 413.6824308929333 28 423.4969609923641 430.95804558342076 436.33447825754433 439.91060697025836 29 442.46544280829954 443.7828019209314 445.44551252223863 446.3822170779967 30 447.03040608671915 3.7402750670694074 41.168600585025885 83.02282664213085 31 117.41178280399303 167.3956935721441 204.26213262455897 234.91703733944348 32 264.2463908853601 292.5126418351867 318.0447807275893 340.28528709553103 33 360.4027292674224 373.7859265238961 393.2999756995644 408.5544909574963 34 420.0025527426506 428.29426922401115 434.65168997825856 438.86105089891004 35 441.55391517195045 443.51403019241434 444.8637264447764 445.89531428160996 36 446.6010566550302 446.9761692230607 447.55465366104426] 37
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。