fockit 0.0.2__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.
Files changed (44) hide show
  1. fockit-0.0.2/.gitignore +48 -0
  2. fockit-0.0.2/LICENSE +21 -0
  3. fockit-0.0.2/PKG-INFO +83 -0
  4. fockit-0.0.2/README.md +61 -0
  5. fockit-0.0.2/pyproject.toml +138 -0
  6. fockit-0.0.2/src/fockit/__init__.py +53 -0
  7. fockit-0.0.2/src/fockit/_types.py +48 -0
  8. fockit-0.0.2/src/fockit/_version.py +24 -0
  9. fockit-0.0.2/src/fockit/algebra.py +275 -0
  10. fockit-0.0.2/src/fockit/constructors.py +280 -0
  11. fockit-0.0.2/src/fockit/converters.py +52 -0
  12. fockit-0.0.2/src/fockit/display.py +150 -0
  13. fockit-0.0.2/src/fockit/inspection.py +60 -0
  14. fockit-0.0.2/src/fockit/normal_order.py +142 -0
  15. fockit-0.0.2/src/fockit/operators.py +318 -0
  16. fockit-0.0.2/src/fockit/py.typed +0 -0
  17. fockit-0.0.2/src/fockit/simplify.py +89 -0
  18. fockit-0.0.2/src/fockit/solve/__init__.py +67 -0
  19. fockit-0.0.2/src/fockit/solve/basis.py +822 -0
  20. fockit-0.0.2/src/fockit/solve/diagonalize.py +96 -0
  21. fockit-0.0.2/src/fockit/solve/evolve.py +326 -0
  22. fockit-0.0.2/src/fockit/solve/matrix.py +88 -0
  23. fockit-0.0.2/src/fockit/solve/spaces.py +134 -0
  24. fockit-0.0.2/src/fockit/solve/thermal.py +196 -0
  25. fockit-0.0.2/src/fockit/transforms.py +151 -0
  26. fockit-0.0.2/tests/__init__.py +0 -0
  27. fockit-0.0.2/tests/solve/conftest.py +4 -0
  28. fockit-0.0.2/tests/solve/test_boson.py +46 -0
  29. fockit-0.0.2/tests/solve/test_evolve.py +236 -0
  30. fockit-0.0.2/tests/solve/test_fermion.py +271 -0
  31. fockit-0.0.2/tests/solve/test_mixed.py +67 -0
  32. fockit-0.0.2/tests/solve/test_pauli.py +65 -0
  33. fockit-0.0.2/tests/solve/test_sector_restriction.py +176 -0
  34. fockit-0.0.2/tests/solve/test_symmetries.py +533 -0
  35. fockit-0.0.2/tests/solve/test_thermal.py +191 -0
  36. fockit-0.0.2/tests/test_constructors.py +25 -0
  37. fockit-0.0.2/tests/test_converters.py +57 -0
  38. fockit-0.0.2/tests/test_display.py +104 -0
  39. fockit-0.0.2/tests/test_inspection.py +22 -0
  40. fockit-0.0.2/tests/test_integration.py +221 -0
  41. fockit-0.0.2/tests/test_normal_order.py +104 -0
  42. fockit-0.0.2/tests/test_operators.py +48 -0
  43. fockit-0.0.2/tests/test_simplify.py +32 -0
  44. fockit-0.0.2/tests/test_transforms.py +64 -0
@@ -0,0 +1,48 @@
1
+ # Byte-compiled / cache
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Virtual environments
10
+ venv/
11
+ .env/
12
+ .venv/
13
+ env/
14
+ ENV/
15
+
16
+ .env
17
+ .env.*
18
+
19
+ # Pytest
20
+ .pytest_cache/
21
+
22
+ # Coverage reports
23
+ .coverage
24
+ .coverage.*
25
+ htmlcov/
26
+
27
+ # Distribution / packaging
28
+ build/
29
+ dist/
30
+ *.egg-info/
31
+ .eggs/
32
+ *.egg
33
+
34
+ # mypy
35
+ .mypy_cache/
36
+
37
+ # Ruff / flake8 / pylint caches
38
+ .ruff_cache/
39
+
40
+ *.log
41
+ *.tmp
42
+ *.swp
43
+
44
+ # macOS
45
+ .DS_Store
46
+
47
+ # project specific
48
+ src/fockit/_version.py
fockit-0.0.2/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Henry L. Nourse
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
fockit-0.0.2/PKG-INFO ADDED
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.4
2
+ Name: fockit
3
+ Version: 0.0.2
4
+ Summary: Build many-body models, write your own operator algebras, and test algorithms on them
5
+ Project-URL: Homepage, https://github.com/thenoursehorse/fockit
6
+ Author: Henry L. Nourse
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: algebra,bosons,fermions,many-body,operator,quantum,spins
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Topic :: Scientific/Engineering
15
+ Requires-Python: >=3.14
16
+ Provides-Extra: solve
17
+ Requires-Dist: numpy>=1.26; extra == 'solve'
18
+ Requires-Dist: scipy>=1.11.4; extra == 'solve'
19
+ Provides-Extra: sympy
20
+ Requires-Dist: sympy>=1.12; extra == 'sympy'
21
+ Description-Content-Type: text/markdown
22
+
23
+ # fockit - Quantum many-body operators and solvers
24
+
25
+ Copyright (C) 2026 H. L. Nourse
26
+
27
+ ## What is fockit?
28
+
29
+ Build many-body models, write your own operator algebras, and test algorithms
30
+ on them. Quick and simple.
31
+
32
+ Comes with fermions, bosons and Pauli operators, and you can add your own.
33
+ Simple exact solvers check your ideas on small systems.
34
+
35
+ ## Where to start?
36
+
37
+ The tests are examples:
38
+
39
+ - `tests/test_integration.py` for the operator algebra.
40
+ - `tests/solve/` for matrices and solvers.
41
+ - `tests/solve/test_symmetries.py` for symmetry sectors (momentum, reflection,
42
+ spin flip, spin inversion, particle-hole, point groups).
43
+
44
+ ## Dependencies
45
+
46
+ - [python](https://www.python.org/) version `>= 3.12`
47
+ - [numpy](https://numpy.org/) and [scipy](https://scipy.org/) for the solvers
48
+ - [sympy](https://www.sympy.org/) for symbolic coefficients (optional)
49
+
50
+ ## Installation
51
+
52
+ Clone source
53
+
54
+ ```shell
55
+ git clone https://github.com/thenoursehorse/fockit
56
+ cd fockit
57
+ ```
58
+
59
+ Install with [uv](https://docs.astral.sh/uv)
60
+
61
+ ```shell
62
+ uv sync --extra solve
63
+ ```
64
+
65
+ Add `--extra sympy` for symbolic coefficients.
66
+
67
+ ## Tests
68
+
69
+ ```shell
70
+ uv sync --group test --extra sympy --extra solve
71
+ uv run pytest
72
+ ```
73
+
74
+ ## Development
75
+
76
+ ```shell
77
+ uv sync --group all --extra sympy --extra solve
78
+ ```
79
+
80
+ ## AI use
81
+
82
+ This code was written with AI coding assistants (Claude Code and Codex). All of
83
+ it is reviewed and tested.
fockit-0.0.2/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # fockit - Quantum many-body operators and solvers
2
+
3
+ Copyright (C) 2026 H. L. Nourse
4
+
5
+ ## What is fockit?
6
+
7
+ Build many-body models, write your own operator algebras, and test algorithms
8
+ on them. Quick and simple.
9
+
10
+ Comes with fermions, bosons and Pauli operators, and you can add your own.
11
+ Simple exact solvers check your ideas on small systems.
12
+
13
+ ## Where to start?
14
+
15
+ The tests are examples:
16
+
17
+ - `tests/test_integration.py` for the operator algebra.
18
+ - `tests/solve/` for matrices and solvers.
19
+ - `tests/solve/test_symmetries.py` for symmetry sectors (momentum, reflection,
20
+ spin flip, spin inversion, particle-hole, point groups).
21
+
22
+ ## Dependencies
23
+
24
+ - [python](https://www.python.org/) version `>= 3.12`
25
+ - [numpy](https://numpy.org/) and [scipy](https://scipy.org/) for the solvers
26
+ - [sympy](https://www.sympy.org/) for symbolic coefficients (optional)
27
+
28
+ ## Installation
29
+
30
+ Clone source
31
+
32
+ ```shell
33
+ git clone https://github.com/thenoursehorse/fockit
34
+ cd fockit
35
+ ```
36
+
37
+ Install with [uv](https://docs.astral.sh/uv)
38
+
39
+ ```shell
40
+ uv sync --extra solve
41
+ ```
42
+
43
+ Add `--extra sympy` for symbolic coefficients.
44
+
45
+ ## Tests
46
+
47
+ ```shell
48
+ uv sync --group test --extra sympy --extra solve
49
+ uv run pytest
50
+ ```
51
+
52
+ ## Development
53
+
54
+ ```shell
55
+ uv sync --group all --extra sympy --extra solve
56
+ ```
57
+
58
+ ## AI use
59
+
60
+ This code was written with AI coding assistants (Claude Code and Codex). All of
61
+ it is reviewed and tested.
@@ -0,0 +1,138 @@
1
+ [project]
2
+ name = "fockit"
3
+ dynamic = ["version"]
4
+ description = "Build many-body models, write your own operator algebras, and test algorithms on them"
5
+ readme = "README.md"
6
+ requires-python = ">=3.14"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ keywords = ["quantum", "many-body", "operator", "algebra", "fermions", "bosons", "spins"]
10
+ authors = [
11
+ {name = "Henry L. Nourse"},
12
+ ]
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.14",
16
+ "Operating System :: OS Independent",
17
+ "Intended Audience :: Science/Research",
18
+ "Topic :: Scientific/Engineering",
19
+ ]
20
+
21
+ [project.urls]
22
+ Homepage = "https://github.com/thenoursehorse/fockit"
23
+
24
+ [project.optional-dependencies]
25
+ sympy = [
26
+ "sympy>=1.12",
27
+ ]
28
+ solve = [
29
+ "numpy>=1.26",
30
+ "scipy>=1.11.4",
31
+ ]
32
+
33
+ [build-system]
34
+ # hatchling 1.32 writes metadata 2.5, which twine doesn't accept yet
35
+ requires = ["hatchling<1.32", "hatch-vcs"]
36
+ build-backend = "hatchling.build"
37
+
38
+ [tool.hatch]
39
+ version.source = "vcs"
40
+ build.hooks.vcs.version-file = "src/fockit/_version.py"
41
+ build.targets.sdist.include = ["src", "tests", "README.md", "LICENSE", "pyproject.toml"]
42
+ metadata.allow-direct-references = true
43
+
44
+ [dependency-groups]
45
+ test = [
46
+ "pytest>=8.3",
47
+ "pytest-subtests>=0.14",
48
+ "pytest-cov>=6.0",
49
+ ]
50
+ dev = [
51
+ { include-group = "test" },
52
+ "pre-commit>=4.0",
53
+ "ruff>=0.8.0",
54
+ "mypy>=1.13",
55
+ ]
56
+ all = [
57
+ {include-group = "test"},
58
+ {include-group = "dev"},
59
+ ]
60
+
61
+ [tool.pytest]
62
+ minversion = "8.3"
63
+ addopts = ["-ra", "--showlocals"]
64
+ strict = true
65
+ filterwarnings = ["error"]
66
+ log_level = "INFO"
67
+ testpaths = [
68
+ "tests",
69
+ ]
70
+
71
+ [tool.ruff]
72
+ src = ["src"]
73
+ target-version = "py314"
74
+ line-length = 88
75
+ extend-exclude = ["src/fockit/_version.py"]
76
+
77
+ [tool.ruff.format]
78
+ docstring-code-format = true
79
+ quote-style = "double"
80
+ indent-style = "space"
81
+
82
+ [tool.ruff.lint]
83
+ extend-select = [
84
+ "B", # flake8-bugbear
85
+ "I", # isort
86
+ "E", # pycodestyle errors
87
+ "F", # pyflakes (bugs)
88
+ "ARG", # flake8-unused-arguments
89
+ "C4", # flake8-comprehensions
90
+ "EM", # flake8-errmsg
91
+ "ICN", # flake8-import-conventions
92
+ "PGH", # pygrep-hooks
93
+ "PIE", # flake8-pie
94
+ "PL", # pylint
95
+ "PT", # flake8-pytest-style
96
+ "PTH", # flake8-use-pathlib
97
+ "RET", # flake8-return
98
+ "RUF", # Ruff-specific
99
+ "SIM", # flake8-simplify
100
+ "TID251", # flake8-tidy-imports.banned-api
101
+ "T20", # flake8-print
102
+ "UP", # pyupgrade
103
+ "YTT", # flake8-2020
104
+ "D", # pydocstyle
105
+ "D204", # one-blank-line-after-class
106
+ "D301", # escape-sequence-in-docstring
107
+ "D413", # blank-line-after-last-section
108
+ "UP", # pyupgrade (modern Python)
109
+ ]
110
+ ignore = [
111
+ "PLR", # Design related pylint codes
112
+ "PLC0415", # allow lazy imports (not at top of file)
113
+ "RUF012", # Would require a lot of ClassVar's
114
+ "D417", # remove documentation requirement for all functions
115
+ ]
116
+ allowed-confusables = ["σ"]
117
+
118
+ [tool.ruff.lint.per-file-ignores]
119
+ "tests/*" = ["D"]
120
+
121
+ [tool.ruff.lint.pycodestyle]
122
+ max-doc-length = 75
123
+ max-line-length = 88
124
+
125
+ [tool.ruff.lint.pydocstyle]
126
+ convention = "numpy"
127
+
128
+ [tool.mypy]
129
+ files = "src"
130
+ python_version = "3.14"
131
+ strict = true
132
+ show_error_codes = true
133
+ enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
134
+ warn_unreachable = true
135
+
136
+ [[tool.mypy.overrides]]
137
+ module = ["scipy.*", "sympy.*", "triqs.*"]
138
+ ignore_missing_imports = true
@@ -0,0 +1,53 @@
1
+ """Symbolic operator algebra for fermions, bosons, and beyond."""
2
+
3
+ from fockit.constructors import (
4
+ b,
5
+ bdag,
6
+ c,
7
+ cdag,
8
+ n,
9
+ nb,
10
+ sigma_x,
11
+ sigma_y,
12
+ sigma_z,
13
+ sm,
14
+ sp,
15
+ )
16
+ from fockit.display import to_latex, to_text
17
+ from fockit.inspection import degree, modes, num_terms
18
+ from fockit.normal_order import is_normal_ordered, normal_order
19
+ from fockit.operators import (
20
+ identity,
21
+ zero,
22
+ )
23
+ from fockit.simplify import drop_zeros, simplify_coeffs
24
+ from fockit.transforms import anticommutator, commutator, hc, substitute_modes
25
+
26
+ __all__ = [
27
+ "anticommutator",
28
+ "b",
29
+ "bdag",
30
+ "c",
31
+ "cdag",
32
+ "commutator",
33
+ "degree",
34
+ "drop_zeros",
35
+ "hc",
36
+ "identity",
37
+ "is_normal_ordered",
38
+ "modes",
39
+ "n",
40
+ "nb",
41
+ "normal_order",
42
+ "num_terms",
43
+ "sigma_x",
44
+ "sigma_y",
45
+ "sigma_z",
46
+ "simplify_coeffs",
47
+ "sm",
48
+ "sp",
49
+ "substitute_modes",
50
+ "to_latex",
51
+ "to_text",
52
+ "zero",
53
+ ]
@@ -0,0 +1,48 @@
1
+ """Shared typing helpers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Hashable
6
+ from typing import Protocol, SupportsComplex, SupportsFloat, SupportsIndex, cast
7
+
8
+ type Mode = Hashable
9
+
10
+
11
+ class SymbolicCoefficient(Protocol):
12
+ """Protocol for symbolic coefficient objects."""
13
+
14
+ def __hash__(self) -> int: ...
15
+
16
+ def __add__(self, other: object, /) -> object: ...
17
+
18
+ def __radd__(self, other: object, /) -> object: ...
19
+
20
+ def __sub__(self, other: object, /) -> object: ...
21
+
22
+ def __rsub__(self, other: object, /) -> object: ...
23
+
24
+ def __mul__(self, other: object, /) -> object: ...
25
+
26
+ def __rmul__(self, other: object, /) -> object: ...
27
+
28
+ def __neg__(self) -> object: ...
29
+
30
+ def __abs__(self) -> object: ...
31
+
32
+ def __eq__(self, other: object, /) -> bool: ...
33
+
34
+ def conjugate(self) -> object: ...
35
+
36
+
37
+ type Coefficient = int | float | complex | SymbolicCoefficient
38
+ type ComplexConvertible = complex | SupportsComplex | SupportsFloat | SupportsIndex
39
+
40
+
41
+ def as_coefficient(value: object) -> Coefficient:
42
+ """Cast a coefficient result back to ``Coefficient``."""
43
+ return cast(Coefficient, value)
44
+
45
+
46
+ def as_complex(value: Coefficient) -> complex:
47
+ """Convert a coefficient to ``complex``."""
48
+ return complex(cast(ComplexConvertible, value))
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.0.2'
22
+ __version_tuple__ = version_tuple = (0, 0, 2)
23
+
24
+ __commit_id__ = commit_id = None