diff --git a/recipes/recipes_emscripten/numpy/build.sh b/recipes/recipes_emscripten/numpy/build.sh index d1068f99132..4a10cb35d18 100644 --- a/recipes/recipes_emscripten/numpy/build.sh +++ b/recipes/recipes_emscripten/numpy/build.sh @@ -6,7 +6,9 @@ rm -r -f branding export CFLAGS="$CFLAGS -Wno-return-type -Wno-implicit-function-declaration" export MESON_CROSS_FILE=$RECIPE_DIR/emscripten.meson.cross -export LDFLAGS="$LDFLAGS -sWASM_BIGINT" +export LDFLAGS="$LDFLAGS -sWASM_BIGINT -sEXPORTED_FUNCTIONS=['_init_numpy'] -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=['sin','cos','exp','log']" + + cp $RECIPE_DIR/config/config.h.in numpy/_core/config.h.in # diff --git a/recipes/recipes_emscripten/numpy/recipe.yaml b/recipes/recipes_emscripten/numpy/recipe.yaml index 17e700ef797..90613100672 100644 --- a/recipes/recipes_emscripten/numpy/recipe.yaml +++ b/recipes/recipes_emscripten/numpy/recipe.yaml @@ -11,7 +11,7 @@ source: url: https://github.com/numpy/numpy/releases/download/v${{ version }}/numpy-${{ version }}.tar.gz sha256: e0486a11ec30cdecb53f184d496d1c6a20786c81e55e41640270130056f8ee48 build: - number: 0 + number: 1 requirements: build: diff --git a/recipes/recipes_emscripten/numpy/test_numpy.py b/recipes/recipes_emscripten/numpy/test_numpy.py index 839ca268a61..ee36d7f6871 100644 --- a/recipes/recipes_emscripten/numpy/test_numpy.py +++ b/recipes/recipes_emscripten/numpy/test_numpy.py @@ -1,5 +1,31 @@ def test_numpy(): - import numpy + import numpy as np - ones = numpy.ones(shape=[2,3]) - assert ones.shape == (2,3) \ No newline at end of file + ones = np.ones(shape=[2,3]) + assert ones.shape == (2,3) + + + + # 1. Array creation & dtype + a = np.arange(6).reshape(2, 3) + print("Array a:\n", a, "dtype:", a.dtype) + + # 2. Elementwise ops & broadcasting + b = np.ones((2, 1)) + print("a + b (broadcasted):\n", a + b) + + # 3. Reduction + print("Sum of a:", np.sum(a)) + + # 4. Matrix multiplication (BLAS check) + c = np.array([[1, 2], [3, 4]]) + d = np.array([[5, 6], [7, 8]]) + print("Matrix product c @ d:\n", c @ d) + + # 5. Linear algebra (LAPACK check) + eigvals, eigvecs = np.linalg.eig(c) + print("Eigenvalues of c:", eigvals) + + # 6. Random numbers + rng = np.random.default_rng(42) + print("Random sample:", rng.random(3))