Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUILD: Move to Poetry #647

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 38 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,52 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Cache conda
uses: actions/cache@v4
env:
# Increase this value to reset cache if ci/environment.yml has not changed
CACHE_NUMBER: 0
# - name: Cache conda
# uses: actions/cache@v4
# env:
# # Increase this value to reset cache if ci/environment.yml has not changed
# CACHE_NUMBER: 0
# with:
# path: ~/conda_pkgs_dir
# key:
# test-${{ matrix.os }}-conda-py${{ matrix.python }}-${{ env.CACHE_NUMBER }}-${{
# hashFiles('ci/environment.yml') }}
# - uses: conda-incubator/setup-miniconda@v3
# with:
# activate-environment: sparse-dev
# allow-softlinks: true
# environment-file: ci/environment.yml
# python-version: ${{ matrix.python }}
# miniforge-version: latest
# - name: Install julia and numba
# run: |
# conda install conda-forge::numba
# conda install conda-forge::julia
# - uses: julia-actions/setup-julia@v1.9
# with:
# version: '1.10'
- uses: actions/setup-python@v5
with:
path: ~/conda_pkgs_dir
key:
test-${{ matrix.os }}-conda-py${{ matrix.python }}-${{ env.CACHE_NUMBER }}-${{
hashFiles('ci/environment.yml') }}
- uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: sparse-dev
allow-softlinks: true
environment-file: ci/environment.yml
python-version: ${{ matrix.python }}
miniforge-version: latest
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install package
run: |
pip install -e .[tests]
poetry install --with tests,finch
# - name: Install package
# run: |
# pip install -e .[tests,finch]
- name: Run tests
run: |
pytest --pyargs sparse
poetry run pytest tests/test_backends.py
# pytest --pyargs sparse/tests/test_backends.py
- uses: codecov/codecov-action@v4
if: always()
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always()
with:
files: "**/test-*.xml"
# - name: Publish Test Results
# uses: EnricoMi/publish-unit-test-result-action/composite@v2
# if: always()
# with:
# files: "**/test-*.xml"
docs:
defaults:
run:
Expand Down
34 changes: 24 additions & 10 deletions benchmarks/benchmark_gcxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
class MatrixMultiplySuite:
def setup(self):
rng = np.random.default_rng(0)
self.x = sparse.random((100, 100), density=0.01, format="gcxs", random_state=rng)
self.y = sparse.random((100, 100), density=0.01, format="gcxs", random_state=rng)
self.x = sparse.random(
(100, 100), density=0.01, format="gcxs", random_state=rng
)
self.y = sparse.random(
(100, 100), density=0.01, format="gcxs", random_state=rng
)

self.x @ self.y # Numba compilation

Expand All @@ -18,8 +22,12 @@ def time_matmul(self):
class ElemwiseSuite:
def setup(self):
rng = np.random.default_rng(0)
self.x = sparse.random((100, 100, 100), density=0.01, format="gcxs", random_state=rng)
self.y = sparse.random((100, 100, 100), density=0.01, format="gcxs", random_state=rng)
self.x = sparse.random(
(100, 100, 100), density=0.01, format="gcxs", random_state=rng
)
self.y = sparse.random(
(100, 100, 100), density=0.01, format="gcxs", random_state=rng
)

self.x + self.y # Numba compilation

Expand All @@ -33,8 +41,12 @@ def time_mul(self):
class ElemwiseBroadcastingSuite:
def setup(self):
rng = np.random.default_rng(0)
self.x = sparse.random((100, 1, 100), density=0.01, format="gcxs", random_state=rng)
self.y = sparse.random((100, 100), density=0.01, format="gcxs", random_state=rng)
self.x = sparse.random(
(100, 1, 100), density=0.01, format="gcxs", random_state=rng
)
self.y = sparse.random(
(100, 100), density=0.01, format="gcxs", random_state=rng
)

def time_add(self):
self.x + self.y
Expand All @@ -47,7 +59,9 @@ class IndexingSuite:
def setup(self):
rng = np.random.default_rng(0)
self.index = rng.integers(0, 100, 50)
self.x = sparse.random((100, 100, 100), density=0.01, format="gcxs", random_state=rng)
self.x = sparse.random(
(100, 100, 100), density=0.01, format="gcxs", random_state=rng
)

# Numba compilation
self.x[5]
Expand Down Expand Up @@ -76,9 +90,9 @@ class DenseMultiplySuite:
def setup(self, compressed_axis, n_vecs):
rng = np.random.default_rng(1337)
n = 10000
x = sparse.random((n, n), density=0.001, format="gcxs", random_state=rng).change_compressed_axes(
(compressed_axis,)
)
x = sparse.random(
(n, n), density=0.001, format="gcxs", random_state=rng
).change_compressed_axes((compressed_axis,))
self.x = x
self.t = rng.random((n, n_vecs))
self.u = rng.random((n_vecs, n))
Expand Down
4 changes: 3 additions & 1 deletion benchmarks/benchmark_tensordot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def setup(self):
self.s2 = sparse.random((100, 100, 100, 100), density=0.01, random_state=rng)

def time_dense(self):
sparse.tensordot(self.s1, self.s2, axes=([0, 1], [0, 2]), return_type=np.ndarray)
sparse.tensordot(
self.s1, self.s2, axes=([0, 1], [0, 2]), return_type=np.ndarray
)

def time_sparse(self):
sparse.tensordot(self.s1, self.s2, axes=([0, 1], [0, 2]))
Expand Down
8 changes: 6 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

mathjax_path = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
mathjax_path = (
"https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
)

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
Expand Down Expand Up @@ -151,7 +153,9 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [(root_doc, "sparse.tex", "sparse Documentation", "Sparse Developers", "manual")]
latex_documents = [
(root_doc, "sparse.tex", "sparse Documentation", "Sparse Developers", "manual")
]

# -- Options for manual page output ---------------------------------------

Expand Down
12 changes: 9 additions & 3 deletions docs/gen_logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def fill(rs):
root,
"rect",
style=f"{colors['orange']};{fill(rs)};",
transform=transform(1, b, 0, 1, (i + 5) * s + offset_x, (i * b + j) * s + offset_y),
transform=transform(
1, b, 0, 1, (i + 5) * s + offset_x, (i * b + j) * s + offset_y
),
**kwargs,
)

Expand Down Expand Up @@ -103,7 +105,9 @@ def fill(rs):
root,
"rect",
style=f"{colors['blue']};{fill(rs)};",
transform=transform(1, b, 0, 1, i * s + offset_x, (i * b + j + y2) * s + offset_y),
transform=transform(
1, b, 0, 1, i * s + offset_x, (i * b + j + y2) * s + offset_y
),
**kwargs,
)

Expand All @@ -119,7 +123,9 @@ def fill(rs):
root,
"rect",
style=f"{colors['grey']};{fill(rs)};",
transform=transform(1, -b, 0, 1, (i + 5) * s + offset_x, ((10 - i) * b + j + 5) * s + offset_y),
transform=transform(
1, -b, 0, 1, (i + 5) * s + offset_x, ((10 - i) * b + j + 5) * s + offset_y
),
**kwargs,
)

Expand Down
187 changes: 108 additions & 79 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,81 +1,110 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"
# [build-system]
# requires = ["setuptools>=64", "setuptools_scm>=8"]
# build-backend = "setuptools.build_meta"

# [project]
# name = "sparse"
# dynamic = ["version"]
# description = "Sparse n-dimensional arrays for the PyData ecosystem"
# readme = "README.rst"
# dependencies = ["numpy>=1.17"]
# maintainers = [{ name = "Hameer Abbasi", email = "hameerabbasi@yahoo.com" }]
# requires-python = ">=3.9"
# license = { file = "LICENSE" }
# keywords = ["sparse", "numpy", "scipy", "dask"]
# classifiers = [
# "Development Status :: 2 - Pre-Alpha",
# "Operating System :: OS Independent",
# "License :: OSI Approved :: BSD License",
# "Programming Language :: Python",
# "Programming Language :: Python :: 3",
# "Programming Language :: Python :: 3.9",
# "Programming Language :: Python :: 3.10",
# "Programming Language :: Python :: 3.11",
# "Programming Language :: Python :: 3 :: Only",
# "Intended Audience :: Developers",
# "Intended Audience :: Science/Research",
# ]

# [project.optional-dependencies]
# docs = ["sphinx", "sphinx_rtd_theme", "scipy"]
# tests = [
# "dask[array]",
# "pytest>=3.5",
# "pytest-cov",
# "pre-commit",
# "scipy",
# ]
# tox = ["sparse[tests]", "tox"]
# all = ["sparse[docs,tox]", "matrepr"]
# finch = ["finch-tensor==0.1.6"]

# [project.urls]
# Documentation = "https://sparse.pydata.org/"
# Source = "https://github.com/pydata/sparse/"
# Repository = "https://github.com/pydata/sparse.git"
# "Issue Tracker" = "https://github.com/pydata/sparse/issues"
# Discussions = "https://github.com/pydata/sparse/discussions"

# # [project.entry-points.numba_extensions]
# # init = "sparse.pydata_backend._numba_extension:_init_extension"

# [tool.setuptools.packages.find]
# where = ["."]
# include = ["sparse", "sparse.*"]

# [tool.setuptools_scm]
# version_file = "sparse/_version.py"

# [tool.ruff]
# exclude = ["sparse/_version.py"]
# line-length = 120

# [tool.ruff.lint]
# select = ["F", "E", "W", "I", "B", "UP", "YTT", "BLE", "C4", "T10", "ISC", "ICN", "PIE", "PYI", "RSE", "RET", "SIM", "PGH", "FLY", "NPY", "PERF"]

[project]
name = "sparse"
dynamic = ["version"]
description = "Sparse n-dimensional arrays for the PyData ecosystem"
# [tool.ruff.lint.isort.sections]
# numpy = ["numpy", "numpy.*", "scipy", "scipy.*"]

# [tool.ruff.format]
# quote-style = "double"
# docstring-code-format = true

# [tool.ruff.lint.isort]
# section-order = [
# "future",
# "standard-library",
# "first-party",
# "third-party",
# "numpy",
# "local-folder",
# ]

[tool.poetry]
name = "sparse-copy"
version = "1.1.1"
description = ""
authors = ["Hameer Abbasi"]
readme = "README.rst"
dependencies = ["numpy>=1.17", "numba>=0.49"]
maintainers = [{ name = "Hameer Abbasi", email = "hameerabbasi@yahoo.com" }]
requires-python = ">=3.9"
license = { file = "LICENSE" }
keywords = ["sparse", "numpy", "scipy", "dask"]
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Operating System :: OS Independent",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
]

[project.optional-dependencies]
docs = ["sphinx", "sphinx_rtd_theme", "scipy"]
tests = [
"dask[array]",
"pytest>=3.5",
"pytest-cov",
"pre-commit",
"scipy",
]
tox = ["sparse[tests]", "tox"]
all = ["sparse[docs,tox]", "matrepr"]
finch = ["finch-tensor"]

[project.urls]
Documentation = "https://sparse.pydata.org/"
Source = "https://github.com/pydata/sparse/"
Repository = "https://github.com/pydata/sparse.git"
"Issue Tracker" = "https://github.com/pydata/sparse/issues"
Discussions = "https://github.com/pydata/sparse/discussions"

[project.entry-points.numba_extensions]
init = "sparse.pydata_backend._numba_extension:_init_extension"

[tool.setuptools.packages.find]
where = ["."]
include = ["sparse", "sparse.*"]

[tool.setuptools_scm]
version_file = "sparse/_version.py"

[tool.ruff]
exclude = ["sparse/_version.py"]
line-length = 120

[tool.ruff.lint]
select = ["F", "E", "W", "I", "B", "UP", "YTT", "BLE", "C4", "T10", "ISC", "ICN", "PIE", "PYI", "RSE", "RET", "SIM", "PGH", "FLY", "NPY", "PERF"]

[tool.ruff.lint.isort.sections]
numpy = ["numpy", "numpy.*", "scipy", "scipy.*"]

[tool.ruff.format]
quote-style = "double"
docstring-code-format = true

[tool.ruff.lint.isort]
section-order = [
"future",
"standard-library",
"first-party",
"third-party",
"numpy",
"local-folder",
]
packages = [{include = "sparse"}]

[tool.poetry.dependencies]
python = "^3.9"
juliapkg = "^0.1.10"
juliacall = "^0.9.15"
numpy = "^1.19"
llvmlite = "0.42.0"
numba = "^0.59"

[tool.poetry.group.tests.dependencies]
pytest = "^7.4.4"
pre-commit = "^3.6.0"
pytest-cov = "^4.1.0"
scipy = "^1.7"

[tool.poetry.group.finch.dependencies]
finch-tensor = "0.1.6"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Loading
Loading