torch-ctf 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- torch_ctf-0.0.1/.copier-answers.yml +11 -0
- torch_ctf-0.0.1/.github/ISSUE_TEMPLATE.md +15 -0
- torch_ctf-0.0.1/.github/TEST_FAIL_TEMPLATE.md +12 -0
- torch_ctf-0.0.1/.github/dependabot.yml +10 -0
- torch_ctf-0.0.1/.github/workflows/ci.yml +103 -0
- torch_ctf-0.0.1/.gitignore +111 -0
- torch_ctf-0.0.1/.pre-commit-config.yaml +42 -0
- torch_ctf-0.0.1/LICENSE +28 -0
- torch_ctf-0.0.1/PKG-INFO +59 -0
- torch_ctf-0.0.1/README.md +34 -0
- torch_ctf-0.0.1/pyproject.toml +171 -0
- torch_ctf-0.0.1/src/torch_ctf/__init__.py +61 -0
- torch_ctf-0.0.1/src/torch_ctf/ctf_1d.py +194 -0
- torch_ctf-0.0.1/src/torch_ctf/ctf_2d.py +294 -0
- torch_ctf-0.0.1/src/torch_ctf/ctf_aberrations.py +297 -0
- torch_ctf-0.0.1/src/torch_ctf/ctf_ewald.py +587 -0
- torch_ctf-0.0.1/src/torch_ctf/ctf_lpp.py +634 -0
- torch_ctf-0.0.1/src/torch_ctf/ctf_utils.py +86 -0
- torch_ctf-0.0.1/src/torch_ctf/py.typed +5 -0
- torch_ctf-0.0.1/tests/test_torch_ctf.py +1747 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Do not edit - changes here will be overwritten by Copier
|
|
2
|
+
_commit: v1
|
|
3
|
+
_src_path: gh:pydev-guide/pyrepo-copier
|
|
4
|
+
author_email: jdickerson@berkeley.edu
|
|
5
|
+
author_name: Josh Dickerson
|
|
6
|
+
github_username: jdickerson95
|
|
7
|
+
mode: tooling
|
|
8
|
+
module_name: torch_ctf
|
|
9
|
+
project_name: torch-ctf
|
|
10
|
+
project_short_description: CTF calculation for cryoEM in torch
|
|
11
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
* torch-ctf version:
|
|
2
|
+
* Python version:
|
|
3
|
+
* Operating System:
|
|
4
|
+
|
|
5
|
+
### Description
|
|
6
|
+
|
|
7
|
+
Describe what you were trying to get done.
|
|
8
|
+
Tell us what happened, what went wrong, and what you expected to happen.
|
|
9
|
+
|
|
10
|
+
### What I Did
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
Paste the command(s) you ran and the output.
|
|
14
|
+
If there was a crash, please include the traceback here.
|
|
15
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "{{ env.TITLE }}"
|
|
3
|
+
labels: [bug]
|
|
4
|
+
---
|
|
5
|
+
The {{ workflow }} workflow failed on {{ date | date("YYYY-MM-DD HH:mm") }} UTC
|
|
6
|
+
|
|
7
|
+
The most recent failing test was on {{ env.PLATFORM }} py{{ env.PYTHON }}
|
|
8
|
+
with commit: {{ sha }}
|
|
9
|
+
|
|
10
|
+
Full run: https://github.com/{{ repo }}/actions/runs/{{ env.RUN_ID }}
|
|
11
|
+
|
|
12
|
+
(This post will be updated if another test fails, as long as this issue remains open.)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
2
|
+
|
|
3
|
+
version: 2
|
|
4
|
+
updates:
|
|
5
|
+
- package-ecosystem: "github-actions"
|
|
6
|
+
directory: "/"
|
|
7
|
+
schedule:
|
|
8
|
+
interval: "weekly"
|
|
9
|
+
commit-message:
|
|
10
|
+
prefix: "ci(dependabot):"
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
tags: [v*]
|
|
7
|
+
pull_request:
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
schedule:
|
|
10
|
+
# run every week (for --pre release tests)
|
|
11
|
+
- cron: "0 0 * * 0"
|
|
12
|
+
|
|
13
|
+
# cancel in-progress runs that use the same workflow and branch
|
|
14
|
+
concurrency:
|
|
15
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
16
|
+
cancel-in-progress: true
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
check-manifest:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v6
|
|
23
|
+
- run: pipx run check-manifest
|
|
24
|
+
|
|
25
|
+
test:
|
|
26
|
+
name: ${{ matrix.platform }} (${{ matrix.python-version }})
|
|
27
|
+
runs-on: ${{ matrix.platform }}
|
|
28
|
+
env:
|
|
29
|
+
UV_PRERELEASE: ${{ github.event_name == 'schedule' && 'allow' || 'if-necessary-or-explicit' }}
|
|
30
|
+
strategy:
|
|
31
|
+
fail-fast: false
|
|
32
|
+
matrix:
|
|
33
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
34
|
+
platform: [ubuntu-latest, macos-latest, windows-latest]
|
|
35
|
+
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v6
|
|
38
|
+
|
|
39
|
+
- name: ๐ Set up Python ${{ matrix.python-version }}
|
|
40
|
+
uses: astral-sh/setup-uv@v7
|
|
41
|
+
with:
|
|
42
|
+
python-version: ${{ matrix.python-version }}
|
|
43
|
+
enable-cache: true
|
|
44
|
+
|
|
45
|
+
- name: Install Dependencies
|
|
46
|
+
run: uv sync --no-dev --group test
|
|
47
|
+
|
|
48
|
+
- name: ๐งช Run Tests
|
|
49
|
+
run: uv run pytest --cov --cov-report=xml --cov-report=term-missing
|
|
50
|
+
|
|
51
|
+
# If something goes wrong with --pre tests, we can open an issue in the repo
|
|
52
|
+
- name: ๐ Report --pre Failures
|
|
53
|
+
if: failure() && github.event_name == 'schedule'
|
|
54
|
+
uses: JasonEtco/create-an-issue@v2
|
|
55
|
+
env:
|
|
56
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
57
|
+
PLATFORM: ${{ matrix.platform }}
|
|
58
|
+
PYTHON: ${{ matrix.python-version }}
|
|
59
|
+
RUN_ID: ${{ github.run_id }}
|
|
60
|
+
TITLE: "[test-bot] pip install --pre is failing"
|
|
61
|
+
with:
|
|
62
|
+
filename: .github/TEST_FAIL_TEMPLATE.md
|
|
63
|
+
update_existing: true
|
|
64
|
+
|
|
65
|
+
- name: Coverage
|
|
66
|
+
uses: codecov/codecov-action@v5
|
|
67
|
+
# with:
|
|
68
|
+
# token: ${{ secrets.CODECOV_TOKEN }}
|
|
69
|
+
|
|
70
|
+
build-and-inspect-package:
|
|
71
|
+
name: Build & inspect package.
|
|
72
|
+
needs: test
|
|
73
|
+
runs-on: ubuntu-latest
|
|
74
|
+
steps:
|
|
75
|
+
- uses: actions/checkout@v6
|
|
76
|
+
with:
|
|
77
|
+
fetch-depth: 0
|
|
78
|
+
- uses: hynek/build-and-inspect-python-package@v2
|
|
79
|
+
|
|
80
|
+
upload-to-pypi:
|
|
81
|
+
name: Upload package to PyPI
|
|
82
|
+
needs: build-and-inspect-package
|
|
83
|
+
if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule'
|
|
84
|
+
runs-on: ubuntu-latest
|
|
85
|
+
permissions:
|
|
86
|
+
# IMPORTANT: this permission is mandatory for trusted publishing on PyPi
|
|
87
|
+
# see https://docs.pypi.org/trusted-publishers/
|
|
88
|
+
id-token: write
|
|
89
|
+
# This permission allows writing releases
|
|
90
|
+
contents: write
|
|
91
|
+
|
|
92
|
+
steps:
|
|
93
|
+
- name: Download built artifact to dist/
|
|
94
|
+
uses: actions/download-artifact@v7
|
|
95
|
+
with:
|
|
96
|
+
name: Packages
|
|
97
|
+
path: dist
|
|
98
|
+
- name: ๐ข Publish to PyPI
|
|
99
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
100
|
+
- uses: softprops/action-gh-release@v2
|
|
101
|
+
with:
|
|
102
|
+
generate_release_notes: true
|
|
103
|
+
files: './dist/*'
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
env/
|
|
12
|
+
build/
|
|
13
|
+
develop-eggs/
|
|
14
|
+
dist/
|
|
15
|
+
downloads/
|
|
16
|
+
eggs/
|
|
17
|
+
.eggs/
|
|
18
|
+
lib/
|
|
19
|
+
lib64/
|
|
20
|
+
parts/
|
|
21
|
+
sdist/
|
|
22
|
+
var/
|
|
23
|
+
wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
|
|
28
|
+
.DS_Store
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
# Usually these files are written by a python script from a template
|
|
32
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
33
|
+
*.manifest
|
|
34
|
+
*.spec
|
|
35
|
+
|
|
36
|
+
# Installer logs
|
|
37
|
+
pip-log.txt
|
|
38
|
+
pip-delete-this-directory.txt
|
|
39
|
+
|
|
40
|
+
# Unit test / coverage reports
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
.hypothesis/
|
|
50
|
+
.pytest_cache/
|
|
51
|
+
|
|
52
|
+
# Translations
|
|
53
|
+
*.mo
|
|
54
|
+
*.pot
|
|
55
|
+
|
|
56
|
+
# Django stuff:
|
|
57
|
+
*.log
|
|
58
|
+
local_settings.py
|
|
59
|
+
|
|
60
|
+
# Flask stuff:
|
|
61
|
+
instance/
|
|
62
|
+
.webassets-cache
|
|
63
|
+
|
|
64
|
+
# Scrapy stuff:
|
|
65
|
+
.scrapy
|
|
66
|
+
|
|
67
|
+
# Sphinx documentation
|
|
68
|
+
docs/_build/
|
|
69
|
+
|
|
70
|
+
# PyBuilder
|
|
71
|
+
target/
|
|
72
|
+
|
|
73
|
+
# Jupyter Notebook
|
|
74
|
+
.ipynb_checkpoints
|
|
75
|
+
|
|
76
|
+
# pyenv
|
|
77
|
+
.python-version
|
|
78
|
+
|
|
79
|
+
# celery beat schedule file
|
|
80
|
+
celerybeat-schedule
|
|
81
|
+
|
|
82
|
+
# SageMath parsed files
|
|
83
|
+
*.sage.py
|
|
84
|
+
|
|
85
|
+
# dotenv
|
|
86
|
+
.env
|
|
87
|
+
|
|
88
|
+
# virtualenv
|
|
89
|
+
.venv
|
|
90
|
+
venv/
|
|
91
|
+
ENV/
|
|
92
|
+
|
|
93
|
+
# Spyder project settings
|
|
94
|
+
.spyderproject
|
|
95
|
+
.spyproject
|
|
96
|
+
|
|
97
|
+
# Rope project settings
|
|
98
|
+
.ropeproject
|
|
99
|
+
|
|
100
|
+
# mkdocs documentation
|
|
101
|
+
/site
|
|
102
|
+
|
|
103
|
+
# mypy
|
|
104
|
+
.mypy_cache/
|
|
105
|
+
|
|
106
|
+
# ruff
|
|
107
|
+
.ruff_cache/
|
|
108
|
+
|
|
109
|
+
# IDE settings
|
|
110
|
+
.vscode/
|
|
111
|
+
.idea/
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# enable pre-commit.ci at https://pre-commit.ci/
|
|
2
|
+
# it adds:
|
|
3
|
+
# 1. auto fixing pull requests
|
|
4
|
+
# 2. auto updating the pre-commit configuration
|
|
5
|
+
ci:
|
|
6
|
+
autoupdate_schedule: monthly
|
|
7
|
+
autofix_commit_msg: "style(pre-commit.ci): auto fixes [...]"
|
|
8
|
+
autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate"
|
|
9
|
+
|
|
10
|
+
repos:
|
|
11
|
+
- repo: https://github.com/abravalheri/validate-pyproject
|
|
12
|
+
rev: v0.24.1
|
|
13
|
+
hooks:
|
|
14
|
+
- id: validate-pyproject
|
|
15
|
+
|
|
16
|
+
- repo: https://github.com/rhysd/actionlint
|
|
17
|
+
rev: v1.7.7
|
|
18
|
+
hooks:
|
|
19
|
+
- id: actionlint
|
|
20
|
+
|
|
21
|
+
- repo: https://github.com/adhtruong/mirrors-typos
|
|
22
|
+
rev: v1.36.2
|
|
23
|
+
hooks:
|
|
24
|
+
- id: typos
|
|
25
|
+
args: [--force-exclude] # omitting --write-changes
|
|
26
|
+
|
|
27
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
28
|
+
rev: v0.13.0
|
|
29
|
+
hooks:
|
|
30
|
+
- id: ruff-check
|
|
31
|
+
args: [--fix] # may also add '--unsafe-fixes'
|
|
32
|
+
- id: ruff-format
|
|
33
|
+
|
|
34
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
35
|
+
rev: v1.18.1
|
|
36
|
+
hooks:
|
|
37
|
+
- id: mypy
|
|
38
|
+
files: "^src/"
|
|
39
|
+
# # you have to add the things you want to type check against here
|
|
40
|
+
# additional_dependencies:
|
|
41
|
+
# - numpy
|
|
42
|
+
|
torch_ctf-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, Josh Dickerson
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
torch_ctf-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: torch-ctf
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: CTF calculation for cryoEM in torch
|
|
5
|
+
Project-URL: homepage, https://github.com/jdickerson95/torch-ctf
|
|
6
|
+
Project-URL: repository, https://github.com/jdickerson95/torch-ctf
|
|
7
|
+
Author-email: Josh Dickerson <jdickerson@berkeley.edu>
|
|
8
|
+
License: BSD-3-Clause
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: einops
|
|
21
|
+
Requires-Dist: scipy
|
|
22
|
+
Requires-Dist: torch
|
|
23
|
+
Requires-Dist: torch-grid-utils>=v0.1.0
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# torch-ctf
|
|
27
|
+
|
|
28
|
+
[](https://github.com/jdickerson95/torch-ctf/raw/main/LICENSE)
|
|
29
|
+
[](https://pypi.org/project/torch-ctf)
|
|
30
|
+
[](https://python.org)
|
|
31
|
+
[](https://github.com/jdickerson95/torch-ctf/actions/workflows/ci.yml)
|
|
32
|
+
[](https://codecov.io/gh/jdickerson95/torch-ctf)
|
|
33
|
+
|
|
34
|
+
CTF calculation for cryoEM in torch
|
|
35
|
+
|
|
36
|
+
## Development
|
|
37
|
+
|
|
38
|
+
The easiest way to get started is to use the [github cli](https://cli.github.com)
|
|
39
|
+
and [uv](https://docs.astral.sh/uv/getting-started/installation/):
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
gh repo fork jdickerson95/torch-ctf --clone
|
|
43
|
+
# or just
|
|
44
|
+
# gh repo clone jdickerson95/torch-ctf
|
|
45
|
+
cd torch-ctf
|
|
46
|
+
uv sync
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Run tests:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
uv run pytest
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Lint files:
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
uv run pre-commit run --all-files
|
|
59
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# torch-ctf
|
|
2
|
+
|
|
3
|
+
[](https://github.com/jdickerson95/torch-ctf/raw/main/LICENSE)
|
|
4
|
+
[](https://pypi.org/project/torch-ctf)
|
|
5
|
+
[](https://python.org)
|
|
6
|
+
[](https://github.com/jdickerson95/torch-ctf/actions/workflows/ci.yml)
|
|
7
|
+
[](https://codecov.io/gh/jdickerson95/torch-ctf)
|
|
8
|
+
|
|
9
|
+
CTF calculation for cryoEM in torch
|
|
10
|
+
|
|
11
|
+
## Development
|
|
12
|
+
|
|
13
|
+
The easiest way to get started is to use the [github cli](https://cli.github.com)
|
|
14
|
+
and [uv](https://docs.astral.sh/uv/getting-started/installation/):
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
gh repo fork jdickerson95/torch-ctf --clone
|
|
18
|
+
# or just
|
|
19
|
+
# gh repo clone jdickerson95/torch-ctf
|
|
20
|
+
cd torch-ctf
|
|
21
|
+
uv sync
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Run tests:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
uv run pytest
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Lint files:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
uv run pre-commit run --all-files
|
|
34
|
+
```
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# https://peps.python.org/pep-0517/
|
|
2
|
+
[build-system]
|
|
3
|
+
requires = ["hatchling", "hatch-vcs"]
|
|
4
|
+
build-backend = "hatchling.build"
|
|
5
|
+
|
|
6
|
+
# https://hatch.pypa.io/latest/config/metadata/
|
|
7
|
+
[tool.hatch.version]
|
|
8
|
+
source = "vcs"
|
|
9
|
+
|
|
10
|
+
# read more about configuring hatch at:
|
|
11
|
+
# https://hatch.pypa.io/latest/config/build/
|
|
12
|
+
[tool.hatch.build.targets.wheel]
|
|
13
|
+
only-include = ["src"]
|
|
14
|
+
sources = ["src"]
|
|
15
|
+
|
|
16
|
+
# https://peps.python.org/pep-0621/
|
|
17
|
+
[project]
|
|
18
|
+
name = "torch-ctf"
|
|
19
|
+
dynamic = ["version"]
|
|
20
|
+
description = "CTF calculation for cryoEM in torch"
|
|
21
|
+
readme = "README.md"
|
|
22
|
+
requires-python = ">=3.10"
|
|
23
|
+
license = { text = "BSD-3-Clause" }
|
|
24
|
+
authors = [{ name = "Josh Dickerson", email = "jdickerson@berkeley.edu" }]
|
|
25
|
+
# https://pypi.org/classifiers/
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Development Status :: 3 - Alpha",
|
|
28
|
+
"License :: OSI Approved :: BSD License",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Python :: 3.10",
|
|
31
|
+
"Programming Language :: Python :: 3.11",
|
|
32
|
+
"Programming Language :: Python :: 3.12",
|
|
33
|
+
"Programming Language :: Python :: 3.13",
|
|
34
|
+
"Programming Language :: Python :: 3.14",
|
|
35
|
+
"Typing :: Typed",
|
|
36
|
+
]
|
|
37
|
+
# add your package dependencies here
|
|
38
|
+
dependencies = [
|
|
39
|
+
"torch",
|
|
40
|
+
"scipy",
|
|
41
|
+
"einops",
|
|
42
|
+
"torch-grid-utils>=v0.1.0",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
|
|
46
|
+
# add dependencies for "extra" features here. Not dev dependencies.
|
|
47
|
+
# [project.optional-dependencies]
|
|
48
|
+
# name = ["dependency"]
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
homepage = "https://github.com/jdickerson95/torch-ctf"
|
|
52
|
+
repository = "https://github.com/jdickerson95/torch-ctf"
|
|
53
|
+
|
|
54
|
+
# Entry points
|
|
55
|
+
# https://peps.python.org/pep-0621/#entry-points
|
|
56
|
+
# same as console_scripts entry point
|
|
57
|
+
# [project.scripts]
|
|
58
|
+
# torch-ctf-cli = "torch_ctf:main_cli"
|
|
59
|
+
|
|
60
|
+
# [project.entry-points."some.group"]
|
|
61
|
+
# tomatoes = "torch_ctf:main_tomatoes"
|
|
62
|
+
|
|
63
|
+
# https://peps.python.org/pep-0735/
|
|
64
|
+
# setup with `uv sync` or `pip install -e . --group dev`
|
|
65
|
+
[dependency-groups]
|
|
66
|
+
test = ["pytest", "pytest-cov"]
|
|
67
|
+
dev = [
|
|
68
|
+
{ include-group = "test" },
|
|
69
|
+
"ipython",
|
|
70
|
+
"mypy",
|
|
71
|
+
"pdbpp", # https://github.com/pdbpp/pdbpp
|
|
72
|
+
"pre-commit-uv",
|
|
73
|
+
"rich", # https://github.com/Textualize/rich
|
|
74
|
+
"ruff",
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
[tool.uv.sources]
|
|
78
|
+
torch-ctf = { workspace = true }
|
|
79
|
+
|
|
80
|
+
# https://docs.astral.sh/ruff
|
|
81
|
+
[tool.ruff]
|
|
82
|
+
line-length = 88
|
|
83
|
+
target-version = "py310"
|
|
84
|
+
src = ["src"]
|
|
85
|
+
fix = true
|
|
86
|
+
# unsafe-fixes = true
|
|
87
|
+
|
|
88
|
+
[tool.ruff.lint]
|
|
89
|
+
pydocstyle = { convention = "numpy" }
|
|
90
|
+
select = [
|
|
91
|
+
"E", # style errors
|
|
92
|
+
"W", # style warnings
|
|
93
|
+
"F", # flakes
|
|
94
|
+
"D", # pydocstyle
|
|
95
|
+
"D417", # Missing argument descriptions in Docstrings
|
|
96
|
+
"I", # isort
|
|
97
|
+
"UP", # pyupgrade
|
|
98
|
+
"C4", # flake8-comprehensions
|
|
99
|
+
"B", # flake8-bugbear
|
|
100
|
+
"A001", # flake8-builtins
|
|
101
|
+
"RUF", # ruff-specific rules
|
|
102
|
+
"TC", # flake8-type-checking
|
|
103
|
+
"TID", # flake8-tidy-imports
|
|
104
|
+
]
|
|
105
|
+
ignore = [
|
|
106
|
+
"D401", # First line should be in imperative mood (remove to opt in)
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
[tool.ruff.lint.per-file-ignores]
|
|
110
|
+
"tests/*.py" = ["D", "S"]
|
|
111
|
+
"docs/*.py" = ["D", "A"]
|
|
112
|
+
"src/torch_ctf/ctf_lpp.py" = ["RUF002", "RUF003"]
|
|
113
|
+
|
|
114
|
+
# https://docs.astral.sh/ruff/formatter/
|
|
115
|
+
[tool.ruff.format]
|
|
116
|
+
docstring-code-format = true
|
|
117
|
+
skip-magic-trailing-comma = false # default is false
|
|
118
|
+
|
|
119
|
+
# https://docs.pytest.org/
|
|
120
|
+
[tool.pytest.ini_options]
|
|
121
|
+
minversion = "7.0"
|
|
122
|
+
addopts = ["--color=yes"]
|
|
123
|
+
testpaths = ["tests"]
|
|
124
|
+
filterwarnings = ["error"]
|
|
125
|
+
|
|
126
|
+
# https://mypy.readthedocs.io/en/stable/config_file.html
|
|
127
|
+
[tool.mypy]
|
|
128
|
+
files = "src/**/"
|
|
129
|
+
strict = true
|
|
130
|
+
disallow_any_generics = false
|
|
131
|
+
disallow_subclassing_any = false
|
|
132
|
+
show_error_codes = true
|
|
133
|
+
pretty = true
|
|
134
|
+
# plugins = ["pydantic.mypy"]
|
|
135
|
+
|
|
136
|
+
# # module specific overrides
|
|
137
|
+
# [[tool.mypy.overrides]]
|
|
138
|
+
# module = ["numpy.*",]
|
|
139
|
+
# ignore_errors = true
|
|
140
|
+
|
|
141
|
+
# https://coverage.readthedocs.io/
|
|
142
|
+
[tool.coverage.report]
|
|
143
|
+
show_missing = true
|
|
144
|
+
exclude_lines = [
|
|
145
|
+
"pragma: no cover",
|
|
146
|
+
"if TYPE_CHECKING:",
|
|
147
|
+
"@overload",
|
|
148
|
+
"except ImportError",
|
|
149
|
+
"raise AssertionError",
|
|
150
|
+
"\\.\\.\\.",
|
|
151
|
+
"raise NotImplementedError()",
|
|
152
|
+
"pass",
|
|
153
|
+
]
|
|
154
|
+
|
|
155
|
+
[tool.coverage.run]
|
|
156
|
+
source = ["torch_ctf"]
|
|
157
|
+
|
|
158
|
+
# https://github.com/mgedmin/check-manifest#configuration
|
|
159
|
+
# add files that you want check-manifest to explicitly ignore here
|
|
160
|
+
# (files that are in the repo but shouldn't go in the package)
|
|
161
|
+
[tool.check-manifest]
|
|
162
|
+
ignore = [
|
|
163
|
+
".pre-commit-config.yaml",
|
|
164
|
+
".ruff_cache/**/*",
|
|
165
|
+
"tests/**/*",
|
|
166
|
+
"uv.lock",
|
|
167
|
+
]
|
|
168
|
+
|
|
169
|
+
# https://github.com/crate-ci/typos/blob/master/docs/reference.md
|
|
170
|
+
[tool.typos.default]
|
|
171
|
+
extend-ignore-identifiers-re = []
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""CTF calculation for cryoEM in torch."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
|
|
5
|
+
from torch_ctf.ctf_1d import calculate_ctf_1d
|
|
6
|
+
from torch_ctf.ctf_2d import calculate_ctf_2d
|
|
7
|
+
from torch_ctf.ctf_aberrations import (
|
|
8
|
+
apply_even_zernikes,
|
|
9
|
+
apply_odd_zernikes,
|
|
10
|
+
beam_tilt_to_zernike_coeffs,
|
|
11
|
+
calculate_defocus_phase_aberration,
|
|
12
|
+
calculate_relativistic_electron_wavelength,
|
|
13
|
+
resolve_odd_zernikes,
|
|
14
|
+
)
|
|
15
|
+
from torch_ctf.ctf_ewald import calculate_ctfp_and_ctfq_2d, get_ctf_weighting
|
|
16
|
+
from torch_ctf.ctf_lpp import (
|
|
17
|
+
calc_LPP_ctf_2D,
|
|
18
|
+
calc_LPP_phase,
|
|
19
|
+
calculate_relativistic_beta,
|
|
20
|
+
calculate_relativistic_gamma,
|
|
21
|
+
get_eta,
|
|
22
|
+
get_eta0_from_peak_phase_deg,
|
|
23
|
+
initialize_laser_params,
|
|
24
|
+
make_laser_coords,
|
|
25
|
+
)
|
|
26
|
+
from torch_ctf.ctf_utils import (
|
|
27
|
+
calculate_additional_phase_shift,
|
|
28
|
+
calculate_amplitude_contrast_equivalent_phase_shift,
|
|
29
|
+
calculate_total_phase_shift,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
__version__ = version("torch-ctf")
|
|
34
|
+
except PackageNotFoundError:
|
|
35
|
+
__version__ = "uninstalled"
|
|
36
|
+
__author__ = "Josh Dickerson"
|
|
37
|
+
__email__ = "jdickerson@berkeley.edu"
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
40
|
+
"apply_even_zernikes",
|
|
41
|
+
"apply_odd_zernikes",
|
|
42
|
+
"beam_tilt_to_zernike_coeffs",
|
|
43
|
+
"calc_LPP_ctf_2D",
|
|
44
|
+
"calc_LPP_phase",
|
|
45
|
+
"calculate_additional_phase_shift",
|
|
46
|
+
"calculate_amplitude_contrast_equivalent_phase_shift",
|
|
47
|
+
"calculate_ctf_1d",
|
|
48
|
+
"calculate_ctf_2d",
|
|
49
|
+
"calculate_ctfp_and_ctfq_2d",
|
|
50
|
+
"calculate_defocus_phase_aberration",
|
|
51
|
+
"calculate_relativistic_beta",
|
|
52
|
+
"calculate_relativistic_electron_wavelength",
|
|
53
|
+
"calculate_relativistic_gamma",
|
|
54
|
+
"calculate_total_phase_shift",
|
|
55
|
+
"get_ctf_weighting",
|
|
56
|
+
"get_eta",
|
|
57
|
+
"get_eta0_from_peak_phase_deg",
|
|
58
|
+
"initialize_laser_params",
|
|
59
|
+
"make_laser_coords",
|
|
60
|
+
"resolve_odd_zernikes",
|
|
61
|
+
]
|