Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH: linalg: consistent support for zero-size batch #24148

@jakevdp

Description

@jakevdp

Describe your issue.

In the 1.17 release candidate, scipy.linalg.toeplitz unexpectedly returns a list rather than array when passed batched input with an empty batch.

Reproducing Code Example

import numpy as np
import scipy
print(f"{scipy.__version__=}")

result = scipy.linalg.toeplitz(np.zeros((0, 4)))
print(type(result), result)

Error message

scipy.__version__='1.17.0rc1'
<class 'list'> []

The expected output here would be an ndarray with shape (0, 4, 4).

SciPy/NumPy/Python version and system information

1.17.0rc1 2.3.5 sys.version_info(major=3, minor=12, micro=12, releaselevel='final', serial=0)
Build Dependencies:
  blas:
    detection method: pkgconfig
    found: true
    has ilp64: false
    include directory: /opt/_internal/cpython-3.12.11/lib/python3.12/site-packages/scipy_openblas32/include
    lib directory: /opt/_internal/cpython-3.12.11/lib/python3.12/site-packages/scipy_openblas32/lib
    name: scipy-openblas
    openblas configuration: OpenBLAS 0.3.30 DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64
    pc file directory: /project/
    version: 0.3.30
  lapack:
    detection method: pkgconfig
    found: true
    has ilp64: false
    include directory: /opt/_internal/cpython-3.12.11/lib/python3.12/site-packages/scipy_openblas32/include
    lib directory: /opt/_internal/cpython-3.12.11/lib/python3.12/site-packages/scipy_openblas32/lib
    name: scipy-openblas
    openblas configuration: OpenBLAS 0.3.30 DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64
    pc file directory: /project/
    version: 0.3.30
  pybind11:
    detection method: config-tool
    include directory: unknown
    name: pybind11
    version: 3.0.1
Compilers:
  c:
    commands: cc
    linker: ld.bfd
    name: gcc
    version: 14.2.1
  c++:
    commands: c++
    linker: ld.bfd
    name: gcc
    version: 14.2.1
  cython:
    commands: cython
    linker: cython
    name: cython
    version: 3.2.2
  fortran:
    commands: gfortran
    linker: ld.bfd
    name: gcc
    version: 14.2.1
  pythran:
    include directory: ../../tmp/build-env-fjeibmbd/lib/python3.12/site-packages/pythran
    version: 0.18.1
Machine Information:
  build:
    cpu: x86_64
    endian: little
    family: x86_64
    system: linux
  cross-compiled: false
  host:
    cpu: x86_64
    endian: little
    family: x86_64
    system: linux
Python Information:
  path: /tmp/build-env-fjeibmbd/bin/python
  version: '3.12'

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectA clear bug or issue that prevents SciPy from being installed or used as expectedenhancementA new feature or improvementscipy.linalg

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions