chore(types): fill out remaining partial types. <!-- Thank you for contributing to Pyodide! All improvements are welcome,
     so don't be afraid to make a PR. -->

### Description

<!-- Please explain what your PR is about:
     - reasoning for the change
     - some details of updated code
     - any noteworthy choices to be aware of
	Please refer to any related issues by #<issue_id> -->

Filling out remaining partially typed functions. Had to guess on a few, maybe some Any's could be avoided.

package:
  name: scipy
  version: 1.8.0

# See extra explanation in info.md
#
# For future reference: if you see the following errors:
#   Declaration error: adjustable dimension on non-argument
# or:
#   nonconstant array size
# you are trying to compile code that isn't written to the fortran 77 standard.
# The line number in the error points to the last line of the problematic
# subroutine. Try deleting it.

source:
  url: https://files.pythonhosted.org/packages/b4/a2/4faa34bf0cdbefd5c706625f1234987795f368eb4e97bde9d6f46860843e/scipy-1.8.0.tar.gz
  sha256: 31d4f2d6b724bc9a98e527b5849b8a7e589bf1ea630c33aa563eda912c9ff0bd

  patches:
    - patches/0001-Fix-dstevr-in-special-lapack_defs.h.patch
    - patches/0002-loadDynamicLibrary-flapack.patch
    - patches/0003-Add-lapack_extras-to-linalg-setup.py.patch
    - patches/0004-int-to-string.patch
    - patches/0005-disable-blas-detection.patch
    - patches/0006-fix-fotran-files-minpack.patch
    - patches/0007-gemm_-no-const.patch
    - patches/0008-make-int-return-values.patch
    - patches/0009-Rename-_page_trend_test.py-to-prevent-test-unvendori.patch
    - patches/0010-sasum-returns-double-not-float.patch
    - patches/0011-skip-fortran-fails-to-link.patch
    - patches/0012-Disable-lapack-detection.patch
    - patches/0013-Add-extra-END-to-prini.f.patch
    - patches/0014-BUG-Fix-signature-of-D_IIR_forback-1-2.patch

build:
  cflags: |
    -I$(WASM_LIBRARY_DIR)/CLAPACK/INCLUDE
    -I$(HOSTSITEPACKAGES)/pythran/
    -Wno-return-type
    -DUNDERSCORE_G77
  ldflags: |
    -L$(NUMPY_LIB)/core/lib/
    -L$(NUMPY_LIB)/random/lib/
  # IMPORTANT: Other locations important in scipy build process:
  # There are two files built in the "capture" pass that need patching:
  #    _blas_subroutines.h, and _cython
  # Scipy has a bunch of custom logic implemented in
  # pyodide-build/pyodide_build/_f2c_fixes.py.
  script: |
    pip install -t $HOSTSITEPACKAGES pythran
    # We get linker errors because the following 36 functions are missing
    # Copying them from a more recent LAPACK seems to work fine.
    wget https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v3.10.0.tar.gz
    tar xzf v3.10.0.tar.gz
    cd lapack-3.10.0/SRC

    cat \
      cgemqrt.f cgeqrfp.f cgeqrt.f clahqr.f csyconv.f csyconvf.f csyconvf_rook.f ctpmqrt.f ctpqrt.f cuncsd.f \
      dgemqrt.f dgeqrfp.f dgeqrt.f dlahqr.f dsyconv.f dsyconvf.f dsyconvf_rook.f dtpmqrt.f dtpqrt.f dorcsd.f \
      sgemqrt.f sgeqrfp.f sgeqrt.f slahqr.f ssyconv.f ssyconvf.f ssyconvf_rook.f stpmqrt.f stpqrt.f sorcsd.f \
      zgemqrt.f zgeqrfp.f zgeqrt.f zlahqr.f zsyconv.f zsyconvf.f zsyconvf_rook.f ztpmqrt.f ztpqrt.f zuncsd.f \
    >>  ../../scipy/linalg/lapack_extras.f
    sed -i 's/CHARACTER/INTEGER/g' ../../scipy/linalg/lapack_extras.f
    sed -i 's/RECURSIVE//g' ../../scipy/linalg/lapack_extras.f
    cd ../..

    # Change many functions that return void into functions that return int
    find scipy -name "*.c*" | xargs sed -i 's/extern void F_FUNC/extern int F_FUNC/g'

    sed -i 's/void F_FUNC/int F_FUNC/g' scipy/odr/__odrpack.c
    sed -i 's/^void/int/g' scipy/odr/odrpack.h
    sed -i 's/^void/int/g' scipy/odr/__odrpack.c

    sed -i 's/void BLAS_FUNC/int BLAS_FUNC/g' scipy/special/lapack_defs.h
    # sed -i 's/void F_FUNC/int F_FUNC/g' scipy/linalg/_lapack_subroutines.h
    sed -i 's/extern void/extern int/g' scipy/optimize/__minpack.h
    sed -i 's/void/int/g' scipy/linalg/cython_blas_signatures.txt
    sed -i 's/^void/int/g' scipy/interpolate/src/_fitpackmodule.c

    sed -i 's/^void/int/g' scipy/optimize/_trlib/trlib_private.h
    sed -i 's/^void/int/g' scipy/optimize/_trlib/trlib/trlib_private.h
    sed -i 's/, int)/)/g' scipy/optimize/_trlib/trlib_private.h
    sed -i 's/, 1)/)/g' scipy/optimize/_trlib/trlib_private.h

    sed -i 's/^void/int/g' scipy/spatial/qhull_misc.h
    sed -i 's/, size_t)/)/g' scipy/spatial/qhull_misc.h
    sed -i 's/,1)/)/g' scipy/spatial/qhull_misc.h


    # Missing declaration from cython_lapack_signatures.txt
    echo "void ilaenv(int *ispec, char *name, char *opts, int *n1, int *n2, int *n3, int *n4)" \
      >>  scipy/linalg/cython_lapack_signatures.txt

    # sed -i 's/^void/int/g' scipy/linalg/cython_lapack_signatures.txt

    # Input error causes "duplicate symbol" linker errors. Empty out the file.
    echo "" > scipy/sparse/linalg/_dsolve/SuperLU/SRC/input_error.c
  cross-build-env: true
  cross-build-files:
    - scipy/linalg/cython_lapack.pxd
    - scipy/linalg/cython_blas.pxd

requirements:
  run:
    - numpy
    - CLAPACK

test:
  imports:
    - scipy
    - scipy.cluster
    - scipy.cluster.vq
    - scipy.cluster.hierarchy
    - scipy.constants
    - scipy.fft
    - scipy.fftpack
    - scipy.integrate
    - scipy.interpolate
    - scipy.io
    - scipy.io.arff
    - scipy.io.matlab
    - scipy.io.wavfile
    - scipy.linalg
    - scipy.linalg.blas
    - scipy.linalg.cython_blas
    - scipy.linalg.lapack
    - scipy.linalg.cython_lapack
    - scipy.linalg.interpolative
    - scipy.misc
    - scipy.ndimage
    - scipy.odr
    - scipy.optimize
    - scipy.signal
    - scipy.signal.windows
    - scipy.sparse
    - scipy.sparse.linalg
    - scipy.sparse.csgraph
    - scipy.spatial
    - scipy.spatial.distance
    - scipy.spatial.transform
    - scipy.special
    - scipy.stats
    - scipy.stats.contingency
    - scipy.stats.distributions
    - scipy.stats.mstats
    - scipy.stats.qmc

package:
  name: scipy
  version: 1.8.0

# See extra explanation in info.md
#
# For future reference: if you see the following errors:
#   Declaration error: adjustable dimension on non-argument
# or:
#   nonconstant array size
# you are trying to compile code that isn't written to the fortran 77 standard.
# The line number in the error points to the last line of the problematic
# subroutine. Try deleting it.

source:
  url: https://files.pythonhosted.org/packages/b4/a2/4faa34bf0cdbefd5c706625f1234987795f368eb4e97bde9d6f46860843e/scipy-1.8.0.tar.gz
  sha256: 31d4f2d6b724bc9a98e527b5849b8a7e589bf1ea630c33aa563eda912c9ff0bd

  patches:
    - patches/0001-Fix-dstevr-in-special-lapack_defs.h.patch
    - patches/0002-loadDynamicLibrary-flapack.patch
    - patches/0003-Add-lapack_extras-to-linalg-setup.py.patch
    - patches/0004-int-to-string.patch
    - patches/0005-disable-blas-detection.patch
    - patches/0006-fix-fotran-files-minpack.patch
    - patches/0007-gemm_-no-const.patch
    - patches/0008-make-int-return-values.patch
    - patches/0009-Rename-_page_trend_test.py-to-prevent-test-unvendori.patch
    - patches/0010-sasum-returns-double-not-float.patch
    - patches/0011-skip-fortran-fails-to-link.patch
    - patches/0012-Disable-lapack-detection.patch
    - patches/0013-Add-extra-END-to-prini.f.patch
    - patches/0014-BUG-Fix-signature-of-D_IIR_forback-1-2.patch

build:
  cflags: |
    -I$(WASM_LIBRARY_DIR)/CLAPACK/INCLUDE
    -I$(HOSTSITEPACKAGES)/pythran/
    -Wno-return-type
    -DUNDERSCORE_G77
  ldflags: |
    -L$(NUMPY_LIB)/core/lib/
    -L$(NUMPY_LIB)/random/lib/
  # IMPORTANT: Other locations important in scipy build process:
  # There are two files built in the "capture" pass that need patching:
  #    _blas_subroutines.h, and _cython
  # Scipy has a bunch of custom logic implemented in
  # pyodide-build/pyodide_build/_f2c_fixes.py.
  script: |
    pip install -t $HOSTSITEPACKAGES pythran
    # We get linker errors because the following 36 functions are missing
    # Copying them from a more recent LAPACK seems to work fine.
    wget https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v3.10.0.tar.gz
    tar xzf v3.10.0.tar.gz
    cd lapack-3.10.0/SRC

    cat \
      cgemqrt.f cgeqrfp.f cgeqrt.f clahqr.f csyconv.f csyconvf.f csyconvf_rook.f ctpmqrt.f ctpqrt.f cuncsd.f \
      dgemqrt.f dgeqrfp.f dgeqrt.f dlahqr.f dsyconv.f dsyconvf.f dsyconvf_rook.f dtpmqrt.f dtpqrt.f dorcsd.f \
      sgemqrt.f sgeqrfp.f sgeqrt.f slahqr.f ssyconv.f ssyconvf.f ssyconvf_rook.f stpmqrt.f stpqrt.f sorcsd.f \
      zgemqrt.f zgeqrfp.f zgeqrt.f zlahqr.f zsyconv.f zsyconvf.f zsyconvf_rook.f ztpmqrt.f ztpqrt.f zuncsd.f \
    >>  ../../scipy/linalg/lapack_extras.f
    sed -i 's/CHARACTER/INTEGER/g' ../../scipy/linalg/lapack_extras.f
    sed -i 's/RECURSIVE//g' ../../scipy/linalg/lapack_extras.f
    cd ../..

    # Change many functions that return void into functions that return int
    find scipy -name "*.c*" | xargs sed -i 's/extern void F_FUNC/extern int F_FUNC/g'

    sed -i 's/void F_FUNC/int F_FUNC/g' scipy/odr/__odrpack.c
    sed -i 's/^void/int/g' scipy/odr/odrpack.h
    sed -i 's/^void/int/g' scipy/odr/__odrpack.c

    sed -i 's/void BLAS_FUNC/int BLAS_FUNC/g' scipy/special/lapack_defs.h
    # sed -i 's/void F_FUNC/int F_FUNC/g' scipy/linalg/_lapack_subroutines.h
    sed -i 's/extern void/extern int/g' scipy/optimize/__minpack.h
    sed -i 's/void/int/g' scipy/linalg/cython_blas_signatures.txt
    sed -i 's/^void/int/g' scipy/interpolate/src/_fitpackmodule.c

    sed -i 's/^void/int/g' scipy/optimize/_trlib/trlib_private.h
    sed -i 's/^void/int/g' scipy/optimize/_trlib/trlib/trlib_private.h
    sed -i 's/, int)/)/g' scipy/optimize/_trlib/trlib_private.h
    sed -i 's/, 1)/)/g' scipy/optimize/_trlib/trlib_private.h

    sed -i 's/^void/int/g' scipy/spatial/qhull_misc.h
    sed -i 's/, size_t)/)/g' scipy/spatial/qhull_misc.h
    sed -i 's/,1)/)/g' scipy/spatial/qhull_misc.h


    # Missing declaration from cython_lapack_signatures.txt
    echo "void ilaenv(int *ispec, char *name, char *opts, int *n1, int *n2, int *n3, int *n4)" \
      >>  scipy/linalg/cython_lapack_signatures.txt

    # sed -i 's/^void/int/g' scipy/linalg/cython_lapack_signatures.txt

    # Input error causes "duplicate symbol" linker errors. Empty out the file.
    echo "" > scipy/sparse/linalg/_dsolve/SuperLU/SRC/input_error.c
  cross-build-env: true
  cross-build-files:
    - scipy/linalg/cython_lapack.pxd
    - scipy/linalg/cython_blas.pxd

requirements:
  run:
    - numpy
    - CLAPACK

test:
  imports:
    - scipy
    - scipy.cluster
    - scipy.cluster.vq
    - scipy.cluster.hierarchy
    - scipy.constants
    - scipy.fft
    - scipy.fftpack
    - scipy.integrate
    - scipy.interpolate
    - scipy.io
    - scipy.io.arff
    - scipy.io.matlab
    - scipy.io.wavfile
    - scipy.linalg
    - scipy.linalg.blas
    - scipy.linalg.cython_blas
    - scipy.linalg.lapack
    - scipy.linalg.cython_lapack
    - scipy.linalg.interpolative
    - scipy.misc
    - scipy.ndimage
    - scipy.odr
    - scipy.optimize
    - scipy.signal
    - scipy.signal.windows
    - scipy.sparse
    - scipy.sparse.linalg
    - scipy.sparse.csgraph
    - scipy.spatial
    - scipy.spatial.distance
    - scipy.spatial.transform
    - scipy.special
    - scipy.stats
    - scipy.stats.contingency
    - scipy.stats.distributions
    - scipy.stats.mstats
    - scipy.stats.qmc
