Skip to content

Commit a0f0ddf

Browse files
MolierJan Pecinovsky
authored andcommitted
zero division fix and updated hooks (#23)
authored by: Oscar
1 parent 956632b commit a0f0ddf

7 files changed

Lines changed: 71 additions & 12 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// "postStartCommand": "",
77
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=cached",
88
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
9-
"remoteUser": "root",
9+
"remoteUser": "vscode",
1010
"customizations": {
1111
"vscode": {
1212
"extensions": [

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
33
# Ruff version.
4-
rev: v0.5.5
4+
rev: v0.12.10
55
hooks:
66
# Run the linter.
77
- id: ruff
@@ -12,13 +12,13 @@ repos:
1212
types_or: [python, pyi, jupyter]
1313

1414
- repo: https://github.com/asottile/pyupgrade
15-
rev: v3.16.0
15+
rev: v3.20.0
1616
hooks:
1717
- id: pyupgrade
1818
args: [--py311-plus]
1919

2020
- repo: https://github.com/pre-commit/pre-commit-hooks
21-
rev: v4.6.0
21+
rev: v6.0.0
2222
hooks:
2323
- id: mixed-line-ending
2424
args: [--fix=lf] # Force LF line endings
@@ -29,7 +29,7 @@ repos:
2929

3030
- repo: https://github.com/astral-sh/uv-pre-commit
3131
# uv version.
32-
rev: 0.6.16
32+
rev: 0.8.13
3333
hooks:
3434
- id: uv-export
3535
args:

openenergyid/baseload/analysis.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,13 @@ def analyze(self, power_lf: pl.LazyFrame, reporting_granularity: str = "1h") ->
163163
pl.col("total_consumption_in_kilowatthour")
164164
- pl.col("consumption_due_to_baseload_in_kilowatthour")
165165
).alias("consumption_not_due_to_baseload_in_kilowatthour"),
166-
# What fraction of total energy was from baseload
167-
(
166+
pl.when(pl.col("total_consumption_in_kilowatthour") != 0)
167+
.then(
168168
pl.col("consumption_due_to_baseload_in_kilowatthour")
169169
/ pl.col("total_consumption_in_kilowatthour")
170-
).alias("baseload_ratio"),
170+
)
171+
.otherwise(None)
172+
.alias("baseload_ratio"),
171173
]
172174
)
173175
)

openenergyid/mvlr/mvlr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ def _do_analysis_no_cross_validation(self):
206206

207207
def _do_analysis_cross_validation(self):
208208
"""Find the best model (fit) based on cross-valiation (leave one out)"""
209-
assert (
210-
len(self.data) < 15
211-
), "Cross-validation is not implemented if your sample contains more than 15 datapoints"
209+
assert len(self.data) < 15, (
210+
"Cross-validation is not implemented if your sample contains more than 15 datapoints"
211+
)
212212

213213
# initialization: first model is the mean, but compute cv correctly.
214214
errors = []

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ dev = [
4343
"ipykernel>=6.29.5",
4444
"jupyter>=1.1.1",
4545
"matplotlib>=3.10.3",
46+
"notebook>=7.4.3",
47+
"pandoc>=2.4",
48+
"pip>=25.1.1",
4649
"plotly>=6.1.2",
4750
"pyarrow>=20.0.0",
4851
"pyinstrument>=5.0.2",

requirements-dev.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ pandas==2.2.3
269269
# statsmodels
270270
pandera==0.24.0
271271
# via openenergyid
272+
pandoc==2.4
272273
pandocfilters==1.5.1
273274
# via nbconvert
274275
parso==0.8.4
@@ -279,11 +280,16 @@ pexpect==4.9.0 ; sys_platform != 'emscripten' and sys_platform != 'win32'
279280
# via ipython
280281
pillow==11.2.1
281282
# via matplotlib
283+
pip==25.1.1
282284
platformdirs==4.3.8
283285
# via jupyter-core
284286
plotly==6.1.2
285287
pluggy==1.6.0
286288
# via pytest
289+
plumbum==1.9.0
290+
# via pandoc
291+
ply==3.11
292+
# via pandoc
287293
polars==1.30.0
288294
# via pandera
289295
prometheus-client==0.22.1
@@ -340,7 +346,9 @@ pytz==2025.2
340346
# pandas
341347
# pvlib
342348
pywin32==310 ; platform_python_implementation != 'PyPy' and sys_platform == 'win32'
343-
# via jupyter-core
349+
# via
350+
# jupyter-core
351+
# plumbum
344352
pywinpty==2.0.15 ; os_name == 'nt'
345353
# via
346354
# jupyter-server

uv.lock

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)