Skip to content

Commit

Permalink
Merge pull request #194 from jorenham/feature/markdownlint
Browse files Browse the repository at this point in the history
Use markdownlint
  • Loading branch information
jorenham authored Apr 9, 2024
2 parents 8de07ff + 0da628e commit 0308acc
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ trim_trailing_whitespace = true
max_line_length = 79

# 2 space indentation
[{*.json,*.yaml,*.yml,}]
[{*.json,*.jsonc,*.yaml,*.yml}]
indent_size = 2
39 changes: 4 additions & 35 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,20 @@ __pycache__/
*$py.class

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
site/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Unit test / coverage reports
.coverage
.coverage.*
.cache
coverage.xml
*.cover
*.py,cover
.hypothesis/
# Cache
.hypothesis
.pytest_cache/
cover/
.ruff_cache/
.pyright/

# Jupyter Notebook
.ipynb_checkpoints

# Environments
.env
.venv/
env/
venv/
ENV/
env.bak/
venv.bak/

# IDE configuration
# IntelliJ
.idea/
.vscode/
.run/
13 changes: 13 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
default: true
no-hard-tabs: true
MD007:
indent: 4
MD033:
allowed_elements:
- 'br'
- 'table'
- 'tr'
- 'th'
- 'td'
- 'img'
MD041: false
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repos:
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
args: [--unsafe]
- id: destroyed-symlinks
- id: detect-private-key
- id: fix-byte-order-marker
Expand All @@ -20,6 +21,12 @@ repos:
- id: no-commit-to-branch
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
exclude_types: [svg]

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
hooks:
- id: markdownlint

- repo: https://github.com/python-poetry/poetry
rev: 1.8.2
Expand Down
14 changes: 14 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"recommendations": [
"charliermarsh.ruff",
"codezombiech.gitignore",
"davidanson.vscode-markdownlint",
"editorconfig.editorconfig",
"elagil.pre-commit-helper",
"ms-python.python",
"ms-python.vscode-pylance",
"serhioromano.vscode-gitflow",
"yzhang.markdown-all-in-one",
"zeshuaro.vscode-python-poetry"
]
}
68 changes: 33 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
<!--overview-start-->

<img src="https://jorenham.github.io/Lmo/img/lmo.svg" alt="jorenham/lmo" width="128" align="right">

# Lmo - Trimmed L-moments and L-comoments

[![license](https://img.shields.io/github/license/jorenham/lmo?style=flat-square)](https://github.com/jorenham/lmo/blob/master/LICENSE?)
[![PyPI](https://img.shields.io/pypi/v/lmo?style=flat-square)](https://pypi.org/project/lmo/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/Lmo?style=flat-square)](https://pypi.org/project/lmo/)
[![versions](https://img.shields.io/pypi/pyversions/lmo?style=flat-square)](https://github.com/jorenham/lmo)
![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/jorenham/lmo/CI.yml?branch=master&style=flat-square)
![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/m/jorenham/Lmo?style=flat-square)
[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)



~~~
Is your tail too heavy?
Can't find a moment?
Are the swans black?
The distribution pathological?
... then look no further: Lmo's got you covered!
Uniform or multi-dimensional, Lmo can summarize it all with one quick glance!
~~~

Unlike the legacy [moments](https://wikipedia.org/wiki/Moment_(mathematics)),
[L-moments](https://wikipedia.org/wiki/L-moment) **uniquely describe** a
![GitHub Workflow Status][IMG-GHA]
![license][IMG-BSD]
[![Lmo - PyPI][IMG-PYPI]](https://pypi.org/project/Lmo/)
[![Lmo - Versions][IMG-VER]](https://github.com/jorenham/Lmo)
[![Ruff][IMG-RUFF]](https://github.com/astral-sh/ruff)
[![Pyright][IMG-PYRIGHT]](https://microsoft.github.io/pyright/)

[IMG-GHA]: https://img.shields.io/github/actions/workflow/status/jorenham/Lmo/CI.yml?branch=master
[IMG-BSD]: https://img.shields.io/github/license/jorenham/Lmo
[IMG-PYPI]: https://img.shields.io/pypi/v/Lmo
[IMG-VER]: https://img.shields.io/pypi/pyversions/Lmo
[IMG-RUFF]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
[IMG-PYRIGHT]: https://microsoft.github.io/pyright/img/pyright_badge.svg

Unlike the legacy
[product-moments](https://wikipedia.org/wiki/Moment_(mathematics)), the
[*L-moments*](https://wikipedia.org/wiki/L-moment) **uniquely describe** a
probability distribution, and are more robust and efficient.

The "L" stands for Linear; it is a linear combination of order statistics.
So Lmo is as fast as sorting your samples (in terms of time-complexity).

Expand Down Expand Up @@ -98,17 +89,24 @@ pip install lmo

These are automatically installed by your package manager, alongside `lmo`.

| Package | Minimum version |
| --- | --- |
| [Python](https://github.com/python/cpython) | `3.10` |
| [NumPy](https://github.com/numpy/numpy) | `1.22` |
| [SciPy](https://github.com/scipy/scipy) | `1.9` |
| Package | Minimum version |
| ------------ | ------------------- |
| [Python][PY] | `3.10` |
| [NumPy][NP] | See [NEP 29][NEP29] |
| [SciPy][SP] | `1.9` |

[PY]: https://github.com/python/cpython
[NP]: https://github.com/numpy/numpy
[SP]: https://github.com/scipy/scipy
[NEP29]: https://numpy.org/neps/nep-0029-deprecation_policy.html#support-table

### Optional dependencies

| Package | Minimum version | Notes
| --- | --- | --- |
| [Pandas](https://github.com/pandas-dev/pandas) | `1.4` | Lmo extends `pd.Series` and `pd.DataFrame` with convenient methods, e.g. `df.l_scale(trim=1)`. Install as `pip install lmo[pandas]` to ensure compatibility. |
| Package | Minimum version | Notes |
| ------------ | --------------- | ---------------------------- |
| [Pandas][PD] | `1.4` | Installable as `lmo[pandas]` |

[PD]: https://github.com/pandas-dev/pandas

## Foundational Literature

Expand Down
22 changes: 14 additions & 8 deletions docs/distributions.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- markdownlint-disable MD051 MD052 -->
# L-moments of common probability distributions

This page lists theoretical L-moments of popular probability distributions.
Expand Down Expand Up @@ -772,7 +773,6 @@ The [Gompertz distribution](https://wikipedia.org/wiki/Gompertz_distribution)
[^GOMP] with shape parameter \( \alpha > 0 \) and \( x \ge 0 \), has the
following CDF and PPF:


\[
\begin{align*}
F(x) &= 1 - e^{\alpha (1 - e^x)} \\
Expand Down Expand Up @@ -800,7 +800,8 @@ The general trimmed L-moments of the Gompertz distribution are:

### GEV

The [GEV](https://wikipedia.org/wiki/GEV_distribution) unifies the
The [GEV](https://wikipedia.org/wiki/GEV_distribution) distribution [^GEV]
unifies the
[Gumbel](https://wikipedia.org/wiki/Gumbel_distribution),
[Fréchet](https://wikipedia.org/wiki/Fr%C3%A9chet_distribution),
and [Weibull](https://wikipedia.org/wiki/Weibull_distribution) distributions.
Expand Down Expand Up @@ -1038,9 +1039,12 @@ The distribution functions for \( x > 0 \) are defined as:
\end{align*}
\]

<img src="../gallery/burr12.svg" width="100%"
<img
src="../gallery/burr12.svg"
width="100%"
style="height: auto; aspect-ratio: 16/9;"
alt="Burr XII distribution PDF" />
alt="Burr XII distribution PDF"
/>

When \( \beta > 1 / \alpha \), the general \( r \)-th trimmed L-moment is:

Expand Down Expand Up @@ -1090,7 +1094,7 @@ shapes \( \gamma \equiv 1 / \alpha \) and \( \alpha' \equiv \beta \), location

For [Kumaraswamy's distribution
](https://wikipedia.org/wiki/Kumaraswamy_distribution) [^KUM1] with parameters
\( \alpha \in \mathbb{R}_{>0} \) and \( \beta \in \mathbb{R}_{>0} \),
<!-- markdownlint-disable-line -->\( \alpha \in \mathbb{R}_{>0} \) and \( \beta \in \mathbb{R}_{>0} \),
the general solution for the \( r \)th (untrimmed L-moment has been derived by
M.C. Jones in 2009 [^KUM2]. Lmo has extended these results for the general
trimmed L-moments.
Expand Down Expand Up @@ -1147,8 +1151,8 @@ There are several notable special cases of the Kumaraswamy distribution:
### Wakeby

The [*Wakeby distribution*](https://wikipedia.org/wiki/Wakeby_distribution)
[^WAK] is quantile-based -- the CDF and PDF are not analytically expressible for the
general case.
[^WAK] is quantile-based -- the CDF and PDF are not analytically expressible
for the general case.
Without loss of generality, Lmo uses a 3-parameter "standardized"
paremetrization, with shape parameters \( \beta,\ \delta,\ \phi \).

Expand Down Expand Up @@ -1331,6 +1335,7 @@ r \tlmoment{s, t}{r}

and the arbitrarily-trimmed L-location is

<!-- markdownlint-disable -->
\[
\tlmoment{s, t}{1}
= -(1 + \phi) \mathfrak{L}_{1}^{(s)}(\beta)
Expand All @@ -1351,6 +1356,7 @@ where
& \text{otherwise.}
\end{cases}
\]
<!-- markdownlint-enable -->

These equations look scarier that they actually are. To see why, take a look
at the first 4 L-moment, with 4 styles of trimming:
Expand Down Expand Up @@ -1549,6 +1555,7 @@ There are several notable special cases of the GLD:
generating asymmetric random variables

## Constants and special functions
<!-- markdownlint-disable MD051 MD052 -->

An overview of the (non-obvious) mathematical notation of special functions
and constants.
Expand Down Expand Up @@ -1808,7 +1815,6 @@ and constants.
</tr>
</table>


*[STD]: Standard deviation
*[MAD]: Median absolute deviation
*[RV]: Random variable
Expand Down
5 changes: 2 additions & 3 deletions docs/gallery/burr12.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# pyright: reportUnknownMemberType=false
# pyright: reportUnknownMemberType=false, reportUnusedCallResult=false
from pathlib import Path

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

from scipy.stats import burr12 # type: ignore
from scipy.stats import burr12

GALLERY_PATH = Path(__file__).resolve().parent
TEX_LABEL_TEMPLATE = r'$\alpha = {},\ \beta = {}$'
Expand Down Expand Up @@ -55,4 +55,3 @@
format='svg',
bbox_inches='tight'
)

3 changes: 1 addition & 2 deletions docs/gallery/genlambda.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pyright: reportUnknownMemberType=false
# pyright: reportUnknownMemberType=false, reportUnusedCallResult=false
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -60,4 +60,3 @@
format='svg',
bbox_inches='tight'
)

3 changes: 1 addition & 2 deletions docs/gallery/kumaraswamy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pyright: reportUnknownMemberType=false
# pyright: reportUnknownMemberType=false, reportUnusedCallResult=false
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -54,4 +54,3 @@
format='svg',
bbox_inches='tight'
)

3 changes: 1 addition & 2 deletions docs/gallery/wakeby.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pyright: reportUnknownMemberType=false
# pyright: reportUnknownMemberType=false, reportUnusedCallResult=false
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -54,4 +54,3 @@
format='svg',
bbox_inches='tight'
)

0 comments on commit 0308acc

Please sign in to comment.