From 73211cc478619a0f13186cbfdf005d8b1097db8b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Aug 2026 16:51:11 +0000 Subject: [PATCH 1/2] chore: update pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.13 → v0.16.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.13...v0.16.4) - [github.com/pre-commit/pre-commit-hooks: v5.0.0 → v6.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v5.0.0...v6.0.0) - [github.com/kynan/nbstripout: 0.8.1 → 0.9.1](https://github.com/kynan/nbstripout/compare/0.8.1...0.9.1) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d2075a6..43322b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ ci: repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.11.13" + rev: "v0.16.4" hooks: - id: ruff types_or: [python, pyi, jupyter] @@ -17,7 +17,7 @@ repos: types_or: [python, pyi, jupyter] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: trailing-whitespace exclude: '.*\.fits$' @@ -31,7 +31,7 @@ repos: args: ["--maxkb=10000"] - repo: https://github.com/kynan/nbstripout - rev: 0.8.1 + rev: 0.9.1 hooks: - id: nbstripout args: ["--extra-keys=metadata.kernelspec metadata.language_info.version metadata.toc"] From f9e600ab3c8072eb501595d44bb7d40f2376a688 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Aug 2026 16:53:14 +0000 Subject: [PATCH 2/2] style: pre-commit fixes --- 1_models-quick-fit.ipynb | 32 +++++++++++++------------------- 2_user-defined-model.ipynb | 17 ++++++++--------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/1_models-quick-fit.ipynb b/1_models-quick-fit.ipynb index dbb4b57..bf08334 100755 --- a/1_models-quick-fit.ipynb +++ b/1_models-quick-fit.ipynb @@ -37,11 +37,11 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as np\n", "import matplotlib.pyplot as plt\n", - "from astropy.modeling import models, fitting\n", - "from astroquery.vizier import Vizier\n", + "import numpy as np\n", "import scipy.optimize\n", + "from astropy.modeling import fitting, models\n", + "from astroquery.vizier import Vizier\n", "\n", "# Make plots display in notebooks\n", "%matplotlib inline" @@ -439,7 +439,7 @@ "outputs": [], "source": [ "reduced_chi_squared = calc_reduced_chi_square(best_fit_poly(x1), x1, y1, y1_err, N, 4)\n", - "print(\"Reduced Chi Squared with LinearLSQFitter: {}\".format(reduced_chi_squared))" + "print(f\"Reduced Chi Squared with LinearLSQFitter: {reduced_chi_squared}\")" ] }, { @@ -449,7 +449,7 @@ "outputs": [], "source": [ "reduced_chi_squared = calc_reduced_chi_square(best_fit_poly_2(x1), x1, y1, y1_err, N, 4)\n", - "print(\"Reduced Chi Squared with SimplexLSQFitter: {}\".format(reduced_chi_squared))" + "print(f\"Reduced Chi Squared with SimplexLSQFitter: {reduced_chi_squared}\")" ] }, { @@ -592,15 +592,9 @@ "metadata": {}, "outputs": [], "source": [ - "print(\n", - " \"Amplitude: {} +\\- {}\".format(best_fit_gauss.amplitude.value, np.sqrt(cov_diag[0]))\n", - ")\n", - "print(\"Mean: {} +\\- {}\".format(best_fit_gauss.mean.value, np.sqrt(cov_diag[1])))\n", - "print(\n", - " \"Standard Deviation: {} +\\- {}\".format(\n", - " best_fit_gauss.stddev.value, np.sqrt(cov_diag[2])\n", - " )\n", - ")" + "print(rf\"Amplitude: {best_fit_gauss.amplitude.value} +\\- {np.sqrt(cov_diag[0])}\")\n", + "print(rf\"Mean: {best_fit_gauss.mean.value} +\\- {np.sqrt(cov_diag[1])}\")\n", + "print(rf\"Standard Deviation: {best_fit_gauss.stddev.value} +\\- {np.sqrt(cov_diag[2])}\")" ] }, { @@ -646,9 +640,9 @@ "metadata": {}, "outputs": [], "source": [ - "print(\"Amplitude: {} +\\- {}\".format(p_opt[0], np.sqrt(p_cov[0, 0])))\n", - "print(\"Mean: {} +\\- {}\".format(p_opt[1], np.sqrt(p_cov[1, 1])))\n", - "print(\"Standard Deviation: {} +\\- {}\".format(p_opt[2], np.sqrt(p_cov[2, 2])))" + "print(rf\"Amplitude: {p_opt[0]} +\\- {np.sqrt(p_cov[0, 0])}\")\n", + "print(rf\"Mean: {p_opt[1]} +\\- {np.sqrt(p_cov[1, 1])}\")\n", + "print(rf\"Standard Deviation: {p_opt[2]} +\\- {np.sqrt(p_cov[2, 2])}\")" ] }, { @@ -665,7 +659,7 @@ "outputs": [], "source": [ "reduced_chi_squared = calc_reduced_chi_square(best_fit_gauss(x2), x2, y2, y2_err, N2, 3)\n", - "print(\"Reduced Chi Squared using astropy.modeling: {}\".format(reduced_chi_squared))" + "print(f\"Reduced Chi Squared using astropy.modeling: {reduced_chi_squared}\")" ] }, { @@ -675,7 +669,7 @@ "outputs": [], "source": [ "reduced_chi_squared = calc_reduced_chi_square(best_fit_gauss_2, x2, y2, y2_err, N2, 3)\n", - "print(\"Reduced Chi Squared using scipy: {}\".format(reduced_chi_squared))" + "print(f\"Reduced Chi Squared using scipy: {reduced_chi_squared}\")" ] }, { diff --git a/2_user-defined-model.ipynb b/2_user-defined-model.ipynb index ebe2699..68f735d 100644 --- a/2_user-defined-model.ipynb +++ b/2_user-defined-model.ipynb @@ -52,11 +52,10 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as np\n", "import matplotlib.pyplot as plt\n", - "from astropy.modeling import models, fitting\n", + "import numpy as np\n", + "from astropy.modeling import Fittable1DModel, Parameter, fitting, models\n", "from astropy.modeling.models import custom_model\n", - "from astropy.modeling import Fittable1DModel, Parameter\n", "from astroquery.sdss import SDSS" ] }, @@ -207,8 +206,8 @@ "plt.plot(lam, flux, color=\"k\")\n", "plt.xlim(6300, 6700)\n", "plt.axvline(x=6563, linestyle=\"--\")\n", - "plt.xlabel(\"Wavelength ({})\".format(units_wavelength))\n", - "plt.ylabel(\"Flux ({})\".format(units_flux))\n", + "plt.xlabel(f\"Wavelength ({units_wavelength})\")\n", + "plt.ylabel(f\"Flux ({units_flux})\")\n", "plt.show()" ] }, @@ -265,7 +264,7 @@ "plt.plot(lam, gaussian_fit(lam), color=\"darkorange\")\n", "plt.xlim(6300, 6700)\n", "plt.xlabel(\"Wavelength (Angstroms)\")\n", - "plt.ylabel(\"Flux ({})\".format(units_flux))\n", + "plt.ylabel(f\"Flux ({units_flux})\")\n", "plt.show()" ] }, @@ -353,7 +352,7 @@ "plt.plot(lam, compound_fit(lam), color=\"darkorange\")\n", "plt.xlim(6300, 6700)\n", "plt.xlabel(\"Wavelength (Angstroms)\")\n", - "plt.ylabel(\"Flux ({})\".format(units_flux))\n", + "plt.ylabel(f\"Flux ({units_flux})\")\n", "plt.show()" ] }, @@ -459,7 +458,7 @@ "plt.plot(lam, compound_fit_fixed(lam), color=\"darkorange\")\n", "plt.xlim(6300, 6700)\n", "plt.xlabel(\"Wavelength (Angstroms)\")\n", - "plt.ylabel(\"Flux ({})\".format(units_flux))\n", + "plt.ylabel(f\"Flux ({units_flux})\")\n", "plt.show()" ] }, @@ -505,7 +504,7 @@ "plt.plot(lam, compound_fit_bounded(lam), color=\"darkorange\")\n", "plt.xlim(6300, 6700)\n", "plt.xlabel(\"Wavelength (Angstroms)\")\n", - "plt.ylabel(\"Flux ({})\".format(units_flux))\n", + "plt.ylabel(f\"Flux ({units_flux})\")\n", "plt.show()" ] },