From 3cee6c471db7281c6793469256cbe2fa2877b872 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:56:57 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.1 → v0.9.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.1...v0.9.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d0611fa..cc99834 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.8.1 + rev: v0.9.1 hooks: # Run the linter. - id: ruff From 3183afed012577176cb2ce30d281a7f48841b793 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:57:04 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sharrow/digital_encoding.py | 6 +++--- sharrow/flows.py | 8 ++++---- sharrow/shared_memory.py | 2 +- sharrow/viz.py | 4 ++-- sharrow/wrappers.py | 18 +++++++++--------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/sharrow/digital_encoding.py b/sharrow/digital_encoding.py index 95a1cc1..3ac0d65 100644 --- a/sharrow/digital_encoding.py +++ b/sharrow/digital_encoding.py @@ -359,9 +359,9 @@ def multivalue_digitize_by_dictionary(ds, encode_vars=None, encoding_name=None): encode_var_dims = ds[encode_vars[0]].dims for v in encode_vars[1:]: - assert ( - encode_var_dims == ds[v].dims - ), f"dims must match, {encode_var_dims} != {ds[v].dims}" + assert encode_var_dims == ds[v].dims, ( + f"dims must match, {encode_var_dims} != {ds[v].dims}" + ) logger.info("assembling data stack") conjoined = np.stack( [array_decode(ds[v].compute(), aux_data=ds) for v in encode_vars], axis=-1 diff --git a/sharrow/flows.py b/sharrow/flows.py index 065b75f..ea9c82b 100644 --- a/sharrow/flows.py +++ b/sharrow/flows.py @@ -1749,7 +1749,7 @@ def __initialize_2( textwrap.dedent( f""" # this module generated automatically using sharrow version {__version__} - # generation time: {time.strftime('%d %B %Y %I:%M:%S %p')} + # generation time: {time.strftime("%d %B %Y %I:%M:%S %p")} """ )[1:] ) @@ -1830,7 +1830,7 @@ def __initialize_2( if f_args_j: f_args_j += ", " meta_code.append( - f"{clean(k)}_dim{n_root_dims+1}_filler(result, {n}, {f_name_tokens})" + f"{clean(k)}_dim{n_root_dims + 1}_filler(result, {n}, {f_name_tokens})" ) meta_code_dot.append( f"intermediate[{n}] = ({clean(k)}({f_args_j}intermediate, {f_name_tokens})).item()" @@ -2268,9 +2268,9 @@ def check_cache_misses(self, *funcs, fresh=True, log_details=True): ) if isinstance(timers, float): if timers < 1e-3: - timers = f"{timers/1e-6:.0f} µs" + timers = f"{timers / 1e-6:.0f} µs" elif timers < 1: - timers = f"{timers/1e-3:.1f} ms" + timers = f"{timers / 1e-3:.1f} ms" else: timers = f"{timers:.2f} s" logger.warning( diff --git a/sharrow/shared_memory.py b/sharrow/shared_memory.py index 4ec3b6d..d93b38f 100644 --- a/sharrow/shared_memory.py +++ b/sharrow/shared_memory.py @@ -44,7 +44,7 @@ def si_units(x, kind="B", digits=3, shift=1000): while x < 1 and tier >= 0: x *= shift tier -= 1 - return f"{sign}{round(x,digits)} {tiers[tier]}{kind}" + return f"{sign}{round(x, digits)} {tiers[tier]}{kind}" def _hexhash(t, size=10, prefix="sharr"): diff --git a/sharrow/viz.py b/sharrow/viz.py index 867a81f..0aeb07e 100644 --- a/sharrow/viz.py +++ b/sharrow/viz.py @@ -16,7 +16,7 @@ def make_graph(datatree, fontname="Arial", fontsize=12, ignore_joined_dims=True) if viz is None: raise ModuleNotFoundError("pygraphviz is not installed") - small = f"{fontsize * .7:.1f}" + small = f"{fontsize * 0.7:.1f}" g = viz.AGraph(rankdir="LR", strict=False, fontname=fontname, fontsize=fontsize) connected_nodes = set() @@ -117,7 +117,7 @@ def node_label(k, v): out = f"""< - {''.join(cells)} + {"".join(cells)}
{k}
>""" return out diff --git a/sharrow/wrappers.py b/sharrow/wrappers.py index baeb1e5..d88a8eb 100644 --- a/sharrow/wrappers.py +++ b/sharrow/wrappers.py @@ -109,16 +109,16 @@ def set_df(self, df): ------- self (to facilitate chaining) """ - assert ( - self.orig_key in df - ), f"orig_key '{self.orig_key}' not in df columns: {list(df.columns)}" - assert ( - self.dest_key in df - ), f"dest_key '{self.dest_key}' not in df columns: {list(df.columns)}" + assert self.orig_key in df, ( + f"orig_key '{self.orig_key}' not in df columns: {list(df.columns)}" + ) + assert self.dest_key in df, ( + f"dest_key '{self.dest_key}' not in df columns: {list(df.columns)}" + ) if self.time_key: - assert ( - self.time_key in df - ), f"time_key '{self.time_key}' not in df columns: {list(df.columns)}" + assert self.time_key in df, ( + f"time_key '{self.time_key}' not in df columns: {list(df.columns)}" + ) self.df = df # TODO allow non-1 offsets