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

Ruff's the codebase #237

Merged
merged 17 commits into from
Jul 14, 2024
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/Docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Docs
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
deploy:
Expand All @@ -25,7 +25,7 @@ jobs:
- name: Build Docs
run: mkdocs build

# Only deploy if master, otherwise just build for testing
# Only deploy if main, otherwise just build for testing
- name: Deploy
if: endsWith(github.ref, '/master')
if: endsWith(github.ref, '/main')
run: mkdocs gh-deploy --force
37 changes: 24 additions & 13 deletions .github/workflows/Linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Linting

on:
push:
branches: master
branches: main
pull_request:
branches: master
branches: main

jobs:
mypy:
Expand Down Expand Up @@ -46,26 +46,37 @@ jobs:
run: |
mypy opt_einsum

black:
name: Black
ruff:
name: Ruff
strategy:
fail-fast: false
matrix:
python-version: [3.12]
environment: ["min-deps"]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Python Setup
uses: actions/setup-python@v2.2.1
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.8
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channel-priority: true
activate-environment: test
environment-file: devtools/conda-envs/${{ matrix.environment }}-environment.yaml

- name: Create Environment
shell: bash
- name: Environment Information
shell: bash -l {0}
run: |
python -m pip install --upgrade pip
python -m pip install black
conda info
conda list
conda config --show-sources
conda config --show

- name: Lint
shell: bash
shell: bash -l {0}
run: |
set -e
black opt_einsum --check
make format-check
6 changes: 3 additions & 3 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Tests

on:
push:
branches: master
branches: main
pull_request:
branches: master
branches: main

jobs:
miniconda-setup:
Expand All @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: 3.9
- python-version: 3.8
environment: "min-deps"
- python-version: 3.12
environment: "min-deps"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Hatch replaces this file
opt_einsum/_version.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
9 changes: 0 additions & 9 deletions MANIFEST.in

This file was deleted.

21 changes: 5 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
.DEFAULT_GOAL := all
isort = isort opt_einsum scripts/
black = black opt_einsum scripts/
autoflake = autoflake -ir --remove-all-unused-imports --ignore-init-module-imports --remove-unused-variables opt_einsum scripts/
mypy = mypy --ignore-missing-imports opt_einsum scripts/

.PHONY: install
install:
pip install -e .

.PHONY: format
format:
$(autoflake)
$(isort)
$(black)
ruff check opt_einsum --fix
ruff format opt_einsum

.PHONY: format-check
format-check:
$(isort) --check-only
$(black) --check

.PHONY: check-dist
check-dist:
python setup.py check -ms
python setup.py sdist
twine check dist/*
ruff check opt_einsum
ruff format --check opt_einsum

.PHONY: mypy
mypy:
$(mypy)
mypy opt_einsum

.PHONY: test
test:
Expand Down
6 changes: 2 additions & 4 deletions devtools/conda-envs/full-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
dependencies:
# Base depends
- python >=3.9
- python >=3.8
- numpy >=1.23
- nomkl

Expand All @@ -15,10 +15,8 @@ dependencies:
- jax

# Testing
- autoflake
- black
- codecov
- isort
- mypy
- pytest
- pytest-cov
- ruff ==0.5.*
6 changes: 2 additions & 4 deletions devtools/conda-envs/min-deps-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ channels:
- conda-forge
dependencies:
# Base depends
- python >=3.9
- python >=3.8

# Testing
- autoflake
- black
- codecov
- isort
- mypy
- pytest
- pytest-cov
- ruff ==0.5.*
6 changes: 2 additions & 4 deletions devtools/conda-envs/min-ver-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
dependencies:
# Base depends
- python >=3.9
- python >=3.8
- numpy >=1.23
- nomkl

Expand All @@ -12,10 +12,8 @@ dependencies:
- dask ==2021.*

# Testing
- autoflake
- black
- codecov
- isort
- mypy
- pytest
- pytest-cov
- ruff ==0.5.*
6 changes: 2 additions & 4 deletions devtools/conda-envs/torch-only-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ channels:
- conda-forge
dependencies:
# Base depends
- python >=3.9
- python >=3.8
- pytorch::pytorch >=2.0,<3.0.0a
- pytorch::cpuonly
- mkl

# Testing
- autoflake
- black
- codecov
- isort
- mypy
- pytest
- pytest-cov
- ruff ==0.5.*
13 changes: 3 additions & 10 deletions opt_einsum/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
Main init function for opt_einsum.
"""
"""Main init function for opt_einsum."""

from opt_einsum import blas, helpers, path_random, paths
from opt_einsum._version import __version__
from opt_einsum.contract import contract, contract_expression, contract_path
from opt_einsum.parser import get_symbol
from opt_einsum.path_random import RandomGreedy
from opt_einsum.paths import BranchBound, DynamicProgramming
from opt_einsum.sharing import shared_intermediates

__all__ = [
"__version__",
"blas",
"helpers",
"path_random",
Expand All @@ -24,13 +24,6 @@
"shared_intermediates",
]

# Handle versioneer
from opt_einsum._version import get_versions # isort:skip

versions = get_versions()
__version__ = versions["version"]
__git_revision__ = versions["full-revisionid"]
del get_versions, versions

paths.register_path_fn("random-greedy", path_random.random_greedy)
paths.register_path_fn("random-greedy-128", path_random.random_greedy_128)
Loading
Loading