Skip to content

Commit 2c8a36f

Browse files
authored
refactor: restructure project layout and improve documentation (#107)
refactor: restructure project layout and improve documentation - migrate to pyproject.toml and remove conda-based setup - move package source to `src/` and update CI workflows - switch documentation format from reStructuredText to Markdown - add and update docstrings using Google style, with examples - integrate MkDocs with new workflow and improve README - remove outdated files (e.g. ReadTheDocs config, old notebooks) ref: #106
1 parent 9850ede commit 2c8a36f

File tree

95 files changed

+6690
-3946
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+6690
-3946
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Deploy MkDocs
2+
3+
permissions:
4+
contents: write
5+
pages: write
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
branches:
13+
- '**' # Match all branches for pull requests
14+
release:
15+
types:
16+
- published
17+
18+
jobs:
19+
deploy-pr:
20+
if: github.event_name == 'pull_request'
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: '3.12'
31+
32+
- name: Install dependencies
33+
run: |
34+
pip install .[docs]
35+
36+
- name: Deploy to GitHub Pages (Pull Request)
37+
env:
38+
ACTIONS_DEPLOY_TOKEN: ${{ secrets.ACTIONS_DEPLOY_TOKEN }}
39+
run: |
40+
git config --global user.name '${{ github.actor }}'
41+
git config --global user.email '${{ github.actor }}@users.noreply.github.com'
42+
43+
mike deploy --push develop
44+
45+
deploy-main:
46+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
with:
51+
fetch-depth: 0
52+
53+
- name: Set up Python
54+
uses: actions/setup-python@v4
55+
with:
56+
python-version: '3.12'
57+
58+
- name: Install dependencies
59+
run: |
60+
pip install .[docs]
61+
62+
- name: Deploy to GitHub Pages (Main)
63+
env:
64+
ACTIONS_DEPLOY_TOKEN: ${{ secrets.ACTIONS_DEPLOY_TOKEN }}
65+
run: |
66+
git config --global user.name '${{ github.actor }}'
67+
git config --global user.email '${{ github.actor }}@users.noreply.github.com'
68+
mike deploy --push main
69+
mike set-default --push main
70+
71+
deploy-release:
72+
if: github.event_name == 'release'
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v4
76+
with:
77+
fetch-depth: 0
78+
- name: Set up Python
79+
uses: actions/setup-python@v4
80+
with:
81+
python-version: '3.12'
82+
83+
- name: Install dependencies
84+
run: |
85+
pip install .[docs]
86+
87+
- name: Set release notes tag
88+
run: |
89+
export RELEASE_TAG_VERSION=${{ github.event.release.tag_name }}
90+
echo "RELEASE_TAG_VERSION=${RELEASE_TAG_VERSION}" >> $GITHUB_ENV
91+
92+
- name: Deploy to GitHub Pages
93+
env:
94+
ACTIONS_DEPLOY_TOKEN: ${{ secrets.ACTIONS_DEPLOY_TOKEN }}
95+
run: |
96+
git config --global user.name '${{ github.actor }}'
97+
git config --global user.email '${{ github.actor }}@users.noreply.github.com'
98+
mike deploy --push --update-aliases ${RELEASE_TAG_VERSION} latest
99+
mike set-default --push latest

.readthedocs.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

AUTHORS.rst

Lines changed: 0 additions & 13 deletions
This file was deleted.

README.md

Lines changed: 113 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
[![Python Versions](https://img.shields.io/pypi/pyversions/statista.png)](https://img.shields.io/pypi/pyversions/statista)
1+
# Statista - Advanced Statistical Analysis Package
2+
3+
[![Python Versions](https://img.shields.io/pypi/pyversions/statista.svg)](https://pypi.org/project/statista/)
4+
[![PyPI version](https://badge.fury.io/py/statista.svg)](https://badge.fury.io/py/statista)
5+
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/statista.svg)](https://anaconda.org/conda-forge/statista)
26
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
7+
[![Documentation Status](https://readthedocs.org/projects/statista/badge/?version=latest)](https://statista.readthedocs.io/en/latest/?badge=latest)
8+
[![codecov](https://codecov.io/gh/Serapieum-of-alex/statista/branch/main/graph/badge.svg?token=GQKhcj2pFK)](https://codecov.io/gh/Serapieum-of-alex/statista)
39
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
4-
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/MAfarrag/earth2observe.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/MAfarrag/earth2observe/context:python)
5-
[![Total alerts](https://img.shields.io/lgtm/alerts/g/MAfarrag/earth2observe.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/MAfarrag/earth2observe/alerts/)
10+
[![GitHub last commit](https://img.shields.io/github/last-commit/Serapieum-of-alex/statista)](https://github.com/Serapieum-of-alex/statista/commits/main)
11+
[![GitHub issues](https://img.shields.io/github/issues/Serapieum-of-alex/statista)](https://github.com/Serapieum-of-alex/statista/issues)
12+
[![GitHub stars](https://img.shields.io/github/stars/Serapieum-of-alex/statista)](https://github.com/Serapieum-of-alex/statista/stargazers)
13+
[![GitHub forks](https://img.shields.io/github/forks/Serapieum-of-alex/statista)](https://github.com/Serapieum-of-alex/statista/network/members)
614

15+
## Overview
716

8-
[![codecov](https://codecov.io/gh/Serapieum-of-alex/statista/branch/main/graph/badge.svg?token=GQKhcj2pFK)](https://codecov.io/gh/Serapieum-of-alex/statista)
9-
![GitHub last commit](https://img.shields.io/github/last-commit/MAfarrag/statista)
10-
![GitHub forks](https://img.shields.io/github/forks/MAfarrag/statista?style=social)
11-
![GitHub Repo stars](https://img.shields.io/github/stars/MAfarrag/statista?style=social)
12-
17+
**Statista** is a comprehensive Python package for statistical analysis, focusing on probability distributions, extreme value analysis, and sensitivity analysis. It provides robust tools for researchers, engineers, and data scientists working with statistical models, particularly in hydrology, climate science, and risk assessment.
1318

1419
Current release info
1520
====================
@@ -18,62 +23,121 @@ Current release info
1823
| --- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --- | --- |
1924
| [![Conda Recipe](https://img.shields.io/badge/recipe-statista-green.svg)](https://anaconda.org/conda-forge/statista) | [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/statista.svg)](https://anaconda.org/conda-forge/statista) [![Downloads](https://pepy.tech/badge/statista)](https://pepy.tech/project/statista) [![Downloads](https://pepy.tech/badge/statista/month)](https://pepy.tech/project/statista) [![Downloads](https://pepy.tech/badge/statista/week)](https://pepy.tech/project/statista) ![PyPI - Downloads](https://img.shields.io/pypi/dd/statista?color=blue&style=flat-square) | [![Conda Version](https://img.shields.io/conda/vn/conda-forge/statista.svg)](https://anaconda.org/conda-forge/statista) [![PyPI version](https://badge.fury.io/py/statista.svg)](https://badge.fury.io/py/statista) [![Anaconda-Server Badge](https://anaconda.org/conda-forge/statista/badges/version.svg)](https://anaconda.org/conda-forge/statista) | [![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/statista.svg)](https://anaconda.org/conda-forge/statista) [![Join the chat at https://gitter.im/Hapi-Nile/Hapi](https://badges.gitter.im/Hapi-Nile/Hapi.svg)](https://gitter.im/Hapi-Nile/Hapi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
2025

21-
statista - Statistics package
22-
=====================================================================
23-
**statista** is a statistics package
26+
## Installation
2427

25-
statista
28+
### Conda (Recommended)
2629

27-
Main Features
28-
-------------
29-
- Statistical Distributions
30-
- GEV
31-
- GUMBEL
32-
- Normal
33-
- Exponential
34-
- Parameter estimation methods
35-
- Lmoments
36-
- ML
37-
- MOM
38-
- One-at-time (O-A-T) Sensitivity analysis.
39-
- Sobol visualization
40-
- Statistical descriptors
41-
- Extreme value analysis
30+
```bash
31+
conda install -c conda-forge statista
32+
```
4233

43-
For the full documentation, please visit [statista documentation](https://statista.readthedocs.io/en/latest/?badge=latest)
34+
### PyPI
4435

45-
Installing statista
46-
===============
36+
```bash
37+
pip install statista
38+
```
4739

48-
Installing `statista` from the `conda-forge` channel can be achieved by:
40+
### Development Version
4941

50-
```
51-
conda install -c conda-forge statista
42+
```bash
43+
pip install git+https://github.com/Serapieum-of-alex/statista
5244
```
5345

54-
It is possible to list all the versions of `statista` available on your platform with:
46+
## Main Features
5547

56-
```
57-
conda search statista --channel conda-forge
58-
```
48+
### Statistical Distributions
49+
- **Probability Distributions**: GEV, Gumbel, Normal, Exponential, and more
50+
- **Parameter Estimation Methods**: Maximum Likelihood (ML), L-moments, Method of Moments (MOM)
51+
- **Goodness-of-fit Tests**: Kolmogorov-Smirnov, Chi-square
52+
- **Truncated Distributions**: Focus analysis on values above a threshold
5953

60-
## Install from GitHub
61-
to install the last development to time, you can install the library from GitHub
62-
```
63-
pip install git+https://github.com/MAfarrag/statista
64-
```
54+
### Extreme Value Analysis
55+
- **Return Period Calculation**: Estimate extreme events for different return periods
56+
- **Confidence Intervals**: Calculate confidence bounds using various methods
57+
- **Plotting Positions**: Weibull, Gringorten, and other empirical distribution functions
58+
59+
### Sensitivity Analysis
60+
- **One-at-a-time (OAT)**: Analyze parameter sensitivity individually
61+
- **Sobol Visualization**: Visualize parameter interactions and importance
62+
63+
### Statistical Tools
64+
- **Descriptive Statistics**: Comprehensive statistical descriptors
65+
- **Time Series Analysis**: Auto-correlation and other time series tools
66+
- **Visualization**: Publication-quality plots for statistical analysis
67+
68+
## Quick Start
69+
70+
### Basic Usage
71+
72+
```python
73+
import pandas as pd
74+
from statista.distributions import Distributions
6575

66-
## pip
67-
to install the last release, you can use pip
76+
# Load your time series data
77+
data = pd.read_csv("your_data.csv", header=None)[0].tolist()
78+
79+
# Create a distribution object (e.g., Gumbel)
80+
dist = Distributions("Gumbel", data)
81+
82+
# Fit the distribution using maximum likelihood
83+
params = dist.fit_model(method="mle")
84+
print(params)
85+
86+
# Calculate and plot the PDF and CDF
87+
pdf = dist.pdf(plot_figure=True)
88+
cdf, _, _ = dist.cdf(plot_figure=True)
89+
90+
# Perform goodness-of-fit tests
91+
ks_test = dist.ks()
92+
chi2_test = dist.chisquare()
93+
94+
# Create a probability plot with confidence intervals
95+
fig, ax = dist.plot()
6896
```
69-
pip install statista==0.6.0
97+
98+
### Extreme Value Analysis
99+
100+
```python
101+
from statista.distributions import GEV, PlottingPosition
102+
103+
# Create a GEV distribution
104+
gev_dist = Distributions("GEV", data)
105+
106+
# Fit using L-moments
107+
params = gev_dist.fit_model(method="lmoments")
108+
109+
# Calculate non-exceedance probabilities
110+
cdf_weibul = PlottingPosition.weibul(data)
111+
112+
# Calculate confidence intervals
113+
lower_bound, upper_bound, fig, ax = gev_dist.confidence_interval(plot_figure=True)
70114
```
71115

72-
Quick start
73-
===========
116+
For more examples and detailed documentation, visit [Statista Documentation](https://serapieum-of-alex.github.io/statista)
117+
118+
## Contributing
119+
120+
Contributions are welcome! Please feel free to submit a Pull Request.
121+
122+
## License
123+
124+
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
125+
126+
## Citation
127+
128+
If you use Statista in your research, please cite it as:
74129

75130
```
76-
>>> import statista
131+
Farrag, M. (2023). Statista: A Python package for statistical analysis, extreme value analysis, and sensitivity analysis.
132+
https://github.com/Serapieum-of-alex/statista
77133
```
78134

79-
[other code samples](https://statista.readthedocs.io/en/latest/?badge=latest)
135+
BibTeX:
136+
```bibtex
137+
@software{statista2023,
138+
author = {Farrag, Mostafa},
139+
title = {Statista: A Python package for statistical analysis, extreme value analysis, and sensitivity analysis},
140+
url = {https://github.com/Serapieum-of-alex/statista},
141+
year = {2023}
142+
}
143+
```

docs/AUTHORS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Credits
2+
3+
## Development Lead
4+
5+
* Mostafa Farrag <moah.farag@gmail.com>

0 commit comments

Comments
 (0)