Skip to content

Commit e8aad83

Browse files
committed
feat: 🎉 initial public-ready source of the SRC method
Successive Randomized Compression for MPS/MPO tensor networks, with CPU (NumPy) and GPU (CuPy) backends. Published under Apache-2.0 with a contributor licence agreement.
0 parents  commit e8aad83

64 files changed

Lines changed: 7964 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.devcontainer/Dockerfile‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM ghcr.io/astral-sh/uv:latest AS uv
2+
3+
FROM mcr.microsoft.com/devcontainers/base:1.2.5-noble
4+
5+
COPY --from=uv --chown=vscode: /uv /uvx /bin/
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "src_method development environment",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"remoteUser": "vscode",
7+
"customizations": {
8+
"vscode": {
9+
"settings": {
10+
"python.defaultInterpreterPath": "/home/vscode/.venv/bin/python",
11+
"python.terminal.activateEnvInCurrentTerminal": true,
12+
"terminal.integrated.defaultProfile.linux": "zsh",
13+
"terminal.integrated.profiles.linux": {
14+
"zsh": {
15+
"path": "/bin/zsh"
16+
}
17+
}
18+
},
19+
"extensions": [
20+
"MS-vsliveshare.vsliveshare",
21+
"charliermarsh.ruff",
22+
"ms-python.python",
23+
"ms-toolsai.jupyter",
24+
"mutantdino.resourcemonitor",
25+
"njpwerner.autodocstring",
26+
"streetsidesoftware.code-spell-checker",
27+
"streetsidesoftware.code-spell-checker-scientific-terms",
28+
"tamasfe.even-better-toml",
29+
"vivaxy.vscode-conventional-commits"
30+
]
31+
}
32+
},
33+
"containerEnv": {
34+
"PYTHONUNBUFFERED": "True",
35+
"WORKSPACE": "${containerWorkspaceFolder}",
36+
"UV_LINK_MODE": "copy",
37+
"UV_PROJECT_ENVIRONMENT": "/home/vscode/.venv"
38+
},
39+
"postCreateCommand": "./.devcontainer/postCreateCommand.sh",
40+
"postStartCommand": "./.devcontainer/postStartCommand.sh",
41+
"hostRequirements": {
42+
"cpus": 4,
43+
"memory": "6gb"
44+
}
45+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
6+
# install uv and uvx shell completions
7+
echo 'eval "$(uv generate-shell-completion zsh)"' >> /home/vscode/.zshrc
8+
echo 'eval "$(uvx --generate-shell-completion zsh)"' >> /home/vscode/.zshrc
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
4+
# install project with all dependencies (no GPU extras in devcontainer)
5+
uv sync --all-groups
6+
7+
# install pre-commit hooks
8+
uv run pre-commit install --install-hooks

‎.git_archival.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$

‎.gitattributes‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Keep GitHub's language statistics meaningful for a pure-Python project.
2+
*.py linguist-language=Python
3+
docs/* linguist-documentation
4+
benches/* linguist-documentation
5+
*.md linguist-documentation
6+
*.js linguist-detectable=false
7+
*.css linguist-detectable=false
8+
9+
# Mark generated files.
10+
**/generated/* linguist-generated=true
11+
12+
# Binary assets.
13+
*.png binary
14+
15+
# Substituted at `git archive` time so hatch-vcs can derive a version from a
16+
# tarball that has no .git directory.
17+
.git_archival.txt export-subst
18+
.gitignore export-ignore
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Project Overview
2+
3+
`src_method` is a Python package, designed for quantum computing applications.
4+
5+
## General Instructions
6+
7+
- Always prioritize readability and clarity.
8+
- For algorithm-related code, include explanations of the approach used.
9+
- Write code with good maintainability practices, including comments on why certain design decisions were made.
10+
- Handle edge cases and write clear exception handling.
11+
- For libraries or external dependencies, mention their usage and purpose in comments.
12+
- Use consistent naming conventions and follow language-specific best practices.
13+
- Write concise, efficient, and idiomatic code that is also easily understandable.
14+
- Use conventional commits (ideally with gitmojis) for commit messages.
15+
16+
## Python Coding Conventions
17+
18+
### Python Instructions
19+
20+
- Write code to support Python 3.11, 3.12, 3.13.
21+
- Write clear and concise comments for each function.
22+
- Ensure functions have descriptive names and include type hints.
23+
- Provide docstrings following PEP 257 conventions.
24+
- Use Google-style docstrings without type annotations (types handled by type hints).
25+
- Use the `typing` module for type annotations (e.g., `list[str]`, `dict[str, int]`).
26+
- Break down complex functions into smaller, more manageable functions.
27+
28+
### Code Style and Formatting
29+
30+
- Follow the PEP 8 style guide for Python.
31+
- Maintain proper indentation (use 4 spaces for each level of indentation).
32+
- Ensure lines do not exceed 79 characters.
33+
- Place function and class docstrings immediately after the `def` or `class` keyword.
34+
- Use blank lines to separate functions, classes, and code blocks where appropriate.
35+
36+
### Edge Cases and Testing
37+
38+
- Always include test cases for critical paths of the application.
39+
- Account for common edge cases like empty inputs, invalid data types, and large datasets.
40+
- Include comments for edge cases and the expected behavior in those cases.
41+
- Write unit tests for functions and document them with docstrings explaining the test cases.
42+
- Use `pytest` to run tests.
43+
44+
### Example of Proper Documentation
45+
46+
```python
47+
def calculate_area(radius: float) -> float:
48+
"""Calculate the area of a circle given the radius.
49+
50+
Args:
51+
radius: The radius of the circle.
52+
53+
Returns:
54+
The area of the circle, calculated as π * radius^2.
55+
"""
56+
import math
57+
return math.pi * radius ** 2
58+
```
59+
60+
## Development Commands
61+
62+
### Environment Setup
63+
64+
- Use `uv` for dependency management.
65+
- Create the virtual environment with `uv sync --all-groups --all-extras`.
66+
- Install `pre-commit` hooks to ensure code quality:
67+
```bash
68+
uv run pre-commit install --install-hooks
69+
```
70+
71+
### Code Quality
72+
73+
- Use `uv run ruff check src/ tests/` for linting.
74+
- Use `uv run ruff format src/ tests/` for formatting.
75+
- Use `uv run pre-commit run --all-files` to ensure code quality.
76+
77+
### Testing
78+
79+
- Run the fast tests with `uv run pytest -m "not slow"`
80+
- Run the slow tests with `uv run pytest -m "slow"`
81+
- Run the whole test suite with `uv run pytest`

‎.github/dependabot.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
# maintain dependencies for Python
9+
- package-ecosystem: "uv"
10+
directory: "/" # Location of package manifests
11+
# run on the 1st and 15th day of the month
12+
schedule:
13+
interval: "cron"
14+
cronjob: "0 3 1,15 * *"
15+
open-pull-requests-limit: 10
16+
ignore:
17+
# for all dependencies, ignore all patch updates
18+
- dependency-name: "*"
19+
update-types: ["version-update:semver-patch"]
20+
21+
# maintain dependencies for GitHub Actions
22+
- package-ecosystem: "github-actions"
23+
directory: "/"
24+
schedule:
25+
interval: "monthly"
26+
27+
# maintain dependencies for DevContainer
28+
- package-ecosystem: "devcontainers"
29+
directory: "/"
30+
schedule:
31+
interval: "monthly"

‎.github/release.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
changelog:
2+
exclude:
3+
authors:
4+
- dependabot
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "Copilot Setup Steps"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- .github/workflows/copilot-setup-steps.yml
8+
pull_request:
9+
paths:
10+
- .github/workflows/copilot-setup-steps.yml
11+
12+
jobs:
13+
# the job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
14+
copilot-setup-steps:
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
contents: read
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v6
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Install the latest version of uv
27+
uses: astral-sh/setup-uv@v7
28+
with:
29+
enable-cache: true
30+
python-version: "3.11"
31+
32+
- name: Install package
33+
run: |
34+
uv sync --all-groups

0 commit comments

Comments
 (0)