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

update workflow #8

Merged
merged 2 commits into from
Jun 30, 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
11 changes: 6 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ jobs:
linters:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.12"
cache: 'pip'
cache-dependency-path: 'requirements-dev.txt'
- name: ruff
- name: Install Ruff
run: |
python -m pip install --upgrade pip
pip install ruff
ruff --format=github .
- name: Run Ruff
run: ruff check .

build:
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
platform: [octave]
os: [ubuntu-latest]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
platform: [octave]
os: [ubuntu-latest]

Expand Down
46 changes: 12 additions & 34 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,22 @@ default_stages: [commit]
repos:
# check yaml and end of file fixer
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
exclude: LICENSE

# remove unused import and variable using autoflake
- repo: https://github.com/PyCQA/autoflake
rev: v1.4
hooks:
- id: autoflake
args: [
'--in-place',
'--remove-all-unused-imports',
'--ignore-init-module-imports',
'--remove-unused-variables',
'--'
]

# sort import using isort
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: [
'--treat-comment-as-code',
'"# %%"',
'--'
]

# autofix using autopep8
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.2
hooks:
- id: autopep8

# checkstyle using ruff
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.254'
# autofix using ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.0
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi, jupyter ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
# args: [ --verbose ]
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Contirbuting

## Install in development mode

```shell
pip install -e ."[dev]"
```

## Pytest

```shell
pytest -n auto -rA --lf -c pyproject.toml --cov-report term-missing --cov=matpowercaseframes tests/
```

## Pre-Commit

```shell
pre-commit install
pre-commit run --all-files
```
168 changes: 116 additions & 52 deletions matpowercaseframes/constants.py
Original file line number Diff line number Diff line change
@@ -1,64 +1,128 @@
BUS_TYPES = {"PQ": 1, "PV": 2, "REF": 3, "NONE": 4}

COST_MODELS = {"PW_LINEAR": 1, "POLYNOMIAL": 2}

ATTRIBUTES = (
"version",
"baseMVA",
"bus",
"branch",
"gen",
"gencost",
"bus_name",
"branch_name",
"gen_name",
"dcline",
"dclinecost",
)

COLUMNS = {
'bus': [
'BUS_I', 'BUS_TYPE', 'PD', 'QD', 'GS', 'BS', 'BUS_AREA', 'VM', 'VA',
'BASE_KV', 'ZONE', 'VMAX', 'VMIN', 'LAM_P', 'LAM_Q', 'MU_VMAX',
'MU_VMIN'
"bus": [
"BUS_I",
"BUS_TYPE",
"PD",
"QD",
"GS",
"BS",
"BUS_AREA",
"VM",
"VA",
"BASE_KV",
"ZONE",
"VMAX",
"VMIN",
"LAM_P",
"LAM_Q",
"MU_VMAX",
"MU_VMIN",
],
'gen': [
'GEN_BUS', 'PG', 'QG', 'QMAX', 'QMIN', 'VG', 'MBASE', 'GEN_STATUS',
'PMAX', 'PMIN', 'PC1', 'PC2', 'QC1MIN', 'QC1MAX', 'QC2MIN', 'QC2MAX',
'RAMP_AGC', 'RAMP_10', 'RAMP_30', 'RAMP_Q', 'APF', 'MU_PMAX',
'MU_PMIN', 'MU_QMAX', 'MU_QMIN'
"gen": [
"GEN_BUS",
"PG",
"QG",
"QMAX",
"QMIN",
"VG",
"MBASE",
"GEN_STATUS",
"PMAX",
"PMIN",
"PC1",
"PC2",
"QC1MIN",
"QC1MAX",
"QC2MIN",
"QC2MAX",
"RAMP_AGC",
"RAMP_10",
"RAMP_30",
"RAMP_Q",
"APF",
"MU_PMAX",
"MU_PMIN",
"MU_QMAX",
"MU_QMIN",
],
'branch': [
'F_BUS', 'T_BUS', 'BR_R', 'BR_X', 'BR_B', 'RATE_A', 'RATE_B',
'RATE_C', 'TAP', 'SHIFT', 'BR_STATUS', 'ANGMIN', 'ANGMAX', 'PF', 'QF',
'PT', 'QT', 'MU_SF', 'MU_ST', 'MU_ANGMIN', 'MU_ANGMAX'
"branch": [
"F_BUS",
"T_BUS",
"BR_R",
"BR_X",
"BR_B",
"RATE_A",
"RATE_B",
"RATE_C",
"TAP",
"SHIFT",
"BR_STATUS",
"ANGMIN",
"ANGMAX",
"PF",
"QF",
"PT",
"QT",
"MU_SF",
"MU_ST",
"MU_ANGMIN",
"MU_ANGMAX",
],
'dcline': [
'F_BUS', 'T_BUS', 'BR_STATUS', 'PF', 'PT', 'QF', 'QT', 'VF',
'VT', 'PMIN', 'PMAX', 'QMINF', 'QMAXF', 'QMINT', 'QMAXT', 'LOSS0',
'LOSS1', 'MU_PMIN', 'MU_PMAX', 'MU_QMINF', 'MU_QMAXF', 'MU_QMINT',
'MU_QMAXT',
"dcline": [
"F_BUS",
"T_BUS",
"BR_STATUS",
"PF",
"PT",
"QF",
"QT",
"VF",
"VT",
"PMIN",
"PMAX",
"QMINF",
"QMAXF",
"QMINT",
"QMAXT",
"LOSS0",
"LOSS1",
"MU_PMIN",
"MU_PMAX",
"MU_QMINF",
"MU_QMAXF",
"MU_QMINT",
"MU_QMAXT",
],
'if': {
"if": {
# negative 'BRANCHIDX' defines opposite direction
'map': ['IFNUM', 'BRANCHIDX'],
'lims': ['IFNUM', 'LOWER', 'UPPER']
"map": ["IFNUM", "BRANCHIDX"],
"lims": ["IFNUM", "LOWER", "UPPER"],
},
'gencost': ['MODEL', 'STARTUP', 'SHUTDOWN', 'NCOST', 'COST'],
'dclinecost': ['MODEL', 'STARTUP', 'SHUTDOWN', 'NCOST', 'COST'],
'bus_name': ['BUS_NAME'],
'branch_name': ['BRANCH_NAME'],
'gen_name': ['GEN_NAME']
}

BUS_TYPES = {
'PQ': 1,
'PV': 2,
'REF': 3,
'NONE': 4
}

COST_MODELS = {
'PW_LINEAR': 1,
'POLYNOMIAL': 2
"gencost": ["MODEL", "STARTUP", "SHUTDOWN", "NCOST", "COST"],
"dclinecost": ["MODEL", "STARTUP", "SHUTDOWN", "NCOST", "COST"],
"bus_name": ["BUS_NAME"],
"branch_name": ["BRANCH_NAME"],
"gen_name": ["GEN_NAME"],
}

ATTRIBUTES = (
'version',
'baseMVA',
'bus',
'branch',
'gen',
'gencost',
'bus_name',
'branch_name',
'gen_name',
'dcline',
'dclinecost',
)

# TODO:
# Support following attributes:
# 'ct'
Expand Down
Loading
Loading