gridstate 0.1.0__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.
- gridstate-0.1.0/.github/workflows/ci.yml +101 -0
- gridstate-0.1.0/.github/workflows/release.yml +76 -0
- gridstate-0.1.0/.gitignore +100 -0
- gridstate-0.1.0/.pre-commit-config.yaml +40 -0
- gridstate-0.1.0/CHANGELOG.md +12 -0
- gridstate-0.1.0/LICENSE +91 -0
- gridstate-0.1.0/Makefile +83 -0
- gridstate-0.1.0/PKG-INFO +199 -0
- gridstate-0.1.0/README.md +148 -0
- gridstate-0.1.0/build_cython.py +236 -0
- gridstate-0.1.0/gridstate/__init__.py +84 -0
- gridstate-0.1.0/gridstate/__pyinstaller/__init__.py +5 -0
- gridstate-0.1.0/gridstate/__pyinstaller/hook-gridstate.py +5 -0
- gridstate-0.1.0/gridstate/_version.py +24 -0
- gridstate-0.1.0/gridstate/adapters/__init__.py +16 -0
- gridstate-0.1.0/gridstate/adapters/from_pandapower.py +406 -0
- gridstate-0.1.0/gridstate/algebra/__init__.py +5 -0
- gridstate-0.1.0/gridstate/algebra/base.py +614 -0
- gridstate-0.1.0/gridstate/algebra/estimators.py +47 -0
- gridstate-0.1.0/gridstate/algorithms/__init__.py +5 -0
- gridstate-0.1.0/gridstate/algorithms/ipm.py +496 -0
- gridstate-0.1.0/gridstate/algorithms/wls.py +549 -0
- gridstate-0.1.0/gridstate/api.py +502 -0
- gridstate-0.1.0/gridstate/constants.py +62 -0
- gridstate-0.1.0/gridstate/contract/__init__.py +89 -0
- gridstate-0.1.0/gridstate/contract/derived.py +39 -0
- gridstate-0.1.0/gridstate/contract/runtime.py +220 -0
- gridstate-0.1.0/gridstate/contract/serialize.py +173 -0
- gridstate-0.1.0/gridstate/contract/tables.py +641 -0
- gridstate-0.1.0/gridstate/contract/validate.py +185 -0
- gridstate-0.1.0/gridstate/contract/version.py +103 -0
- gridstate-0.1.0/gridstate/losses.py +365 -0
- gridstate-0.1.0/gridstate/pipeline.py +1102 -0
- gridstate-0.1.0/gridstate/post_processing.py +647 -0
- gridstate-0.1.0/gridstate/preprocessing/__init__.py +47 -0
- gridstate-0.1.0/gridstate/preprocessing/chain_voltage.py +205 -0
- gridstate-0.1.0/gridstate/preprocessing/dead_gen_nodes.py +101 -0
- gridstate-0.1.0/gridstate/preprocessing/ipm_setup.py +466 -0
- gridstate-0.1.0/gridstate/preprocessing/mirror_voltage.py +186 -0
- gridstate-0.1.0/gridstate/preprocessing/node_props.py +92 -0
- gridstate-0.1.0/gridstate/preprocessing/one_sided.py +232 -0
- gridstate-0.1.0/gridstate/preprocessing/pseudo_measurements.py +517 -0
- gridstate-0.1.0/gridstate/preprocessing/synth_injection.py +397 -0
- gridstate-0.1.0/gridstate/quality_summary.py +202 -0
- gridstate-0.1.0/gridstate/result.py +266 -0
- gridstate-0.1.0/gridstate/state.py +311 -0
- gridstate-0.1.0/gridstate/telemetry/__init__.py +89 -0
- gridstate-0.1.0/gridstate/telemetry/_specs.py +100 -0
- gridstate-0.1.0/gridstate/telemetry/generators.py +165 -0
- gridstate-0.1.0/gridstate/telemetry/loss_filter.py +451 -0
- gridstate-0.1.0/gridstate/telemetry/measurements.py +189 -0
- gridstate-0.1.0/gridstate/telemetry/on_line.py +115 -0
- gridstate-0.1.0/gridstate/telemetry/quality.py +159 -0
- gridstate-0.1.0/gridstate/telemetry/rpn.py +205 -0
- gridstate-0.1.0/gridstate/telemetry/shunts.py +209 -0
- gridstate-0.1.0/gridstate/telemetry/topology.py +41 -0
- gridstate-0.1.0/gridstate/telemetry/units.py +87 -0
- gridstate-0.1.0/gridstate/telemetry/voltage_filter.py +331 -0
- gridstate-0.1.0/gridstate/telemetry/voltage_nominal.py +44 -0
- gridstate-0.1.0/gridstate/telemetry/xml_args.py +738 -0
- gridstate-0.1.0/gridstate/topology.py +363 -0
- gridstate-0.1.0/gridstate/units.py +456 -0
- gridstate-0.1.0/gridstate/validation/__init__.py +3 -0
- gridstate-0.1.0/gridstate/validation/_diagnostics.py +101 -0
- gridstate-0.1.0/gridstate/validation/bad_data.py +322 -0
- gridstate-0.1.0/gridstate/validation/chi2_test.py +130 -0
- gridstate-0.1.0/gridstate/validation/observability.py +134 -0
- gridstate-0.1.0/gridstate/working.py +409 -0
- gridstate-0.1.0/gridstate/ybus.py +139 -0
- gridstate-0.1.0/gridstate/z_vector.py +325 -0
- gridstate-0.1.0/gridstate.egg-info/PKG-INFO +199 -0
- gridstate-0.1.0/gridstate.egg-info/SOURCES.txt +132 -0
- gridstate-0.1.0/gridstate.egg-info/dependency_links.txt +1 -0
- gridstate-0.1.0/gridstate.egg-info/entry_points.txt +2 -0
- gridstate-0.1.0/gridstate.egg-info/requires.txt +31 -0
- gridstate-0.1.0/gridstate.egg-info/top_level.txt +1 -0
- gridstate-0.1.0/pyproject.toml +194 -0
- gridstate-0.1.0/setup.cfg +4 -0
- gridstate-0.1.0/tests/__init__.py +0 -0
- gridstate-0.1.0/tests/_dor_parser.py +511 -0
- gridstate-0.1.0/tests/conftest.py +30 -0
- gridstate-0.1.0/tests/test_aggregate_generators.py +212 -0
- gridstate-0.1.0/tests/test_algebra_base.py +461 -0
- gridstate-0.1.0/tests/test_anti_overshoot.py +160 -0
- gridstate-0.1.0/tests/test_bad_data.py +354 -0
- gridstate-0.1.0/tests/test_breaker_reactance.py +114 -0
- gridstate-0.1.0/tests/test_contract.py +204 -0
- gridstate-0.1.0/tests/test_contract_runtime.py +282 -0
- gridstate-0.1.0/tests/test_data/ieee/case118.npz +0 -0
- gridstate-0.1.0/tests/test_data/ieee/case118_truth.npz +0 -0
- gridstate-0.1.0/tests/test_data/ieee/case14.npz +0 -0
- gridstate-0.1.0/tests/test_data/ieee/case14_truth.npz +0 -0
- gridstate-0.1.0/tests/test_data/ieee/case30.npz +0 -0
- gridstate-0.1.0/tests/test_data/ieee/case30_truth.npz +0 -0
- gridstate-0.1.0/tests/test_dead_gen_nodes.py +127 -0
- gridstate-0.1.0/tests/test_dor_parser.py +247 -0
- gridstate-0.1.0/tests/test_ieee_cases.py +103 -0
- gridstate-0.1.0/tests/test_ipm.py +241 -0
- gridstate-0.1.0/tests/test_ipm_integration.py +231 -0
- gridstate-0.1.0/tests/test_losses_q_convention.py +57 -0
- gridstate-0.1.0/tests/test_materialize_phase4.py +211 -0
- gridstate-0.1.0/tests/test_measurement_mutators_phase4.py +567 -0
- gridstate-0.1.0/tests/test_numpy_only_runtime.py +309 -0
- gridstate-0.1.0/tests/test_observability.py +341 -0
- gridstate-0.1.0/tests/test_on_line_phase4.py +199 -0
- gridstate-0.1.0/tests/test_one_sided.py +142 -0
- gridstate-0.1.0/tests/test_pipeline.py +103 -0
- gridstate-0.1.0/tests/test_pipeline_idempotent.py +265 -0
- gridstate-0.1.0/tests/test_pipeline_warm_start.py +62 -0
- gridstate-0.1.0/tests/test_pipeline_working_layer.py +92 -0
- gridstate-0.1.0/tests/test_post_processing.py +456 -0
- gridstate-0.1.0/tests/test_pseudo_layer_phase4.py +576 -0
- gridstate-0.1.0/tests/test_pseudo_v_unobservable.py +201 -0
- gridstate-0.1.0/tests/test_reactor_sign.py +109 -0
- gridstate-0.1.0/tests/test_result_quality_summary.py +125 -0
- gridstate-0.1.0/tests/test_rpn_phase4.py +156 -0
- gridstate-0.1.0/tests/test_serialize_npz.py +94 -0
- gridstate-0.1.0/tests/test_state.py +292 -0
- gridstate-0.1.0/tests/test_telemetry_cascade_phase4.py +237 -0
- gridstate-0.1.0/tests/test_telemetry_phase4.py +461 -0
- gridstate-0.1.0/tests/test_tm_code_quality.py +142 -0
- gridstate-0.1.0/tests/test_topology_phase4.py +211 -0
- gridstate-0.1.0/tests/test_topology_port.py +150 -0
- gridstate-0.1.0/tests/test_units.py +296 -0
- gridstate-0.1.0/tests/test_units_phase2.py +229 -0
- gridstate-0.1.0/tests/test_variance_charging.py +69 -0
- gridstate-0.1.0/tests/test_version.py +20 -0
- gridstate-0.1.0/tests/test_voltage_calibration_gen_nodes.py +277 -0
- gridstate-0.1.0/tests/test_voltage_range_filter_fallback.py +138 -0
- gridstate-0.1.0/tests/test_wls.py +459 -0
- gridstate-0.1.0/tests/test_working_container.py +429 -0
- gridstate-0.1.0/tests/test_ybus.py +254 -0
- gridstate-0.1.0/tests/test_z_vector.py +313 -0
- gridstate-0.1.0/tools/gen_ieee_fixtures.py +175 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: ci-${{ github.ref }}
|
|
10
|
+
cancel-in-progress: true
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
lint:
|
|
14
|
+
name: Lint (pre-commit)
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.11"
|
|
21
|
+
# Runs every hook from .pre-commit-config.yaml (ruff, ruff-format,
|
|
22
|
+
# whitespace/eof/yaml/toml checks). The commit-msg-stage commitizen
|
|
23
|
+
# hook is skipped automatically in --all-files mode.
|
|
24
|
+
- uses: pre-commit/action@v3.0.1
|
|
25
|
+
|
|
26
|
+
typecheck:
|
|
27
|
+
name: Type check (mypy)
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
# Required gate: mypy must be clean before merge (see branch protection).
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
with:
|
|
33
|
+
fetch-depth: 0 # setuptools_scm needs full history + tags for the version
|
|
34
|
+
- uses: actions/setup-python@v5
|
|
35
|
+
with:
|
|
36
|
+
python-version: "3.11"
|
|
37
|
+
- run: pip install -e ".[dev]"
|
|
38
|
+
- run: mypy gridstate
|
|
39
|
+
|
|
40
|
+
test:
|
|
41
|
+
name: Test (Python ${{ matrix.python-version }})
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
strategy:
|
|
44
|
+
fail-fast: false
|
|
45
|
+
matrix:
|
|
46
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
47
|
+
steps:
|
|
48
|
+
- uses: actions/checkout@v4
|
|
49
|
+
with:
|
|
50
|
+
fetch-depth: 0 # setuptools_scm needs full history + tags for the version
|
|
51
|
+
- uses: actions/setup-python@v5
|
|
52
|
+
with:
|
|
53
|
+
python-version: ${{ matrix.python-version }}
|
|
54
|
+
- run: pip install -e ".[test]"
|
|
55
|
+
- run: pytest tests/ --cov=gridstate --cov-report=xml --cov-report=term
|
|
56
|
+
- uses: actions/upload-artifact@v4
|
|
57
|
+
if: matrix.python-version == '3.11'
|
|
58
|
+
with:
|
|
59
|
+
name: coverage-xml
|
|
60
|
+
path: coverage.xml
|
|
61
|
+
|
|
62
|
+
build:
|
|
63
|
+
name: Build (sdist + wheel)
|
|
64
|
+
runs-on: ubuntu-latest
|
|
65
|
+
needs: [lint, typecheck, test]
|
|
66
|
+
steps:
|
|
67
|
+
- uses: actions/checkout@v4
|
|
68
|
+
with:
|
|
69
|
+
fetch-depth: 0
|
|
70
|
+
- uses: actions/setup-python@v5
|
|
71
|
+
with:
|
|
72
|
+
python-version: "3.11"
|
|
73
|
+
- run: pip install build
|
|
74
|
+
- run: python -m build
|
|
75
|
+
- run: pipx run twine check dist/*
|
|
76
|
+
# Release readiness: the distributable wheel must install into a clean
|
|
77
|
+
# environment and actually solve a real case — not merely pass metadata
|
|
78
|
+
# checks. Run from /tmp so `import gridstate` resolves to the INSTALLED
|
|
79
|
+
# wheel, not the source tree in the workspace.
|
|
80
|
+
- name: Smoke-test built wheel in a clean environment
|
|
81
|
+
run: |
|
|
82
|
+
python -m venv /tmp/smoke-env
|
|
83
|
+
/tmp/smoke-env/bin/pip install --upgrade pip
|
|
84
|
+
/tmp/smoke-env/bin/pip install "$(ls dist/*.whl)"
|
|
85
|
+
cp tests/test_data/ieee/case14.npz /tmp/case14.npz
|
|
86
|
+
cd /tmp
|
|
87
|
+
/tmp/smoke-env/bin/python - <<'PY'
|
|
88
|
+
import gridstate
|
|
89
|
+
from gridstate import load_se_input_npz, run_se
|
|
90
|
+
from gridstate.pipeline import PipelineConfig
|
|
91
|
+
|
|
92
|
+
print("gridstate version:", gridstate.__version__)
|
|
93
|
+
se_in = load_se_input_npz("/tmp/case14.npz")
|
|
94
|
+
out = run_se(se_in, config=PipelineConfig(algorithm="wls"), validate=False)
|
|
95
|
+
assert out.success, "WLS failed to converge on IEEE case14 from the built wheel"
|
|
96
|
+
print(f"wheel smoke OK - success={out.success} iters={out.iterations}")
|
|
97
|
+
PY
|
|
98
|
+
- uses: actions/upload-artifact@v4
|
|
99
|
+
with:
|
|
100
|
+
name: dist
|
|
101
|
+
path: dist/*
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Publish to PyPI when a version tag is pushed.
|
|
4
|
+
#
|
|
5
|
+
# Versioning is handled by setuptools_scm (the tag IS the version) and tags are
|
|
6
|
+
# created from Conventional Commits with `cz bump` (run locally, then
|
|
7
|
+
# `git push --follow-tags`). This workflow only builds and publishes.
|
|
8
|
+
#
|
|
9
|
+
# Publishing uses PyPI Trusted Publishing (OIDC) — no API token in secrets.
|
|
10
|
+
# One-time setup on PyPI: add this repository as a trusted publisher for the
|
|
11
|
+
# `gridstate` project, workflow `release.yml`, environment `pypi`.
|
|
12
|
+
|
|
13
|
+
on:
|
|
14
|
+
push:
|
|
15
|
+
tags:
|
|
16
|
+
- "v*"
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
build:
|
|
20
|
+
name: Build distributions
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
with:
|
|
25
|
+
fetch-depth: 0
|
|
26
|
+
- uses: actions/setup-python@v5
|
|
27
|
+
with:
|
|
28
|
+
python-version: "3.11"
|
|
29
|
+
- run: pip install build
|
|
30
|
+
- run: python -m build
|
|
31
|
+
- run: pipx run twine check dist/*
|
|
32
|
+
- uses: actions/upload-artifact@v4
|
|
33
|
+
with:
|
|
34
|
+
name: dist
|
|
35
|
+
path: dist/*
|
|
36
|
+
|
|
37
|
+
publish:
|
|
38
|
+
name: Publish to PyPI
|
|
39
|
+
needs: build
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
environment: pypi
|
|
42
|
+
permissions:
|
|
43
|
+
id-token: write # required for Trusted Publishing (OIDC)
|
|
44
|
+
steps:
|
|
45
|
+
- uses: actions/download-artifact@v4
|
|
46
|
+
with:
|
|
47
|
+
name: dist
|
|
48
|
+
path: dist
|
|
49
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
50
|
+
|
|
51
|
+
github-release:
|
|
52
|
+
name: GitHub Release
|
|
53
|
+
# Independent of PyPI publish: depends only on a good build, so a GitHub
|
|
54
|
+
# Release (with attached artifacts) is created even if the PyPI step is
|
|
55
|
+
# not yet wired (e.g. before the trusted publisher is configured). Re-run
|
|
56
|
+
# the publish job separately once PyPI is set up.
|
|
57
|
+
needs: build
|
|
58
|
+
runs-on: ubuntu-latest
|
|
59
|
+
permissions:
|
|
60
|
+
contents: write # create the release + upload assets
|
|
61
|
+
steps:
|
|
62
|
+
- uses: actions/checkout@v4
|
|
63
|
+
with:
|
|
64
|
+
fetch-depth: 0 # full history so --generate-notes can diff against the previous tag
|
|
65
|
+
- uses: actions/download-artifact@v4
|
|
66
|
+
with:
|
|
67
|
+
name: dist
|
|
68
|
+
path: dist
|
|
69
|
+
- name: Create GitHub Release with auto-generated notes
|
|
70
|
+
env:
|
|
71
|
+
GH_TOKEN: ${{ github.token }}
|
|
72
|
+
run: |
|
|
73
|
+
gh release create "${GITHUB_REF_NAME}" \
|
|
74
|
+
--title "${GITHUB_REF_NAME}" \
|
|
75
|
+
--generate-notes \
|
|
76
|
+
dist/*
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
*.manifest
|
|
31
|
+
*.spec
|
|
32
|
+
|
|
33
|
+
# Unit test / coverage reports
|
|
34
|
+
htmlcov/
|
|
35
|
+
.tox/
|
|
36
|
+
.nox/
|
|
37
|
+
.coverage
|
|
38
|
+
.coverage.*
|
|
39
|
+
.cache
|
|
40
|
+
coverage.xml
|
|
41
|
+
*.cover
|
|
42
|
+
.hypothesis/
|
|
43
|
+
.pytest_cache/
|
|
44
|
+
cover/
|
|
45
|
+
|
|
46
|
+
# Environments
|
|
47
|
+
.env
|
|
48
|
+
.venv
|
|
49
|
+
env/
|
|
50
|
+
venv/
|
|
51
|
+
ENV/
|
|
52
|
+
env.bak/
|
|
53
|
+
venv.bak/
|
|
54
|
+
|
|
55
|
+
# mypy / ruff / pytype caches
|
|
56
|
+
.mypy_cache/
|
|
57
|
+
.dmypy.json
|
|
58
|
+
dmypy.json
|
|
59
|
+
.pyre/
|
|
60
|
+
.pytype/
|
|
61
|
+
.ruff_cache/
|
|
62
|
+
|
|
63
|
+
# IDE / OS
|
|
64
|
+
.idea/
|
|
65
|
+
.vscode/
|
|
66
|
+
*.swp
|
|
67
|
+
*.swo
|
|
68
|
+
*~
|
|
69
|
+
.DS_Store
|
|
70
|
+
Thumbs.db
|
|
71
|
+
|
|
72
|
+
# Sensitive
|
|
73
|
+
.env*
|
|
74
|
+
secrets.json
|
|
75
|
+
credentials.json
|
|
76
|
+
*.key
|
|
77
|
+
*.pem
|
|
78
|
+
*.p12
|
|
79
|
+
private_key*
|
|
80
|
+
id_rsa*
|
|
81
|
+
id_dsa*
|
|
82
|
+
id_ecdsa*
|
|
83
|
+
id_ed25519*
|
|
84
|
+
|
|
85
|
+
# setuptools_scm generated version file
|
|
86
|
+
gridstate/_version.py
|
|
87
|
+
|
|
88
|
+
# Local settings and Claude memory (not committed)
|
|
89
|
+
.claude/
|
|
90
|
+
|
|
91
|
+
# One-off debug scripts
|
|
92
|
+
scripts/
|
|
93
|
+
|
|
94
|
+
# Heavy test data. Only small samples are kept in the repo
|
|
95
|
+
# (see tests/test_data/README.md); full measurement logs are external.
|
|
96
|
+
tests/test_data/**/*.log
|
|
97
|
+
!tests/test_data/**/*_sample.log
|
|
98
|
+
|
|
99
|
+
# Local-only specs / extracted material
|
|
100
|
+
.specs/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Pre-commit hooks for gridstate.
|
|
2
|
+
#
|
|
3
|
+
# Install:
|
|
4
|
+
# .venv/bin/pip install pre-commit
|
|
5
|
+
# .venv/bin/pre-commit install
|
|
6
|
+
#
|
|
7
|
+
# The same hooks run in CI (.github/workflows/ci.yml -> pre-commit/action).
|
|
8
|
+
# The ruff version here must match the pin in pyproject.toml ([dev]), otherwise
|
|
9
|
+
# the local hook and CI may diverge on rules.
|
|
10
|
+
|
|
11
|
+
exclude: '^(tests/test_data/|\.venv/|build/|dist/)'
|
|
12
|
+
|
|
13
|
+
repos:
|
|
14
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
15
|
+
rev: v6.0.0
|
|
16
|
+
hooks:
|
|
17
|
+
- id: trailing-whitespace
|
|
18
|
+
- id: end-of-file-fixer
|
|
19
|
+
- id: check-yaml
|
|
20
|
+
- id: check-toml
|
|
21
|
+
- id: check-json
|
|
22
|
+
- id: check-merge-conflict
|
|
23
|
+
- id: check-added-large-files
|
|
24
|
+
args: ['--maxkb=3000']
|
|
25
|
+
- id: mixed-line-ending
|
|
26
|
+
args: ['--fix=lf']
|
|
27
|
+
- id: debug-statements
|
|
28
|
+
|
|
29
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
30
|
+
rev: v0.15.12
|
|
31
|
+
hooks:
|
|
32
|
+
- id: ruff
|
|
33
|
+
args: [--fix]
|
|
34
|
+
- id: ruff-format
|
|
35
|
+
|
|
36
|
+
- repo: https://github.com/commitizen-tools/commitizen
|
|
37
|
+
rev: v4.10.0
|
|
38
|
+
hooks:
|
|
39
|
+
- id: commitizen
|
|
40
|
+
stages: [commit-msg]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and the project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
Release entries are generated by [Commitizen](https://commitizen-tools.github.io/commitizen/)
|
|
8
|
+
from [Conventional Commits](https://www.conventionalcommits.org/).
|
|
9
|
+
|
|
10
|
+
## Unreleased
|
|
11
|
+
|
|
12
|
+
- Initial public release in preparation.
|
gridstate-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Evgeny Istomin
|
|
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.
|
|
22
|
+
|
|
23
|
+
================================================================================
|
|
24
|
+
THIRD-PARTY SOFTWARE NOTICES
|
|
25
|
+
================================================================================
|
|
26
|
+
|
|
27
|
+
This project contains code adapted from the open-source project listed below.
|
|
28
|
+
The adapted code retains the original copyright notice as required by its
|
|
29
|
+
license.
|
|
30
|
+
|
|
31
|
+
--------------------------------------------------------------------------------
|
|
32
|
+
pandapower
|
|
33
|
+
--------------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
Copyright (c) 2016-2025 by University of Kassel and Fraunhofer Institute for
|
|
36
|
+
Energy Economics and Energy System Technology (IEE), Kassel. All rights
|
|
37
|
+
reserved.
|
|
38
|
+
|
|
39
|
+
Licensed under the BSD 3-Clause License (full text below).
|
|
40
|
+
Upstream: https://github.com/e2nIEE/pandapower
|
|
41
|
+
|
|
42
|
+
Files adapted from pandapower into this project:
|
|
43
|
+
|
|
44
|
+
pandapower/estimation/algorithm/base.py
|
|
45
|
+
-> gridstate/algorithms/wls.py (class WLSAlgorithm)
|
|
46
|
+
pandapower/estimation/algorithm/matrix_base.py
|
|
47
|
+
-> gridstate/algebra/base.py (class BaseAlgebra)
|
|
48
|
+
pandapower/estimation/algorithm/estimator.py
|
|
49
|
+
-> gridstate/algebra/estimators.py (cost functions)
|
|
50
|
+
pandapower/estimation/state_estimation.py
|
|
51
|
+
-> gridstate/validation/chi2_test.py (perform_chi2_test)
|
|
52
|
+
-> gridstate/validation/bad_data.py (perform_rn_max_test)
|
|
53
|
+
pandapower/pypower/makeYbus.py
|
|
54
|
+
-> gridstate/ybus.py (Ybus / Yf / Yt assembly)
|
|
55
|
+
|
|
56
|
+
Adaptation summary: the PYPOWER layer (ppc_conversion, idx_bus, idx_brch) was
|
|
57
|
+
removed; the code operates on this project's own internal per-unit
|
|
58
|
+
representation (gridstate/units.py) instead of the PYPOWER case format.
|
|
59
|
+
|
|
60
|
+
BSD 3-Clause License
|
|
61
|
+
....................
|
|
62
|
+
|
|
63
|
+
Copyright (c) 2016-2025 by University of Kassel and Fraunhofer Institute for
|
|
64
|
+
Energy Economics and Energy System Technology (IEE), Kassel. All rights
|
|
65
|
+
reserved.
|
|
66
|
+
|
|
67
|
+
Redistribution and use in source and binary forms, with or without
|
|
68
|
+
modification, are permitted provided that the following conditions are met:
|
|
69
|
+
|
|
70
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
71
|
+
this list of conditions and the following disclaimer.
|
|
72
|
+
|
|
73
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
74
|
+
this list of conditions and the following disclaimer in the documentation
|
|
75
|
+
and/or other materials provided with the distribution.
|
|
76
|
+
|
|
77
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
78
|
+
contributors may be used to endorse or promote products derived from this
|
|
79
|
+
software without specific prior written permission.
|
|
80
|
+
|
|
81
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
82
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
83
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
84
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
85
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
86
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
87
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
88
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
89
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
90
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
91
|
+
POSSIBILITY OF SUCH DAMAGE.
|
gridstate-0.1.0/Makefile
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Makefile for gridstate
|
|
2
|
+
|
|
3
|
+
VENV := .venv
|
|
4
|
+
PYTHON := python3
|
|
5
|
+
ifeq ($(OS),Windows_NT)
|
|
6
|
+
VENV_BIN := $(VENV)/Scripts
|
|
7
|
+
else
|
|
8
|
+
VENV_BIN := $(VENV)/bin
|
|
9
|
+
endif
|
|
10
|
+
VENV_PYTHON := $(VENV_BIN)/python
|
|
11
|
+
VENV_PIP := $(VENV_BIN)/pip
|
|
12
|
+
|
|
13
|
+
HAS_VENV := $(shell test -d $(VENV) && echo 1 || echo 0)
|
|
14
|
+
|
|
15
|
+
.PHONY: help venv check-venv install install-dev test test-cov lint format type-check clean build setup
|
|
16
|
+
|
|
17
|
+
venv:
|
|
18
|
+
@echo "Creating virtual environment..."
|
|
19
|
+
$(PYTHON) -m venv $(VENV)
|
|
20
|
+
$(VENV_PIP) install --upgrade pip setuptools wheel
|
|
21
|
+
@echo "Activate it: source $(VENV_BIN)/activate"
|
|
22
|
+
|
|
23
|
+
check-venv:
|
|
24
|
+
ifeq ($(HAS_VENV),0)
|
|
25
|
+
@echo "Virtual environment not found. Create it: make venv"
|
|
26
|
+
@exit 1
|
|
27
|
+
endif
|
|
28
|
+
|
|
29
|
+
install: check-venv
|
|
30
|
+
$(VENV_PIP) install -e .
|
|
31
|
+
|
|
32
|
+
install-dev: check-venv
|
|
33
|
+
$(VENV_PIP) install -e ".[dev,test]"
|
|
34
|
+
$(VENV_BIN)/pre-commit install
|
|
35
|
+
|
|
36
|
+
test: check-venv
|
|
37
|
+
$(VENV_BIN)/pytest tests/ -v
|
|
38
|
+
|
|
39
|
+
test-cov: check-venv
|
|
40
|
+
$(VENV_BIN)/pytest tests/ -v --cov=gridstate --cov-report=html --cov-report=term
|
|
41
|
+
|
|
42
|
+
lint: check-venv
|
|
43
|
+
$(VENV_BIN)/ruff check gridstate tests
|
|
44
|
+
$(VENV_BIN)/ruff format --check gridstate tests
|
|
45
|
+
|
|
46
|
+
format: check-venv
|
|
47
|
+
$(VENV_BIN)/ruff format gridstate tests
|
|
48
|
+
$(VENV_BIN)/ruff check --fix gridstate tests
|
|
49
|
+
|
|
50
|
+
type-check: check-venv
|
|
51
|
+
$(VENV_BIN)/mypy gridstate
|
|
52
|
+
|
|
53
|
+
clean:
|
|
54
|
+
rm -rf build/ dist/ *.egg-info
|
|
55
|
+
rm -rf .coverage htmlcov/ .pytest_cache/ .mypy_cache/ .ruff_cache/
|
|
56
|
+
find . -type d -name __pycache__ -not -path './.venv/*' -exec rm -rf {} +
|
|
57
|
+
find . -type f -name "*.pyc" -not -path './.venv/*' -delete
|
|
58
|
+
|
|
59
|
+
build: check-venv
|
|
60
|
+
$(VENV_PYTHON) -m build
|
|
61
|
+
|
|
62
|
+
check: format lint type-check test
|
|
63
|
+
@echo "All checks passed."
|
|
64
|
+
|
|
65
|
+
setup:
|
|
66
|
+
@$(MAKE) venv
|
|
67
|
+
@$(MAKE) install-dev
|
|
68
|
+
@echo "Environment ready. Activate it: source $(VENV_BIN)/activate"
|
|
69
|
+
|
|
70
|
+
help:
|
|
71
|
+
@echo "Available targets:"
|
|
72
|
+
@echo " make setup Full setup for a new developer"
|
|
73
|
+
@echo " make venv Create the virtual environment"
|
|
74
|
+
@echo " make install Install the package"
|
|
75
|
+
@echo " make install-dev Install with dev/test extras and pre-commit hooks"
|
|
76
|
+
@echo " make test Run the test suite"
|
|
77
|
+
@echo " make test-cov Run tests with a coverage report"
|
|
78
|
+
@echo " make lint Style check (ruff)"
|
|
79
|
+
@echo " make format Auto-format"
|
|
80
|
+
@echo " make type-check Type check (mypy)"
|
|
81
|
+
@echo " make check format + lint + type-check + test"
|
|
82
|
+
@echo " make clean Remove temporary files"
|
|
83
|
+
@echo " make build Build the package"
|