hmbp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ id-token: write # Required for trusted publishing
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0 # Full history for setuptools-scm versioning
20
+
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: '3.11'
24
+
25
+ - name: Install build tools
26
+ run: pip install build
27
+
28
+ - name: Build package
29
+ run: python -m build
30
+
31
+ - name: List artifacts
32
+ run: ls -la dist/
33
+
34
+ - name: Publish to PyPI
35
+ uses: pypa/gh-action-pypi-publish@release/v1
36
+ # Uses trusted publishing - no API token needed
37
+ # Configure at: https://pypi.org/manage/account/publishing/
hmbp-0.1.0/.gitignore ADDED
@@ -0,0 +1,46 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ .venv/
25
+ venv/
26
+ ENV/
27
+
28
+ # IDE
29
+ .idea/
30
+ .vscode/
31
+ *.swp
32
+ *.swo
33
+
34
+ # Testing
35
+ .pytest_cache/
36
+ .coverage
37
+ htmlcov/
38
+
39
+ # OS
40
+ .DS_Store
41
+ Thumbs.db
42
+
43
+ # Project specific
44
+ figures/
45
+ .claude/
46
+ hmbp/_version.py
hmbp-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.4
2
+ Name: hmbp
3
+ Version: 0.1.0
4
+ Summary: Simple matplotlib plotting with consistent, publication-ready styling
5
+ Author: hmblair
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/hmblair/hmbp
8
+ Project-URL: Repository, https://github.com/hmblair/hmbp
9
+ Keywords: plotting,matplotlib,visualization,data-science
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Visualization
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: numpy
21
+ Requires-Dist: matplotlib
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest; extra == "dev"
24
+
25
+ # hmbp
26
+
27
+ A simple matplotlib wrapper with consistent, publication-ready styling.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ pip install -e .
33
+ ```
34
+
35
+ ## Style
36
+
37
+ - Font: Helvetica
38
+ - Colormap: RdPu (primary), PiYG (secondary/diverging)
39
+ - 400 DPI output
40
+ - Consistent sizing: title 15pt, labels 14pt, ticks 13pt, legend 12pt
41
+
42
+ ## Usage
43
+
44
+ ```python
45
+ import hmbp
46
+
47
+ fig, ax = hmbp.new_figure()
48
+ hmbp.line_plot(y_values, x_values, label="Model A")
49
+ hmbp.set_labels("Title", "X Label", "Y Label")
50
+ hmbp.save("output.png")
51
+ ```
52
+
53
+ ## Available Functions
54
+
55
+ | Function | Description |
56
+ |----------|-------------|
57
+ | `line_plot` | Line with optional fill |
58
+ | `scatter_plot` | Scatter with optional color mapping |
59
+ | `histogram` | Color-mapped histogram |
60
+ | `bar_plot` | Vertical/horizontal bars |
61
+ | `box_plot` | Box plot distributions |
62
+ | `violin_plot` | Violin plot distributions |
63
+ | `heatmap` | 2D heatmap with colorbar |
64
+ | `line_plot_with_error` | Line with shaded error region |
65
+ | `confusion_matrix` | Annotated confusion matrix |
66
+ | `roc_curve` | ROC curve with AUC |
67
+ | `precision_recall_curve` | PR curve with AP |
68
+ | `residual_plot` | Regression residuals |
69
+ | `learning_curve` | Train/val learning curves |
70
+ | `metric_comparison` | Horizontal bar comparison |
71
+ | `volcano_plot` | Volcano plot for differential analysis |
72
+
73
+ ## Helpers
74
+
75
+ - `new_figure(figsize)` - Create figure and axes
76
+ - `set_labels(title, xlabel, ylabel)` - Apply labels
77
+ - `save(path, fig, close)` - Save with auto-legend
78
+
79
+ ## Quick API
80
+
81
+ Single-call functions that create, label, and save in one step:
82
+
83
+ ```python
84
+ import hmbp
85
+
86
+ hmbp.quick_histogram(data, title="Scores", xlabel="Value", path="hist.png")
87
+ hmbp.quick_bar(values, labels, title="Comparison", ylabel="F1", path="bars.png")
88
+ hmbp.quick_confusion_matrix(cm, class_names=["A", "B"], path="cm.png")
89
+ ```
90
+
91
+ Available: `quick_line`, `quick_scatter`, `quick_histogram`, `quick_bar`, `quick_heatmap`, `quick_confusion_matrix`, `quick_roc`, `quick_volcano`
hmbp-0.1.0/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # hmbp
2
+
3
+ A simple matplotlib wrapper with consistent, publication-ready styling.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install -e .
9
+ ```
10
+
11
+ ## Style
12
+
13
+ - Font: Helvetica
14
+ - Colormap: RdPu (primary), PiYG (secondary/diverging)
15
+ - 400 DPI output
16
+ - Consistent sizing: title 15pt, labels 14pt, ticks 13pt, legend 12pt
17
+
18
+ ## Usage
19
+
20
+ ```python
21
+ import hmbp
22
+
23
+ fig, ax = hmbp.new_figure()
24
+ hmbp.line_plot(y_values, x_values, label="Model A")
25
+ hmbp.set_labels("Title", "X Label", "Y Label")
26
+ hmbp.save("output.png")
27
+ ```
28
+
29
+ ## Available Functions
30
+
31
+ | Function | Description |
32
+ |----------|-------------|
33
+ | `line_plot` | Line with optional fill |
34
+ | `scatter_plot` | Scatter with optional color mapping |
35
+ | `histogram` | Color-mapped histogram |
36
+ | `bar_plot` | Vertical/horizontal bars |
37
+ | `box_plot` | Box plot distributions |
38
+ | `violin_plot` | Violin plot distributions |
39
+ | `heatmap` | 2D heatmap with colorbar |
40
+ | `line_plot_with_error` | Line with shaded error region |
41
+ | `confusion_matrix` | Annotated confusion matrix |
42
+ | `roc_curve` | ROC curve with AUC |
43
+ | `precision_recall_curve` | PR curve with AP |
44
+ | `residual_plot` | Regression residuals |
45
+ | `learning_curve` | Train/val learning curves |
46
+ | `metric_comparison` | Horizontal bar comparison |
47
+ | `volcano_plot` | Volcano plot for differential analysis |
48
+
49
+ ## Helpers
50
+
51
+ - `new_figure(figsize)` - Create figure and axes
52
+ - `set_labels(title, xlabel, ylabel)` - Apply labels
53
+ - `save(path, fig, close)` - Save with auto-legend
54
+
55
+ ## Quick API
56
+
57
+ Single-call functions that create, label, and save in one step:
58
+
59
+ ```python
60
+ import hmbp
61
+
62
+ hmbp.quick_histogram(data, title="Scores", xlabel="Value", path="hist.png")
63
+ hmbp.quick_bar(values, labels, title="Comparison", ylabel="F1", path="bars.png")
64
+ hmbp.quick_confusion_matrix(cm, class_names=["A", "B"], path="cm.png")
65
+ ```
66
+
67
+ Available: `quick_line`, `quick_scatter`, `quick_histogram`, `quick_bar`, `quick_heatmap`, `quick_confusion_matrix`, `quick_roc`, `quick_volcano`
@@ -0,0 +1,137 @@
1
+ """Generate sample plots to demonstrate the hmbp plotting module."""
2
+
3
+ import numpy as np
4
+ import hmbp
5
+
6
+ np.random.seed(42)
7
+
8
+ # 1. Line plot
9
+ fig, ax = hmbp.new_figure()
10
+ x = np.linspace(0, 10, 100)
11
+ hmbp.line_plot(np.sin(x), x, label="Model A")
12
+ hmbp.line_plot(np.cos(x), x, label="Model B", cmap=hmbp.CMAP_ALT)
13
+ hmbp.set_labels("Training Loss Over Time", "Epoch", "Loss")
14
+ hmbp.save("figures/01_line_plot.png")
15
+
16
+ # 2. Scatter plot
17
+ fig, ax = hmbp.new_figure()
18
+ x = np.random.randn(200)
19
+ y = 0.5 * x + np.random.randn(200) * 0.3
20
+ hmbp.scatter_plot(x, y, c=y, label="Samples")
21
+ hmbp.set_labels("Feature Correlation", "Feature A", "Feature B")
22
+ hmbp.save("figures/02_scatter_plot.png")
23
+
24
+ # 3. Histogram
25
+ fig, ax = hmbp.new_figure()
26
+ data = np.concatenate([np.random.randn(500), np.random.randn(300) + 3])
27
+ hmbp.histogram(data, bins=40)
28
+ hmbp.set_labels("Score Distribution", "Score", "Count")
29
+ hmbp.save("figures/03_histogram.png")
30
+
31
+ # 4. Bar plot
32
+ fig, ax = hmbp.new_figure()
33
+ models = ["Random Forest", "XGBoost", "Neural Net", "SVM", "LogReg"]
34
+ scores = [0.92, 0.95, 0.91, 0.88, 0.85]
35
+ hmbp.bar_plot(scores, models)
36
+ hmbp.set_labels("Model Comparison", "", "F1 Score")
37
+ hmbp.save("figures/04_bar_plot.png")
38
+
39
+ # 5. Box plot
40
+ fig, ax = hmbp.new_figure()
41
+ data = [np.random.randn(100) + i * 0.5 for i in range(4)]
42
+ hmbp.box_plot(data, ["Model A", "Model B", "Model C", "Model D"])
43
+ hmbp.set_labels("Score Distribution by Model", "", "Score")
44
+ hmbp.save("figures/05_box_plot.png")
45
+
46
+ # 6. Violin plot
47
+ fig, ax = hmbp.new_figure()
48
+ data = [np.random.randn(100) * (i + 1) * 0.3 for i in range(4)]
49
+ hmbp.violin_plot(data, ["Small", "Medium", "Large", "XL"])
50
+ hmbp.set_labels("Prediction Variance by Model Size", "", "Prediction Error")
51
+ hmbp.save("figures/06_violin_plot.png")
52
+
53
+ # 7. Heatmap (correlation matrix)
54
+ fig, ax = hmbp.new_figure()
55
+ corr = np.random.randn(6, 6)
56
+ corr = (corr + corr.T) / 2
57
+ np.fill_diagonal(corr, 1)
58
+ features = ["feat_1", "feat_2", "feat_3", "feat_4", "feat_5", "feat_6"]
59
+ hmbp.heatmap(corr, xticklabels=features, yticklabels=features,
60
+ colorbar_label="Correlation", center_zero=True, annot=True)
61
+ hmbp.set_labels("Feature Correlation Matrix", "", "")
62
+ hmbp.save("figures/07_heatmap.png")
63
+
64
+ # 8. Line plot with error
65
+ fig, ax = hmbp.new_figure()
66
+ x = np.arange(10)
67
+ y = np.exp(-x * 0.3) + 0.1
68
+ yerr = 0.05 + 0.02 * np.random.randn(10)
69
+ hmbp.line_plot_with_error(y, np.abs(yerr), x, label="Mean +/- Std")
70
+ hmbp.set_labels("Convergence with Uncertainty", "Iteration", "Loss")
71
+ hmbp.save("figures/08_line_with_error.png")
72
+
73
+ # 9. Confusion matrix
74
+ fig, ax = hmbp.new_figure()
75
+ cm = np.array([[85, 10, 5], [8, 82, 10], [4, 12, 84]])
76
+ hmbp.confusion_matrix(cm, class_names=["Cat", "Dog", "Bird"], normalize=True)
77
+ hmbp.set_labels("Classification Results", "", "")
78
+ hmbp.save("figures/09_confusion_matrix.png")
79
+
80
+ # 10. ROC curve
81
+ fig, ax = hmbp.new_figure()
82
+ fpr1 = np.linspace(0, 1, 100)
83
+ tpr1 = np.sqrt(fpr1) # Good model
84
+ tpr2 = fpr1 ** 2 + fpr1 * 0.5 # Mediocre model
85
+ tpr2 = np.clip(tpr2, 0, 1)
86
+ hmbp.roc_curve(fpr1, tpr1, auc=0.92, label="XGBoost")
87
+ hmbp.roc_curve(fpr1, tpr2, auc=0.71, label="Baseline", cmap=hmbp.CMAP_ALT)
88
+ hmbp.set_labels("ROC Comparison", "", "")
89
+ hmbp.save("figures/10_roc_curve.png")
90
+
91
+ # 11. Precision-Recall curve
92
+ fig, ax = hmbp.new_figure()
93
+ recall = np.linspace(0, 1, 100)
94
+ precision1 = 1 - 0.3 * recall ** 2
95
+ precision2 = 1 - 0.6 * recall
96
+ hmbp.precision_recall_curve(precision1, recall, ap=0.89, label="Model A")
97
+ hmbp.precision_recall_curve(precision2, recall, ap=0.72, label="Model B", cmap=hmbp.CMAP_ALT)
98
+ hmbp.set_labels("Precision-Recall Comparison", "", "")
99
+ hmbp.save("figures/11_pr_curve.png")
100
+
101
+ # 12. Residual plot
102
+ fig, ax = hmbp.new_figure()
103
+ y_pred = np.linspace(0, 10, 100)
104
+ y_true = y_pred + np.random.randn(100) * 0.5
105
+ hmbp.residual_plot(y_true, y_pred)
106
+ hmbp.set_labels("Residual Analysis", "", "")
107
+ hmbp.save("figures/12_residual_plot.png")
108
+
109
+ # 13. Learning curve
110
+ fig, ax = hmbp.new_figure()
111
+ sizes = np.array([100, 200, 500, 1000, 2000, 5000])
112
+ train_scores = np.column_stack([
113
+ 0.99 - 0.1 * np.exp(-sizes / 500) + np.random.randn(6) * 0.01
114
+ for _ in range(5)
115
+ ])
116
+ val_scores = np.column_stack([
117
+ 0.85 + 0.1 * (1 - np.exp(-sizes / 1000)) + np.random.randn(6) * 0.02
118
+ for _ in range(5)
119
+ ])
120
+ hmbp.learning_curve(train_scores, val_scores, sizes, metric_name="Accuracy")
121
+ hmbp.set_labels("Learning Curve", "", "")
122
+ hmbp.save("figures/13_learning_curve.png")
123
+
124
+ # 14. Metric comparison
125
+ fig, ax = hmbp.new_figure()
126
+ metrics = {
127
+ "Accuracy": 0.94,
128
+ "Precision": 0.91,
129
+ "Recall": 0.88,
130
+ "F1": 0.89,
131
+ "AUC": 0.96
132
+ }
133
+ hmbp.metric_comparison(metrics)
134
+ hmbp.set_labels("Model Metrics", "", "")
135
+ hmbp.save("figures/14_metric_comparison.png")
136
+
137
+ print("Generated 14 sample plots in figures/")
@@ -0,0 +1,92 @@
1
+ """
2
+ hmbp - Simple matplotlib plotting with consistent, publication-ready styling.
3
+
4
+ Provides line plots, scatter plots, histograms, and data science
5
+ visualizations with a clean aesthetic.
6
+ """
7
+
8
+ from hmbp.plotting import (
9
+ # Style constants
10
+ LABEL_SIZE,
11
+ TITLE_SIZE,
12
+ TICK_SIZE,
13
+ LEGEND_SIZE,
14
+ DPI,
15
+ CMAP,
16
+ CMAP_ALT,
17
+ # Core plot functions
18
+ line_plot,
19
+ scatter_plot,
20
+ histogram,
21
+ bar_plot,
22
+ heatmap,
23
+ box_plot,
24
+ violin_plot,
25
+ line_plot_with_error,
26
+ # Data science plots
27
+ confusion_matrix,
28
+ roc_curve,
29
+ precision_recall_curve,
30
+ residual_plot,
31
+ learning_curve,
32
+ metric_comparison,
33
+ volcano_plot,
34
+ # Helpers
35
+ set_labels,
36
+ save,
37
+ new_figure,
38
+ # Quick API
39
+ quick_line,
40
+ quick_scatter,
41
+ quick_histogram,
42
+ quick_bar,
43
+ quick_heatmap,
44
+ quick_confusion_matrix,
45
+ quick_roc,
46
+ quick_volcano,
47
+ )
48
+
49
+ try:
50
+ from hmbp._version import version as __version__
51
+ except ImportError:
52
+ __version__ = "0.0.0.dev0"
53
+ __all__ = [
54
+ # Style constants
55
+ "LABEL_SIZE",
56
+ "TITLE_SIZE",
57
+ "TICK_SIZE",
58
+ "LEGEND_SIZE",
59
+ "DPI",
60
+ "CMAP",
61
+ "CMAP_ALT",
62
+ # Core plot functions
63
+ "line_plot",
64
+ "scatter_plot",
65
+ "histogram",
66
+ "bar_plot",
67
+ "heatmap",
68
+ "box_plot",
69
+ "violin_plot",
70
+ "line_plot_with_error",
71
+ # Data science plots
72
+ "confusion_matrix",
73
+ "roc_curve",
74
+ "precision_recall_curve",
75
+ "residual_plot",
76
+ "learning_curve",
77
+ "metric_comparison",
78
+ "volcano_plot",
79
+ # Helpers
80
+ "set_labels",
81
+ "save",
82
+ "new_figure",
83
+ # Quick API
84
+ "quick_line",
85
+ "quick_scatter",
86
+ "quick_histogram",
87
+ "quick_bar",
88
+ "quick_heatmap",
89
+ "quick_confusion_matrix",
90
+ "quick_roc",
91
+ "quick_volcano",
92
+ ]
@@ -0,0 +1,34 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '0.1.0'
32
+ __version_tuple__ = version_tuple = (0, 1, 0)
33
+
34
+ __commit_id__ = commit_id = 'g7081845e2'