From 1ad72bdb2cb0e0f8436ae7c3ad9b691ede2b7888 Mon Sep 17 00:00:00 2001 From: sdupourque Date: Mon, 15 Apr 2024 18:27:27 +0200 Subject: [PATCH] linting with new rules --- .pre-commit-config.yaml | 4 ++-- docs/examples/advanced_examples/plot_0_grid.py | 1 + docs/examples/advanced_examples/plot_1_blinding.py | 1 + docs/examples/advanced_examples/plot_2_kde.py | 1 + docs/examples/advanced_examples/plot_3_divide_chains.py | 1 + .../examples/advanced_examples/plot_4_misc_chain_visuals.py | 1 + docs/examples/plot_0_contours.py | 1 + docs/examples/plot_1_summary.py | 1 + docs/examples/plot_2_textual_output.py | 1 + docs/examples/plot_3_distributions.py | 1 + docs/examples/plot_4_walks.py | 1 + docs/examples/plot_6_custom_axes.py | 1 + src/chainconsumer/analysis.py | 6 +++--- src/chainconsumer/chain.py | 1 + 14 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e82621c5..0ab70bbf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-added-large-files args: ["--maxkb=5000"] @@ -14,7 +14,7 @@ repos: - --unsafe - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.14 + rev: v0.3.7 hooks: - id: ruff args: ["--fix", "--no-unsafe-fixes"] diff --git a/docs/examples/advanced_examples/plot_0_grid.py b/docs/examples/advanced_examples/plot_0_grid.py index a58697b8..1b45d674 100644 --- a/docs/examples/advanced_examples/plot_0_grid.py +++ b/docs/examples/advanced_examples/plot_0_grid.py @@ -15,6 +15,7 @@ the order of the parameters is not preserved in the dictionary. """ + import numpy as np import pandas as pd diff --git a/docs/examples/advanced_examples/plot_1_blinding.py b/docs/examples/advanced_examples/plot_1_blinding.py index b03cbdef..555f6371 100644 --- a/docs/examples/advanced_examples/plot_1_blinding.py +++ b/docs/examples/advanced_examples/plot_1_blinding.py @@ -8,6 +8,7 @@ or give it a string (or list of strings) detailing the specific parameters you want blinded! """ + from chainconsumer import Chain, ChainConsumer, PlotConfig, make_sample df = make_sample(num_dimensions=4, seed=1) diff --git a/docs/examples/advanced_examples/plot_2_kde.py b/docs/examples/advanced_examples/plot_2_kde.py index 6e427122..a0a91e58 100644 --- a/docs/examples/advanced_examples/plot_2_kde.py +++ b/docs/examples/advanced_examples/plot_2_kde.py @@ -15,6 +15,7 @@ increses the width of the marginal distributions. """ + from chainconsumer import Chain, ChainConsumer, PlotConfig, make_sample df = make_sample(num_dimensions=2, seed=3, num_points=1000) diff --git a/docs/examples/advanced_examples/plot_3_divide_chains.py b/docs/examples/advanced_examples/plot_3_divide_chains.py index c4d9b4d8..4d0dc7bb 100644 --- a/docs/examples/advanced_examples/plot_3_divide_chains.py +++ b/docs/examples/advanced_examples/plot_3_divide_chains.py @@ -12,6 +12,7 @@ In this toy example, all the chains are from the same random generator, so they're on top of each other. Except MCMC chains to not be as perfect. """ + from chainconsumer import Chain, ChainConsumer, PlotConfig, make_sample df = make_sample(num_dimensions=2, seed=3, num_points=40000) diff --git a/docs/examples/advanced_examples/plot_4_misc_chain_visuals.py b/docs/examples/advanced_examples/plot_4_misc_chain_visuals.py index 7f55f4de..dff18149 100644 --- a/docs/examples/advanced_examples/plot_4_misc_chain_visuals.py +++ b/docs/examples/advanced_examples/plot_4_misc_chain_visuals.py @@ -3,6 +3,7 @@ Rather than having one example for each option, let's condense things. """ + # %% # Shade Gradient # -------------- diff --git a/docs/examples/plot_0_contours.py b/docs/examples/plot_0_contours.py index 85995424..a44a5d35 100644 --- a/docs/examples/plot_0_contours.py +++ b/docs/examples/plot_0_contours.py @@ -5,6 +5,7 @@ handle the defaults and display. """ + from chainconsumer import Chain, ChainConfig, ChainConsumer, PlotConfig, Truth, make_sample # Here's what you might start with diff --git a/docs/examples/plot_1_summary.py b/docs/examples/plot_1_summary.py index 35e84b87..150e2aef 100644 --- a/docs/examples/plot_1_summary.py +++ b/docs/examples/plot_1_summary.py @@ -7,6 +7,7 @@ To show you how they work, let's make some sample data that all has the same average. """ + from chainconsumer import Chain, ChainConfig, ChainConsumer, PlotConfig, Truth, make_sample # Here's what you might start with diff --git a/docs/examples/plot_2_textual_output.py b/docs/examples/plot_2_textual_output.py index 8606c70e..b2cfc81d 100644 --- a/docs/examples/plot_2_textual_output.py +++ b/docs/examples/plot_2_textual_output.py @@ -4,6 +4,7 @@ Because typing those things out is a **massive pain in the ass.** """ + from chainconsumer import Chain, ChainConsumer, Truth, make_sample # Here's a sample dataset diff --git a/docs/examples/plot_3_distributions.py b/docs/examples/plot_3_distributions.py index 36ac4875..38ee4512 100644 --- a/docs/examples/plot_3_distributions.py +++ b/docs/examples/plot_3_distributions.py @@ -7,6 +7,7 @@ To show you how they work, let's make some sample data that all has the same average. """ + from chainconsumer import Chain, ChainConsumer, Truth, make_sample # Here's what you might start with diff --git a/docs/examples/plot_4_walks.py b/docs/examples/plot_4_walks.py index d4d4bf75..40352a3f 100644 --- a/docs/examples/plot_4_walks.py +++ b/docs/examples/plot_4_walks.py @@ -3,6 +3,7 @@ Want to see if your chain is behaving nicely? Use a walk! """ + from chainconsumer import Chain, ChainConsumer, Truth, make_sample # Here's a sample dataset diff --git a/docs/examples/plot_6_custom_axes.py b/docs/examples/plot_6_custom_axes.py index 6ff1f8d9..026816e0 100644 --- a/docs/examples/plot_6_custom_axes.py +++ b/docs/examples/plot_6_custom_axes.py @@ -8,6 +8,7 @@ Here's an example, noting that there are also `plot_point`, `plot_surface` available that I haven't explicitly shown. """ + import matplotlib.pyplot as plt from chainconsumer import Chain, Truth, make_sample diff --git a/src/chainconsumer/analysis.py b/src/chainconsumer/analysis.py index da67b11e..0e81688c 100644 --- a/src/chainconsumer/analysis.py +++ b/src/chainconsumer/analysis.py @@ -26,9 +26,9 @@ class Bound(BetterBase): def array(self) -> np.ndarray: return np.array( [ - self.lower if self.lower is not None else np.NaN, - self.center if self.center is not None else np.NaN, - self.upper if self.upper is not None else np.NaN, + self.lower if self.lower is not None else np.nan, + self.center if self.center is not None else np.nan, + self.upper if self.upper is not None else np.nan, ] ) diff --git a/src/chainconsumer/chain.py b/src/chainconsumer/chain.py index a0335ae3..4ee454f7 100644 --- a/src/chainconsumer/chain.py +++ b/src/chainconsumer/chain.py @@ -7,6 +7,7 @@ There are also a few helper functions and objects in here, like the `MaxPosterior` class which provides the log posterior and the coordinate at which it can be found for the chain.""" + from __future__ import annotations import logging