Issue 1:
I recently purchased new Mac Pro w/ Mac Os X 11.0.1 & Apple Silicon M1.

I installed homebrew (when enabling Rosetta) and managed to install python3.9 and other packages through brew (numpy==1.19.5 & scipy==1.6.0, amongst others).

However, executing my one-liner script yields a "bus error". That happens when I try to import curve_fit from scipy.optimize. Any ideas how to solve that?

I believe this is hardware related and is due to non optimal compilation of scipy for the M1 architecture (data are lost somewhere on the memory bus? https://www.quora.com/Why-there-is-a-bus-error-in-the-Python-program-when-it-recurs-over-18-713-times ).

Python code:

from scipy.optimize import curve_fit

Error:

zsh: bus error

Tail lines when running this code in python3.9 with -v option.

import 'scipy.sparse.linalg.dsolve' # <_frozen_importlib_external.SourceFileLoader object at 0x1182ad040>
# /opt/homebrew/lib/python3.9/site-packages/scipy/sparse/linalg/eigen/__pycache__/__init__.cpython-39.pyc matches /opt/homebrew/lib/python3.9/site-packages/scipy/sparse/linalg/eigen/__init__.py
# code object from '/opt/homebrew/lib/python3.9/site-packages/scipy/sparse/linalg/eigen/__pycache__/__init__.cpython-39.pyc'
# /opt/homebrew/lib/python3.9/site-packages/scipy/sparse/linalg/eigen/arpack/__pycache__/__init__.cpython-39.pyc matches /opt/homebrew/lib/python3.9/site-packages/scipy/sparse/linalg/eigen/arpack/__init__.py
# code object from '/opt/homebrew/lib/python3.9/site-packages/scipy/sparse/linalg/eigen/arpack/__pycache__/__init__.cpython-39.pyc'
# /opt/homebrew/lib/python3.9/site-packages/scipy/sparse/linalg/eigen/arpack/__pycache__/arpack.cpython-39.pyc matches /opt/homebrew/lib/python3.9/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py
# code object from '/opt/homebrew/lib/python3.9/site-packages/scipy/sparse/linalg/eigen/arpack/__pycache__/arpack.cpython-39.pyc'
zsh: bus error python3.9 -v debug.py

I also posted this question on stack overflow: https://stackoverflow.com/questions/65838231/importing-scipy-in-python-3-9-1-yields-zsh-bus-error-apple-silicon-m1-mac-os-1

Issue 2:
My issue is about NaNs produced using scipy.interpolate.griddata.

Consider that the values from values.csv are defined for each point from points.csv.

We would like to get interpolated values for points from xi.csv.

In the following code snippet I check whether the interpolated values contain any NaNs.

Reproducing code example:

from scipy.interpolate import griddata
import numpy as np
import pandas as pd

points = pd.read_csv('points.csv').values
values = pd.read_csv('values.csv').values
xi = pd.read_csv('xi.csv').values

interpolated = griddata(points, values, xi, method='linear', rescale=True)

idx_nan = np.where(np.isnan(interpolated))[0]
if idx_nan.any():
print('NaNs are present')
print(xi[idx_nan])
else:
print('Success')

I used two sets of inputs for points and values: with_duplicates and no_duplicates.

In the former ones there are points with the duplicate coordinates, while in the other one they are eliminated.

Outputs

With Duplicates

NaNs are present
[[ 2. 0. 0. 30. ]
[ 2. 0. 0. 50. ]
[ 2. 0. 0. 70. ]
[ 2.5 0. 0. 30. ]
[ 2.5 0. 0. 50. ]
[ 2.5 0. 0. 70. ]
[ 3. 0. 0. 30. ]
[ 3. 0. 0. 50. ]
[ 3. 0. 0. 70. ]
[ 3.5 0. 0. 30. ]
[ 3.5 0. 0. 50. ]
[ 3.5 0. 0. 70. ]
[ 4. 0. 0. 30. ]
[ 4. 0. 0. 50. ]
[ 4. 0. 0. 70. ]
[ 4.5 0. 0. 30. ]
[ 4.5 0. 0. 50. ]
[ 4.5 0. 0. 70. ]
[ 5. 0. 0. 30. ]
[ 5. 0. 0. 50. ]
[ 5. 0. 0. 70. ]]

I wonder why the NaNs were generated not for all points.

Note, that there were no NaNs for [1 0 0 30] point, for example.

The points, where we have NaNs as a results on interpolation are actually present in points.csv, for example [5, 0, 0, 30] is there.

Thus, it is surprising why interpolation led to NaNs even if there is a perfect match in the points array.

No Duplicates

Success

I removed duplicate points and re-ran the code snippet. Now it was a success.

It is not clear, though, why there would be such a behavior with with_duplicates. If the point from xi matches point from points array, then it seems that the algorithm should just pick the corresponding value.

Scipy/Numpy/Python version information:

import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)
1.2.1 1.16.3 sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)

Files with data

xi.zip

with_duplicates.zip

no_duplicates.zip