Skip to content
Open
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,23 @@ repos:
|params.yaml
)$
- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: "v4.6.0"
rev: "v6.0.0"
hooks:
- id: "end-of-file-fixer"
- id: "trailing-whitespace"
- repo: "https://github.com/iterative/dvc"
rev: "3.51.2"
rev: "3.65.0"
hooks:
- id: "dvc-post-checkout"
additional_dependencies: ["dvc[gs]"]
- id: "dvc-pre-push"
additional_dependencies: ["dvc[gs]"]
- repo: "https://github.com/DavidAnson/markdownlint-cli2"
rev: "v0.13.0"
rev: "v0.20.0"
hooks:
- id: "markdownlint-cli2"
- repo: "https://github.com/srstevenson/nb-clean"
rev: "3.3.0"
rev: "4.0.1"
hooks:
- id: "nb-clean"
args:
Expand All @@ -123,7 +123,7 @@ repos:
|tests/.*
)$
- repo: "https://github.com/charliermarsh/ruff-pre-commit"
rev: "v0.5.2"
rev: "v0.14.10"
hooks:
- id: "ruff"
args: ["--extend-fixable", "PIE790"]
Expand Down
2 changes: 1 addition & 1 deletion src/boilerdata/models/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pydantic.v1 import Extra, Field

from boilerdata import get_params_file
from boilerdata.axes_enum import AxesEnum as A # noqa: N814
from boilerdata.axes_enum import AxesEnum as A
from boilerdata.models.axes import Axes
from boilerdata.models.paths import Paths

Expand Down
8 changes: 5 additions & 3 deletions src/boilerdata/stages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from boilercore.models.trials import Trial
from matplotlib import pyplot as plt

from boilerdata.axes_enum import AxesEnum as A # noqa: N814
from boilerdata.axes_enum import AxesEnum as A
from boilerdata.models.params import PARAMS, Params

idxs = pd.IndexSlice
Expand Down Expand Up @@ -49,7 +49,8 @@ def get_run(params: Params, run: Path) -> pd.DataFrame:
# Need "df" defined so we can call "df.index.dropna()". Repeat `dropna` because a
# run can have an NA index at the end and a CSV can have an all NA record at the end
return (
df.reindex(index=df.index.dropna())
df
.reindex(index=df.index.dropna())
.dropna(how="all")
.pipe(rename_columns, params)
)
Expand Down Expand Up @@ -90,7 +91,8 @@ def per_index(
) -> pd.DataFrame:
"""Group dataframe by index and apply a function to the groups, setting dtypes."""
df = (
df.groupby(level=level, sort=False, group_keys=False) # type: ignore
df
.groupby(level=level, sort=False, group_keys=False) # type: ignore
.apply(per_index_func, params, *args, **kwargs)
.pipe(set_proj_dtypes, params)
)
Expand Down
2 changes: 1 addition & 1 deletion src/boilerdata/stages/metrics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"from IPython.display import display\n",
"from matplotlib import pyplot as plt\n",
"\n",
"from boilerdata.axes_enum import AxesEnum as A # noqa: N814\n",
"from boilerdata.axes_enum import AxesEnum as A\n",
"from boilerdata.models.params import PARAMS\n",
"from boilerdata.stages import (\n",
" MODEL_WITH_UNCERTAINTY,\n",
Expand Down
8 changes: 5 additions & 3 deletions src/boilerdata/stages/originlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import originpro as op # type: ignore # Not installed in CI
import pandas as pd

from boilerdata.axes_enum import AxesEnum as A # noqa: N814
from boilerdata.axes_enum import AxesEnum as A
from boilerdata.models.params import PARAMS, Params


def main(): # noqa: D103
(
pd.read_csv(
pd
.read_csv(
PARAMS.paths.file_results,
index_col=(index := [A.trial, A.run]),
parse_dates=index, # pyright: ignore[reportArgumentType]
Expand Down Expand Up @@ -52,7 +53,8 @@ def transform_for_originlab(df: pd.DataFrame, params: Params) -> pd.DataFrame:
})
units = cols.get_level_values("units")
indices = [
index.to_series()
index
.to_series()
.reset_index(drop=True)
.replace(superscript, superscript_repl) # type: ignore # pandas
.replace(subscript, subscript_repl)
Expand Down
2 changes: 1 addition & 1 deletion src/boilerdata/stages/parse_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pandas as pd

from boilerdata.axes_enum import AxesEnum as A # noqa: N814
from boilerdata.axes_enum import AxesEnum as A
from boilerdata.models.params import PARAMS, Params
from boilerdata.stages import get_run

Expand Down
18 changes: 11 additions & 7 deletions src/boilerdata/stages/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from scipy.constants import convert_temperature
from scipy.stats import t

from boilerdata.axes_enum import AxesEnum as A # noqa: N814
from boilerdata.axes_enum import AxesEnum as A
from boilerdata.models.params import PARAMS, Mat, Params, Prop, get_prop
from boilerdata.stages import MODEL, get_tcs, get_trial, per_run, per_trial
from boilerdata.validation import (
Expand All @@ -24,7 +24,8 @@ def main(): # noqa: D103
confidence_interval_95 = t.interval(0.95, PARAMS.records_to_average)[1]

(
pd.read_csv(
pd
.read_csv(
PARAMS.paths.file_runs,
index_col=(index_col := [A.trial, A.run, A.time]),
parse_dates=index_col, # pyright: ignore[reportArgumentType]
Expand Down Expand Up @@ -120,7 +121,8 @@ def agg_over_runs(
trial = get_trial(grp, params)
_, tc_errors = get_tcs(trial)
grp = (
grp.groupby(level=[A.trial, A.run], dropna=False) # type: ignore # pandas
grp
.groupby(level=[A.trial, A.run], dropna=False) # type: ignore # pandas
.agg(
**( # type: ignore # pandas-stubs 2.0.2
# Take the default agg for all cols
Expand All @@ -133,9 +135,11 @@ def agg_over_runs(
)
)
.assign(**{
tc_error: lambda df: df[tc_error] # noqa: B023 # False positive
* confidence_interval_95
/ np.sqrt(params.records_to_average)
tc_error: lambda df: (
df[tc_error] # noqa: B023 # False positive
* confidence_interval_95
/ np.sqrt(params.records_to_average)
)
for tc_error in tc_errors
})
)
Expand All @@ -147,7 +151,7 @@ def get_superheat(df: pd.DataFrame, params: Params) -> pd.DataFrame:
# Explicitly index the trial to catch improper application of the mean
trial = get_trial(df, params)
return df.assign(**{
A.DT: lambda df: (df[A.T_s] - df.loc[trial.date.isoformat(), A.T_w].mean()),
A.DT: lambda df: df[A.T_s] - df.loc[trial.date.isoformat(), A.T_w].mean(),
A.DT_err: lambda df: df[A.T_s_err],
})

Expand Down
3 changes: 2 additions & 1 deletion src/boilerdata/stages/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def get_runs(params: Params) -> pd.DataFrame:
)

return (
pd.concat(runs)
pd
.concat(runs)
.set_index(
pd.MultiIndex.from_tuples(
multiindex, names=[idx.name for idx in params.axes.index]
Expand Down
2 changes: 1 addition & 1 deletion src/boilerdata/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pandera import Check, Column, DataFrameSchema, Index, MultiIndex
from pandera.errors import SchemaError

from boilerdata.axes_enum import AxesEnum as A # noqa: N814
from boilerdata.axes_enum import AxesEnum as A
from boilerdata.models.params import PARAMS

c = {ax.name: ax for ax in PARAMS.axes.all}
Expand Down
Loading