From fe0e8cd02357fce397f8a2085d7b2b7b60a4f745 Mon Sep 17 00:00:00 2001 From: Joshua Eckels Date: Wed, 28 Aug 2024 15:18:46 -0600 Subject: [PATCH] style: small doc and ci fixes --- .github/workflows/deploy.yml | 2 +- README.md | 3 ++- docs/assets/logo.svg | 2 +- src/uqtils/example.py | 11 ++++------- src/uqtils/sobol.py | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 35faa6d..fc2db2f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -61,6 +61,6 @@ jobs: with: body_path: body.md tag_name: ${{ github.ref_name }} - files: dist/** + files: dist/* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index d327e94..50b9c39 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ ![Logo](https://raw.githubusercontent.com/eckelsjd/uqtils/main/docs/assets/logo.svg) + [![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm-project.org) [![Python version](https://img.shields.io/badge/python-3.11+-blue.svg?logo=python&logoColor=cccccc)](https://www.python.org/downloads/) [![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json)](https://github.com/eckelsjd/copier-numpy) @@ -6,7 +7,7 @@ ![build](https://img.shields.io/github/actions/workflow/status/eckelsjd/uqtils/deploy.yml?logo=github) ![docs](https://img.shields.io/github/actions/workflow/status/eckelsjd/uqtils/docs.yml?logo=materialformkdocs&logoColor=%2523cccccc&label=docs) ![tests](https://img.shields.io/github/actions/workflow/status/eckelsjd/uqtils/tests.yml?logo=github&logoColor=%2523cccccc&label=tests) -![Code Coverage](https://img.shields.io/badge/coverage-87%25-yellowgreen?logo=codecov) +![Code Coverage](https://img.shields.io/badge/coverage-88%25-yellowgreen?logo=codecov) Assorted utilities for uncertainty quantification and scientific computing. diff --git a/docs/assets/logo.svg b/docs/assets/logo.svg index 4eb9259..0dc54ab 100644 --- a/docs/assets/logo.svg +++ b/docs/assets/logo.svg @@ -1 +1 @@ - + diff --git a/src/uqtils/example.py b/src/uqtils/example.py index 9f32495..4906153 100644 --- a/src/uqtils/example.py +++ b/src/uqtils/example.py @@ -1,11 +1,11 @@ """Examples for using the package.""" # ruff: noqa: F841 +# ruff: noqa: I001 def normal_example(): """Sample and plot a normal pdf.""" # --8<-- [start:normal] import numpy as np - import uqtils as uq ndim = 3 @@ -25,7 +25,6 @@ def gradient_example(): """Evaluate 1d and multivariate gradients.""" # --8<-- [start:gradient] import numpy as np - import uqtils as uq # 1d example @@ -55,7 +54,6 @@ def mcmc_example(): """Sample from a logpdf distribution using MCMC.""" # --8<-- [start:mcmc] import numpy as np - import uqtils as uq def fun(x): @@ -78,12 +76,11 @@ def sobol_example(): """Do Sobol' analysis on the Ishigami test function.""" # --8<-- [start:sobol] import numpy as np + import uqtils as uq - from uqtils.sobol import ishigami, sobol_sa - - model = lambda x: ishigami(x)['y'] + model = lambda x: uq.ishigami(x)['y'] sampler = lambda shape: np.random.rand(*shape, 3) * (2 * np.pi) - np.pi n_samples = 1000 - S1, ST = sobol_sa(model, sampler, n_samples) + S1, ST = uq.sobol_sa(model, sampler, n_samples) # --8<-- [end:sobol] diff --git a/src/uqtils/sobol.py b/src/uqtils/sobol.py index 5a01c3f..215d1e5 100644 --- a/src/uqtils/sobol.py +++ b/src/uqtils/sobol.py @@ -10,7 +10,7 @@ from uqtils import ax_default -__all__ = ['sobol_sa'] +__all__ = ['sobol_sa', 'ishigami'] def sobol_sa(model, sampler, num_samples: int, qoi_idx: list[int] = None, qoi_labels: list[str] = None, @@ -229,5 +229,5 @@ def sobol_sa(model, sampler, num_samples: int, qoi_idx: list[int] = None, qoi_la def ishigami(x, a=7.0, b=0.1): - """For testing Sobol indices: https://doi.org/10.1109/ISUMA.1990.151285""" + """For testing Sobol indices: [Ishigami function](https://doi.org/10.1109/ISUMA.1990.151285)""" return {'y': np.sin(x[..., 0:1]) + a*np.sin(x[..., 1:2])**2 + b*(x[..., 2:3]**4)*np.sin(x[..., 0:1])}