From 89df30613c653b9207a54168e93abbbae15907d1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 17:34: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/pre-commit/pre-commit-hooks: v4.4.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v5.0.0) - [github.com/psf/black: 23.3.0 → 25.1.0](https://github.com/psf/black/compare/23.3.0...25.1.0) - https://github.com/charliermarsh/ruff-pre-commit → https://github.com/astral-sh/ruff-pre-commit - [github.com/astral-sh/ruff-pre-commit: v0.0.262 → v0.9.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.262...v0.9.6) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3bd8bf7c..a955eee7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,17 +2,17 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-added-large-files - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 25.1.0 hooks: - id: black -- repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.262' +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: 'v0.9.6' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 23a1dba54b497b560fb43a6ed46073b49de6f4c4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 17:35:06 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- delphi/log/result_analysis.py | 12 ++++++------ .../oai_autointerp/explanations/simulator.py | 2 +- examples/caching_activations.ipynb | 4 ++-- examples/score_explanations.ipynb | 12 +++++------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/delphi/log/result_analysis.py b/delphi/log/result_analysis.py index 1cccf0a6..e46068f6 100644 --- a/delphi/log/result_analysis.py +++ b/delphi/log/result_analysis.py @@ -153,12 +153,12 @@ def parse_score_file(file_path): "total_examples": total_examples, "total_positives": total_positives, "total_negatives": total_negatives, - "positive_class_ratio": total_positives / total_examples - if total_examples > 0 - else 0, - "negative_class_ratio": total_negatives / total_examples - if total_examples > 0 - else 0, + "positive_class_ratio": ( + total_positives / total_examples if total_examples > 0 else 0 + ), + "negative_class_ratio": ( + total_negatives / total_examples if total_examples > 0 else 0 + ), "failed_count": failed_count, } diff --git a/delphi/scorers/simulator/oai_autointerp/explanations/simulator.py b/delphi/scorers/simulator/oai_autointerp/explanations/simulator.py index c7bcaf82..eb29e0dd 100644 --- a/delphi/scorers/simulator/oai_autointerp/explanations/simulator.py +++ b/delphi/scorers/simulator/oai_autointerp/explanations/simulator.py @@ -87,7 +87,7 @@ def from_string(cls, s: str) -> SimulationType: def compute_expected_value( - norm_probabilities_by_distribution_value: OrderedDict[int, float] + norm_probabilities_by_distribution_value: OrderedDict[int, float], ) -> float: """ Given a map from distribution values (integers on the range [0, 10]) to normalized diff --git a/examples/caching_activations.ipynb b/examples/caching_activations.ipynb index 53b5c87f..ad54ccf5 100644 --- a/examples/caching_activations.ipynb +++ b/examples/caching_activations.ipynb @@ -36,8 +36,8 @@ "source": [ "from transformers import AutoModel\n", "\n", - "from delphi.sparse_coders import load_sparse_coders\n", - "from delphi.config import RunConfig\n" + "from delphi.config import RunConfig\n", + "from delphi.sparse_coders import load_sparse_coders\n" ] }, { diff --git a/examples/score_explanations.ipynb b/examples/score_explanations.ipynb index 7b2c0754..5e65acc0 100644 --- a/examples/score_explanations.ipynb +++ b/examples/score_explanations.ipynb @@ -20,23 +20,21 @@ "metadata": {}, "outputs": [], "source": [ + "import os\n", "from functools import partial\n", - "import os \n", - "import torch\n", + "\n", "import orjson\n", + "import torch\n", + "\n", "from delphi.clients import OpenRouter\n", "from delphi.config import ExperimentConfig, LatentConfig\n", "from delphi.explainers import explanation_loader\n", - "from delphi.latents import (\n", - " LatentDataset\n", - ")\n", + "from delphi.latents import LatentDataset\n", "from delphi.latents.constructors import default_constructor\n", "from delphi.latents.samplers import sample\n", "from delphi.pipeline import Pipeline, process_wrapper\n", "from delphi.scorers import FuzzingScorer\n", "\n", - "\n", - "\n", "API_KEY = os.getenv(\"OPENROUTER_API_KEY\")" ] },