diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7a2dde5..9e038e6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,15 +6,15 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python: [3.7, 3.8, 3.9] + python: ['3.8', '3.9', '3.10'] numba_boundscheck: [0] include: - os: macos-latest - python: 3.9 + python: '3.10' - os: windows-latest - python: 3.9 + python: '3.10' - os: ubuntu-latest - python: 3.9 + python: '3.10' numba_boundscheck: 1 fail-fast: false runs-on: ${{ matrix.os }} @@ -79,7 +79,7 @@ jobs: activate-environment: sparse-dev allow-softlinks: true environment-file: ci/environment.yml - python-version: 3.9 + python-version: '3.10' miniforge-variant: Mambaforge use-only-tar-bz2: true use-mamba: true diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 598f4a0b..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,52 +0,0 @@ -jobs: -- job: Linux - variables: - python_version: '3.6' - pool: - vmImage: 'ubuntu-latest' - steps: - - template: ci/azure-steps.yml - strategy: - matrix: - Python39: - python_version: '3.9' - Python38: - python_version: '3.8' - Python37: - python_version: '3.7' -- job: MacOS - variables: - python_version: '3.6' - pool: - vmImage: 'macos-latest' - steps: - - template: ci/azure-steps.yml -- job: Windows - variables: - python_version: '3.6' - pool: - vmImage: 'windows-latest' - steps: - - template: ci/azure-steps.yml -- job: Docs - pool: - vmImage: 'ubuntu-latest' - steps: - - template: ci/azure-docs.yml - -trigger: - branches: - include: - - master - - vnext - tags: - include: - - '*' - -pr: - branches: - include: - - master - - releases/* - exclude: - - releases/old* diff --git a/ci/01-install.sh b/ci/01-install.sh deleted file mode 100755 index 2d5dbf94..00000000 --- a/ci/01-install.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -if [[ $NUMPY_VERSION ]]; then - pip install numpy$NUMPY_VERSION; -fi - -pip install -e .[tests] -pip install codecov diff --git a/ci/azure-docs.yml b/ci/azure-docs.yml deleted file mode 100644 index 5fa79c13..00000000 --- a/ci/azure-docs.yml +++ /dev/null @@ -1,17 +0,0 @@ -steps: -- task: UsePythonVersion@0 - inputs: - versionSpec: "3.7" - architecture: "x64" - -- script: | - pip install -e .[docs] - displayName: Install package - -- script: sphinx-build -W -b html docs/ _build/html - displayName: Build documentation - -- task: PublishPipelineArtifact@1 - inputs: - artifactName: 'Documentation' - targetPath: '$(System.DefaultWorkingDirectory)/_build/html' diff --git a/ci/azure-steps.yml b/ci/azure-steps.yml deleted file mode 100644 index bae51f72..00000000 --- a/ci/azure-steps.yml +++ /dev/null @@ -1,28 +0,0 @@ -steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: $(python_version) - architecture: "x64" - - - script: | - pip install numpy$NUMPY_VERSION; - pip install -e .[tests] - pip install codecov - displayName: Install package - - - script: pytest --pyargs sparse - displayName: Run tests - - - script: codecov - displayName: Upload coverage to CodeCov - - - task: PublishTestResults@2 - condition: always() - inputs: - testResultsFiles: "$(System.DefaultWorkingDirectory)/**/test-*.xml" - testRunTitle: "Publish test results" - - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: "$(System.DefaultWorkingDirectory)/**/coverage.xml" diff --git a/ci/environment-3.6.yml b/ci/environment-3.6.yml deleted file mode 100644 index fd2fc2e1..00000000 --- a/ci/environment-3.6.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: py36-sparse-test -channels: - - conda-forge -dependencies: - - python=3.6 - - pip - - pytest - - numpy - - scipy - - pytest-cov - - nomkl - - numba - - black - - codecov - - pip: - - pytest-black diff --git a/ci/environment-3.7.yml b/ci/environment-3.7.yml deleted file mode 100644 index f04f1d04..00000000 --- a/ci/environment-3.7.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: py37-sparse-test -channels: - - conda-forge -dependencies: - - python=3.7 - - pip - - pytest - - numpy - - scipy - - pytest-cov - - nomkl - - numba - - black - - codecov - - pip: - - pytest-black diff --git a/ci/environment-3.8.yml b/ci/environment-3.8.yml deleted file mode 100644 index 5a28cf9a..00000000 --- a/ci/environment-3.8.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: py38-sparse-test -channels: - - conda-forge -dependencies: - - python=3.8 - - pip - - pytest - - numpy - - scipy - - pytest-cov - - nomkl - - numba - - black - - codecov - - pip: - - pytest-black diff --git a/readthedocs.yml b/readthedocs.yml index 0413384f..fc3870b9 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -2,7 +2,7 @@ build: image: latest python: - version: 3.7 + version: '3.9' pip_install: true extra_requirements: - docs diff --git a/setup.py b/setup.py index f177cefc..0e21e6dc 100755 --- a/setup.py +++ b/setup.py @@ -59,9 +59,9 @@ def parse_requires(): "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3 :: Only", "Intended Audience :: Developers", "Intended Audience :: Science/Research", @@ -74,5 +74,5 @@ def parse_requires(): entry_points={ "numba_extensions": ["init = sparse._numba_extension:_init_extension"] }, - python_requires=">=3.6, <4", + python_requires=">=3.8, <4", ) diff --git a/sparse/_coo/core.py b/sparse/_coo/core.py index a618a834..cda3ceb6 100644 --- a/sparse/_coo/core.py +++ b/sparse/_coo/core.py @@ -241,12 +241,11 @@ def __init__( if self.data.ndim != 1: raise ValueError("data must be a scalar or 1-dimensional.") - if shape and not self.coords.size: - self.coords = np.zeros( - (len(shape) if isinstance(shape, Iterable) else 1, 0), dtype=np.intp - ) - if shape is None: + warnings.warn( + "shape should be provided. This will raise a ValueError in the future.", + DeprecationWarning, + ) if self.coords.nbytes: shape = tuple((self.coords.max(axis=1) + 1)) else: @@ -255,6 +254,18 @@ def __init__( if not isinstance(shape, Iterable): shape = (shape,) + if isinstance(shape, np.ndarray): + shape = tuple(shape) + + if shape and not self.coords.size: + warnings.warn( + "coords should be an ndarray. This will raise a ValueError in the future.", + DeprecationWarning, + ) + self.coords = np.zeros( + (len(shape) if isinstance(shape, Iterable) else 1, 0), dtype=np.intp + ) + super().__init__(shape, fill_value=fill_value) if idx_dtype: if not can_store(idx_dtype, max(shape)): diff --git a/sparse/tests/test_coo.py b/sparse/tests/test_coo.py index 74310df4..78daf569 100644 --- a/sparse/tests/test_coo.py +++ b/sparse/tests/test_coo.py @@ -1672,3 +1672,10 @@ def test_scalar_elemwise(): x1 = s1.todense() assert_eq(s1 * x2, x1 * x2) + + +def test_array_as_shape(): + coords = [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]] + data = [10, 20, 30, 40, 50] + + s = sparse.COO(coords, data, shape=np.array((5, 5)))