diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6dd4d950..85e8f580 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,13 +17,14 @@ repos: hooks: - id: poetry-check - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.7.0 # keep in sync with pyproject.toml hooks: - id: black-jupyter - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.280 + rev: v0.0.280 # keep in sync with pyproject.toml hooks: - id: ruff + types_or: [ python, pyi, jupyter ] args: [ --fix, --exit-non-zero-on-fix ] - repo: https://github.com/adamchainz/blacken-docs rev: 1.15.0 @@ -31,4 +32,4 @@ repos: - id: blacken-docs entry: bash -c "blacken-docs -l 90 $(find doc/ -name '*.md')" args: [ -l 90 ] - additional_dependencies: [ black==23.7.0 ] + additional_dependencies: [ black==23.7.0 ] # keep in sync with black above diff --git a/doc/notebooks/Advanced.ipynb b/doc/notebooks/Advanced.ipynb index d7cc993e..9b8e064d 100644 --- a/doc/notebooks/Advanced.ipynb +++ b/doc/notebooks/Advanced.ipynb @@ -130,9 +130,15 @@ "outputs": [ { "data": { - "text/plain": "array([243.66463933, 232.20612714, 233.55093129]) ", - "text/html": "
Magnitude
[243.66463933130166 232.2061271436693 233.5509312888294]
Unitsvolt
", - "text/latex": "$\\begin{pmatrix} & & \\end{pmatrix}\\ \\mathrm{volt}$" + "text/html": [ + "
Magnitude
[243.66463933130166 232.2061271436693 233.5509312888294]
Unitsvolt
" + ], + "text/latex": [ + "$\\begin{pmatrix} & & \\end{pmatrix}\\ \\mathrm{volt}$" + ], + "text/plain": [ + "array([243.66463933, 232.20612714, 233.55093129]) " + ] }, "execution_count": 4, "metadata": {}, @@ -221,9 +227,15 @@ "outputs": [ { "data": { - "text/plain": "array([243.08225748, 232.46046866, 233.62854073]) ", - "text/html": "
Magnitude
[243.08225748385007 232.46046865587596 233.62854072949668]
Unitsvolt
", - "text/latex": "$\\begin{pmatrix} & & \\end{pmatrix}\\ \\mathrm{volt}$" + "text/html": [ + "
Magnitude
[243.08225748385007 232.46046865587596 233.62854072949668]
Unitsvolt
" + ], + "text/latex": [ + "$\\begin{pmatrix} & & \\end{pmatrix}\\ \\mathrm{volt}$" + ], + "text/plain": [ + "array([243.08225748, 232.46046866, 233.62854073]) " + ] }, "execution_count": 6, "metadata": {}, @@ -260,9 +272,15 @@ "outputs": [ { "data": { - "text/plain": "array([-2757.8035271+0.j, 0. +0.j, 0. +0.j]) ", - "text/html": "
Magnitude
[-2757.8035271+0.j     0.       +0.j     0.       +0.j]
Unitsvolt_ampere
", - "text/latex": "$\\begin{pmatrix} & & \\end{pmatrix}\\ \\mathrm{volt\\_ampere}$" + "text/html": [ + "
Magnitude
[-2757.8035271+0.j     0.       +0.j     0.       +0.j]
Unitsvolt_ampere
" + ], + "text/latex": [ + "$\\begin{pmatrix} & & \\end{pmatrix}\\ \\mathrm{volt\\_ampere}$" + ], + "text/plain": [ + "array([-2757.8035271+0.j, 0. +0.j, 0. +0.j]) " + ] }, "execution_count": 7, "metadata": {}, @@ -343,9 +361,15 @@ "outputs": [ { "data": { - "text/plain": "array([239.5133208 , 230.2108052 , 237.59184615]) ", - "text/html": "
Magnitude
[239.51332079629023 230.21080520340482 237.59184615484196]
Unitsvolt
", - "text/latex": "$\\begin{pmatrix} & & \\end{pmatrix}\\ \\mathrm{volt}$" + "text/html": [ + "
Magnitude
[239.51332079629023 230.21080520340482 237.59184615484196]
Unitsvolt
" + ], + "text/latex": [ + "$\\begin{pmatrix} & & \\end{pmatrix}\\ \\mathrm{volt}$" + ], + "text/plain": [ + "array([239.5133208 , 230.2108052 , 237.59184615]) " + ] }, "execution_count": 9, "metadata": {}, @@ -381,9 +405,16 @@ "outputs": [ { "data": { - "text/plain": "array([-2566.23768012+3068.29336425j, 0. +0.j ,\n 0. +0.j ]) ", - "text/html": "
Magnitude
[-2566.23768012+3068.29336425j     0.           +0.j
0. +0.j ]
Unitsvolt_ampere
", - "text/latex": "$\\begin{pmatrix} & & \\end{pmatrix}\\ \\mathrm{volt\\_ampere}$" + "text/html": [ + "
Magnitude
[-2566.23768012+3068.29336425j     0.           +0.j
0. +0.j ]
Unitsvolt_ampere
" + ], + "text/latex": [ + "$\\begin{pmatrix} & & \\end{pmatrix}\\ \\mathrm{volt\\_ampere}$" + ], + "text/plain": [ + "array([-2566.23768012+3068.29336425j, 0. +0.j ,\n", + " 0. +0.j ]) " + ] }, "execution_count": 10, "metadata": {}, @@ -406,9 +437,15 @@ "outputs": [ { "data": { - "text/plain": "array([4000., 0., 0.]) ", - "text/html": "
Magnitude
[4000.0 0.0 0.0]
Unitsvolt_ampere
", - "text/latex": "$\\begin{pmatrix} & & \\end{pmatrix}\\ \\mathrm{volt\\_ampere}$" + "text/html": [ + "
Magnitude
[4000.0 0.0 0.0]
Unitsvolt_ampere
" + ], + "text/latex": [ + "$\\begin{pmatrix} & & \\end{pmatrix}\\ \\mathrm{volt\\_ampere}$" + ], + "text/plain": [ + "array([4000., 0., 0.]) " + ] }, "execution_count": 11, "metadata": {}, @@ -448,14 +485,14 @@ "# Connect a new bus to the network\n", "new_bus = Bus(id=\"new_bus\", phases=\"abcn\")\n", "new_load = PowerLoad(id=\"new_load\", bus=new_bus, phases=\"an\", powers=[6e3])\n", - "lp_S_AL_240 = LineParameters.from_name_lv(\"S_AL_240\")\n", + "lp_s_al_240 = LineParameters.from_name_lv(\"S_AL_240\")\n", "new_line = Line(\n", " id=\"new_line\",\n", " bus1=bus2,\n", " bus2=new_bus,\n", " phases=\"abcn\",\n", " ground=ground,\n", - " parameters=lp_S_AL_240,\n", + " parameters=lp_s_al_240,\n", " length=0.5,\n", ")" ] @@ -479,7 +516,9 @@ "outputs": [ { "data": { - "text/plain": "Bus(id='new_bus', phases='abcn')" + "text/plain": [ + "Bus(id='new_bus', phases='abcn')" + ] }, "execution_count": 13, "metadata": {}, @@ -502,7 +541,9 @@ "outputs": [ { "data": { - "text/plain": "PowerLoad(id='new_load', phases='an', bus='new_bus')" + "text/plain": [ + "PowerLoad(id='new_load', phases='an', bus='new_bus')" + ] }, "execution_count": 14, "metadata": {}, @@ -525,7 +566,9 @@ "outputs": [ { "data": { - "text/plain": "Line(id='new_line', phases1='abcn', phases2='abcn', bus1='bus2', bus2='new_bus')" + "text/plain": [ + "Line(id='new_line', phases1='abcn', phases2='abcn', bus1='bus2', bus2='new_bus')" + ] }, "execution_count": 15, "metadata": {}, @@ -555,9 +598,15 @@ "outputs": [ { "data": { - "text/plain": "array([227.43645429]) ", - "text/html": "
Magnitude
[227.43645429483067]
Unitsvolt
", - "text/latex": "$\\begin{pmatrix}\\end{pmatrix}\\ \\mathrm{volt}$" + "text/html": [ + "
Magnitude
[227.43645429483067]
Unitsvolt
" + ], + "text/latex": [ + "$\\begin{pmatrix}\\end{pmatrix}\\ \\mathrm{volt}$" + ], + "text/plain": [ + "array([227.43645429]) " + ] }, "execution_count": 16, "metadata": {}, diff --git a/poetry.lock b/poetry.lock index 8eb381b5..946d7393 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2949,6 +2949,32 @@ files = [ {file = "rpds_py-0.9.2.tar.gz", hash = "sha256:8d70e8f14900f2657c249ea4def963bed86a29b81f81f5b76b5a9215680de945"}, ] +[[package]] +name = "ruff" +version = "0.0.280" +description = "An extremely fast Python linter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.0.280-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:48ed5aca381050a4e2f6d232db912d2e4e98e61648b513c350990c351125aaec"}, + {file = "ruff-0.0.280-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:ef6ee3e429fd29d6a5ceed295809e376e6ece5b0f13c7e703efaf3d3bcb30b96"}, + {file = "ruff-0.0.280-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d878370f7e9463ac40c253724229314ff6ebe4508cdb96cb536e1af4d5a9cd4f"}, + {file = "ruff-0.0.280-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:83e8f372fa5627eeda5b83b5a9632d2f9c88fc6d78cead7e2a1f6fb05728d137"}, + {file = "ruff-0.0.280-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7008fc6ca1df18b21fa98bdcfc711dad5f94d0fc3c11791f65e460c48ef27c82"}, + {file = "ruff-0.0.280-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:fe7118c1eae3fda17ceb409629c7f3b5a22dffa7caf1f6796776936dca1fe653"}, + {file = "ruff-0.0.280-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:37359cd67d2af8e09110a546507c302cbea11c66a52d2a9b6d841d465f9962d4"}, + {file = "ruff-0.0.280-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:bd58af46b0221efb95966f1f0f7576df711cb53e50d2fdb0e83c2f33360116a4"}, + {file = "ruff-0.0.280-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2e7c15828d09f90e97bea8feefcd2907e8c8ce3a1f959c99f9b4b3469679f33c"}, + {file = "ruff-0.0.280-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:2dae8f2d9c44c5c49af01733c2f7956f808db682a4193180dedb29dd718d7bbe"}, + {file = "ruff-0.0.280-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:5f972567163a20fb8c2d6afc60c2ea5ef8b68d69505760a8bd0377de8984b4f6"}, + {file = "ruff-0.0.280-py3-none-musllinux_1_2_i686.whl", hash = "sha256:8ffa7347ad11643f29de100977c055e47c988cd6d9f5f5ff83027600b11b9189"}, + {file = "ruff-0.0.280-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:7a37dab70114671d273f203268f6c3366c035fe0c8056614069e90a65e614bfc"}, + {file = "ruff-0.0.280-py3-none-win32.whl", hash = "sha256:7784e3606352fcfb193f3cd22b2e2117c444cb879ef6609ec69deabd662b0763"}, + {file = "ruff-0.0.280-py3-none-win_amd64.whl", hash = "sha256:4a7d52457b5dfcd3ab24b0b38eefaead8e2dca62b4fbf10de4cd0938cf20ce30"}, + {file = "ruff-0.0.280-py3-none-win_arm64.whl", hash = "sha256:b7de5b8689575918e130e4384ed9f539ce91d067c0a332aedef6ca7188adac2d"}, + {file = "ruff-0.0.280.tar.gz", hash = "sha256:581c43e4ac5e5a7117ad7da2120d960a4a99e68ec4021ec3cd47fe1cf78f8380"}, +] + [[package]] name = "send2trash" version = "1.8.2" @@ -3772,4 +3798,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "99c12bc1e220216ff730fc24eaec696e8e2cd9b101ebdbe57a51bedb5702b539" +content-hash = "4c6cb9250d9bf541c10e021d65fbf46bec0383cf0f78ff17aa698d780ff9617e" diff --git a/pyproject.toml b/pyproject.toml index 72a44e74..e7e85147 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,8 @@ coverage = { version = "^7.0.5", extras = ["toml"] } [tool.poetry.group.dev.dependencies] pre-commit = "^3.0.0" -black = { version = "^23.1.0", extras = ["jupyter"] } +black = { version = "==23.7.0", extras = ["jupyter"] } # keep in sync with .pre-commit-config.yaml +ruff = "==0.0.280" # keep in sync with .pre-commit-config.yaml [tool.poetry.group.doc.dependencies] sphinx = "^7.0.1" @@ -84,7 +85,7 @@ show-fixes = true namespace-packages = ["roseau"] select = ["E", "F", "C90", "W", "B", "UP", "I", "RUF100", "TID", "SIM", "PT", "PIE", "N", "C4", "NPY"] unfixable = ["B"] -extend-ignore = ["E501", "B024", "N818"] +ignore = ["E501", "B024", "N818"] [tool.ruff.flake8-tidy-imports] ban-relative-imports = "all" @@ -95,6 +96,9 @@ parametrize-values-type = "tuple" [tool.ruff.mccabe] max-complexity = 15 +[tool.ruff.per-file-ignores] +"*.ipynb" = ["E402", "F403", "F405", "B018"] + [tool.coverage.run] branch = true omit = ["roseau/load_flow/__about__.py"]