heatmap_cli 0.26.0__tar.gz → 0.27.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.
- {heatmap_cli-0.26.0/src/heatmap_cli.egg-info → heatmap_cli-0.27.0}/PKG-INFO +32 -33
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/README.md +31 -32
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/pyproject.toml +1 -1
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/src/heatmap_cli/__init__.py +9 -7
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/src/heatmap_cli/cli.py +64 -11
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/src/heatmap_cli/heatmap.py +25 -6
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0/src/heatmap_cli.egg-info}/PKG-INFO +32 -33
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/src/heatmap_cli.egg-info/SOURCES.txt +0 -1
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_help_flag.py +5 -1
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_purge_flag.py +0 -1
- heatmap_cli-0.26.0/tests/test_verbose_flag.py +0 -31
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/LICENSE.md +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/setup.cfg +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/src/heatmap_cli/__main__.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/src/heatmap_cli/py.typed +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/src/heatmap_cli.egg-info/dependency_links.txt +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/src/heatmap_cli.egg-info/entry_points.txt +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/src/heatmap_cli.egg-info/requires.txt +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/src/heatmap_cli.egg-info/top_level.txt +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_animate_by_week.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_animate_no_frames.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_animate_open.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_annotate_flag.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_annotation_truncation.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_cbar_flag.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_cmap_option.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_cmax_option.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_cmin_option.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_configure_cbar.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_debug_flag.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_demo_option.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_end_date_option.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_env_flag.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_heatmap_direct.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_heatmap_errors.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_heatmap_open.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_heatmap_utils.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_heatmap_wrapper.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_iso_53_week_year.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_no_annotate.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_open_heatmap.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_output_dir_option.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_quiet_flag.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_refresh_output_dir.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_setup_logging.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_start_date_option.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_title_option.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_version_flag.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_week_option.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_year_option.py +0 -0
- {heatmap_cli-0.26.0 → heatmap_cli-0.27.0}/tests/test_yes_flag.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: heatmap_cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.27.0
|
|
4
4
|
Summary: A console program that generates a yearly calendar heatmap.
|
|
5
5
|
Author-email: Kian-Meng Ang <kianmeng@cpan.org>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
@@ -56,7 +56,7 @@ heatmap -h -v
|
|
|
56
56
|
```console
|
|
57
57
|
usage: heatmap_cli [--demo [NUMBER_OF_COLORMAP]] [--seed SEED] [-y YEAR]
|
|
58
58
|
[-w WEEK] [-e END_DATE] [-s START_DATE] [-O OUTPUT_DIR]
|
|
59
|
-
[-o] [-p] [-
|
|
59
|
+
[-o] [-p] [-t TITLE] [-u AUTHOR] [-f IMAGE_FORMAT]
|
|
60
60
|
[-c COLORMAP] [-i COLORMAP_MIN_VALUE]
|
|
61
61
|
[-x COLORMAP_MAX_VALUE] [-b]
|
|
62
62
|
[-a | --annotate | --no-annotate] [--animate-by-week] [-q]
|
|
@@ -75,32 +75,30 @@ positional arguments:
|
|
|
75
75
|
|
|
76
76
|
options:
|
|
77
77
|
--demo [NUMBER_OF_COLORMAP]
|
|
78
|
-
generate number of heatmaps by colormaps (default: '
|
|
78
|
+
generate number of heatmaps by colormaps (default: '194'). Implied: covers the current ISO year; -y/-w/-s/-e/-c are ignored.
|
|
79
79
|
--seed SEED
|
|
80
80
|
set random seed for reproducible --demo output (default: None)
|
|
81
|
-
-y
|
|
81
|
+
-y, --year YEAR
|
|
82
82
|
filter by year from the CSV file (default: 'None')
|
|
83
|
-
-w
|
|
83
|
+
-w, --week WEEK
|
|
84
84
|
filter until week of the year from the CSV file (default: current week)
|
|
85
|
-
-e
|
|
85
|
+
-e, --end-date END_DATE
|
|
86
86
|
filter until the date of the year from the CSV file and this will overwrite -y and -w option (default: None)
|
|
87
|
-
-s
|
|
87
|
+
-s, --start-date START_DATE
|
|
88
88
|
filter from the date of the year from the CSV file and this will overwrite -y and -w option (default: None)
|
|
89
|
-
-O
|
|
89
|
+
-O, --output-dir OUTPUT_DIR
|
|
90
90
|
set default output folder (default: 'output')
|
|
91
91
|
-o, --open
|
|
92
92
|
open the generated heatmap using the default program (default: False)
|
|
93
93
|
-p, --purge
|
|
94
94
|
remove all leftover artifacts set by --output-dir folder (default: False)
|
|
95
|
-
-
|
|
96
|
-
show verbosity of debugging log. Use -vv, -vvv for more details
|
|
97
|
-
-t TITLE, --title TITLE
|
|
95
|
+
-t, --title TITLE
|
|
98
96
|
set title for the heatmap (default: None)
|
|
99
|
-
-u
|
|
97
|
+
-u, --author AUTHOR
|
|
100
98
|
set author for the heatmap (default: kianmeng.org)
|
|
101
|
-
-f
|
|
99
|
+
-f, --format IMAGE_FORMAT
|
|
102
100
|
set the default image format (default: 'png')
|
|
103
|
-
-c
|
|
101
|
+
-c, --cmap COLORMAP
|
|
104
102
|
Set default colormap. (default: 'RdYlGn_r')
|
|
105
103
|
Available colormaps:
|
|
106
104
|
Accent, Accent_r, afmhot, afmhot_r, autumn, autumn_r
|
|
@@ -119,30 +117,31 @@ options:
|
|
|
119
117
|
hot, hot_r, hsv, hsv_r, icefire, icefire_r
|
|
120
118
|
inferno, inferno_r, jet, jet_r, magma, magma_r
|
|
121
119
|
mako, mako_r, managua, managua_r, nipy_spectral, nipy_spectral_r
|
|
122
|
-
ocean, ocean_r,
|
|
123
|
-
Paired, Paired_r, Pastel1, Pastel1_r
|
|
124
|
-
pink, pink_r, PiYG, PiYG_r
|
|
125
|
-
PRGn, PRGn_r, prism, prism_r
|
|
126
|
-
PuBuGn, PuBuGn_r, PuOr, PuOr_r
|
|
127
|
-
Purples, Purples_r, rainbow, rainbow_r
|
|
128
|
-
RdGy, RdGy_r, RdPu, RdPu_r
|
|
129
|
-
RdYlGn, RdYlGn_r, Reds, Reds_r
|
|
130
|
-
seismic, seismic_r, Set1, Set1_r
|
|
131
|
-
Set3, Set3_r, Spectral, Spectral_r
|
|
132
|
-
summer, summer_r, tab10, tab10_r
|
|
133
|
-
tab20b, tab20b_r, tab20c, tab20c_r
|
|
134
|
-
turbo, turbo_r, twilight, twilight_r
|
|
135
|
-
vanimo, vanimo_r, viridis, viridis_r
|
|
136
|
-
winter, winter_r, Wistia, Wistia_r
|
|
137
|
-
YlGnBu, YlGnBu_r, YlOrBr, YlOrBr_r
|
|
138
|
-
|
|
120
|
+
ocean, ocean_r, okabe_ito, okabe_ito_r, Oranges, Oranges_r
|
|
121
|
+
OrRd, OrRd_r, Paired, Paired_r, Pastel1, Pastel1_r
|
|
122
|
+
Pastel2, Pastel2_r, pink, pink_r, PiYG, PiYG_r
|
|
123
|
+
plasma, plasma_r, PRGn, PRGn_r, prism, prism_r
|
|
124
|
+
PuBu, PuBu_r, PuBuGn, PuBuGn_r, PuOr, PuOr_r
|
|
125
|
+
PuRd, PuRd_r, Purples, Purples_r, rainbow, rainbow_r
|
|
126
|
+
RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r
|
|
127
|
+
RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r
|
|
128
|
+
rocket, rocket_r, seismic, seismic_r, Set1, Set1_r
|
|
129
|
+
Set2, Set2_r, Set3, Set3_r, Spectral, Spectral_r
|
|
130
|
+
spring, spring_r, summer, summer_r, tab10, tab10_r
|
|
131
|
+
tab20, tab20_r, tab20b, tab20b_r, tab20c, tab20c_r
|
|
132
|
+
terrain, terrain_r, turbo, turbo_r, twilight, twilight_r
|
|
133
|
+
twilight_shifted, twilight_shifted_r, vanimo, vanimo_r, viridis, viridis_r
|
|
134
|
+
vlag, vlag_r, winter, winter_r, Wistia, Wistia_r
|
|
135
|
+
YlGn, YlGn_r, YlGnBu, YlGnBu_r, YlOrBr, YlOrBr_r
|
|
136
|
+
YlOrRd, YlOrRd_r
|
|
137
|
+
-i, --cmap-min COLORMAP_MIN_VALUE
|
|
139
138
|
Set the minimum value of the colormap range (default: None)
|
|
140
|
-
-x
|
|
139
|
+
-x, --cmap-max COLORMAP_MAX_VALUE
|
|
141
140
|
Set the maximum value of the colormap range (default: None)
|
|
142
141
|
-b, --cbar
|
|
143
142
|
show colorbar (default: False)
|
|
144
143
|
-a, --annotate, --no-annotate
|
|
145
|
-
add count to each heatmap region (use --no-annotate to disable)
|
|
144
|
+
add count to each heatmap region (use --no-annotate to disable)
|
|
146
145
|
--animate-by-week
|
|
147
146
|
create an animation for each day of the current week
|
|
148
147
|
-q, --quiet
|
|
@@ -27,7 +27,7 @@ heatmap -h -v
|
|
|
27
27
|
```console
|
|
28
28
|
usage: heatmap_cli [--demo [NUMBER_OF_COLORMAP]] [--seed SEED] [-y YEAR]
|
|
29
29
|
[-w WEEK] [-e END_DATE] [-s START_DATE] [-O OUTPUT_DIR]
|
|
30
|
-
[-o] [-p] [-
|
|
30
|
+
[-o] [-p] [-t TITLE] [-u AUTHOR] [-f IMAGE_FORMAT]
|
|
31
31
|
[-c COLORMAP] [-i COLORMAP_MIN_VALUE]
|
|
32
32
|
[-x COLORMAP_MAX_VALUE] [-b]
|
|
33
33
|
[-a | --annotate | --no-annotate] [--animate-by-week] [-q]
|
|
@@ -46,32 +46,30 @@ positional arguments:
|
|
|
46
46
|
|
|
47
47
|
options:
|
|
48
48
|
--demo [NUMBER_OF_COLORMAP]
|
|
49
|
-
generate number of heatmaps by colormaps (default: '
|
|
49
|
+
generate number of heatmaps by colormaps (default: '194'). Implied: covers the current ISO year; -y/-w/-s/-e/-c are ignored.
|
|
50
50
|
--seed SEED
|
|
51
51
|
set random seed for reproducible --demo output (default: None)
|
|
52
|
-
-y
|
|
52
|
+
-y, --year YEAR
|
|
53
53
|
filter by year from the CSV file (default: 'None')
|
|
54
|
-
-w
|
|
54
|
+
-w, --week WEEK
|
|
55
55
|
filter until week of the year from the CSV file (default: current week)
|
|
56
|
-
-e
|
|
56
|
+
-e, --end-date END_DATE
|
|
57
57
|
filter until the date of the year from the CSV file and this will overwrite -y and -w option (default: None)
|
|
58
|
-
-s
|
|
58
|
+
-s, --start-date START_DATE
|
|
59
59
|
filter from the date of the year from the CSV file and this will overwrite -y and -w option (default: None)
|
|
60
|
-
-O
|
|
60
|
+
-O, --output-dir OUTPUT_DIR
|
|
61
61
|
set default output folder (default: 'output')
|
|
62
62
|
-o, --open
|
|
63
63
|
open the generated heatmap using the default program (default: False)
|
|
64
64
|
-p, --purge
|
|
65
65
|
remove all leftover artifacts set by --output-dir folder (default: False)
|
|
66
|
-
-
|
|
67
|
-
show verbosity of debugging log. Use -vv, -vvv for more details
|
|
68
|
-
-t TITLE, --title TITLE
|
|
66
|
+
-t, --title TITLE
|
|
69
67
|
set title for the heatmap (default: None)
|
|
70
|
-
-u
|
|
68
|
+
-u, --author AUTHOR
|
|
71
69
|
set author for the heatmap (default: kianmeng.org)
|
|
72
|
-
-f
|
|
70
|
+
-f, --format IMAGE_FORMAT
|
|
73
71
|
set the default image format (default: 'png')
|
|
74
|
-
-c
|
|
72
|
+
-c, --cmap COLORMAP
|
|
75
73
|
Set default colormap. (default: 'RdYlGn_r')
|
|
76
74
|
Available colormaps:
|
|
77
75
|
Accent, Accent_r, afmhot, afmhot_r, autumn, autumn_r
|
|
@@ -90,30 +88,31 @@ options:
|
|
|
90
88
|
hot, hot_r, hsv, hsv_r, icefire, icefire_r
|
|
91
89
|
inferno, inferno_r, jet, jet_r, magma, magma_r
|
|
92
90
|
mako, mako_r, managua, managua_r, nipy_spectral, nipy_spectral_r
|
|
93
|
-
ocean, ocean_r,
|
|
94
|
-
Paired, Paired_r, Pastel1, Pastel1_r
|
|
95
|
-
pink, pink_r, PiYG, PiYG_r
|
|
96
|
-
PRGn, PRGn_r, prism, prism_r
|
|
97
|
-
PuBuGn, PuBuGn_r, PuOr, PuOr_r
|
|
98
|
-
Purples, Purples_r, rainbow, rainbow_r
|
|
99
|
-
RdGy, RdGy_r, RdPu, RdPu_r
|
|
100
|
-
RdYlGn, RdYlGn_r, Reds, Reds_r
|
|
101
|
-
seismic, seismic_r, Set1, Set1_r
|
|
102
|
-
Set3, Set3_r, Spectral, Spectral_r
|
|
103
|
-
summer, summer_r, tab10, tab10_r
|
|
104
|
-
tab20b, tab20b_r, tab20c, tab20c_r
|
|
105
|
-
turbo, turbo_r, twilight, twilight_r
|
|
106
|
-
vanimo, vanimo_r, viridis, viridis_r
|
|
107
|
-
winter, winter_r, Wistia, Wistia_r
|
|
108
|
-
YlGnBu, YlGnBu_r, YlOrBr, YlOrBr_r
|
|
109
|
-
|
|
91
|
+
ocean, ocean_r, okabe_ito, okabe_ito_r, Oranges, Oranges_r
|
|
92
|
+
OrRd, OrRd_r, Paired, Paired_r, Pastel1, Pastel1_r
|
|
93
|
+
Pastel2, Pastel2_r, pink, pink_r, PiYG, PiYG_r
|
|
94
|
+
plasma, plasma_r, PRGn, PRGn_r, prism, prism_r
|
|
95
|
+
PuBu, PuBu_r, PuBuGn, PuBuGn_r, PuOr, PuOr_r
|
|
96
|
+
PuRd, PuRd_r, Purples, Purples_r, rainbow, rainbow_r
|
|
97
|
+
RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r
|
|
98
|
+
RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r
|
|
99
|
+
rocket, rocket_r, seismic, seismic_r, Set1, Set1_r
|
|
100
|
+
Set2, Set2_r, Set3, Set3_r, Spectral, Spectral_r
|
|
101
|
+
spring, spring_r, summer, summer_r, tab10, tab10_r
|
|
102
|
+
tab20, tab20_r, tab20b, tab20b_r, tab20c, tab20c_r
|
|
103
|
+
terrain, terrain_r, turbo, turbo_r, twilight, twilight_r
|
|
104
|
+
twilight_shifted, twilight_shifted_r, vanimo, vanimo_r, viridis, viridis_r
|
|
105
|
+
vlag, vlag_r, winter, winter_r, Wistia, Wistia_r
|
|
106
|
+
YlGn, YlGn_r, YlGnBu, YlGnBu_r, YlOrBr, YlOrBr_r
|
|
107
|
+
YlOrRd, YlOrRd_r
|
|
108
|
+
-i, --cmap-min COLORMAP_MIN_VALUE
|
|
110
109
|
Set the minimum value of the colormap range (default: None)
|
|
111
|
-
-x
|
|
110
|
+
-x, --cmap-max COLORMAP_MAX_VALUE
|
|
112
111
|
Set the maximum value of the colormap range (default: None)
|
|
113
112
|
-b, --cbar
|
|
114
113
|
show colorbar (default: False)
|
|
115
114
|
-a, --annotate, --no-annotate
|
|
116
|
-
add count to each heatmap region (use --no-annotate to disable)
|
|
115
|
+
add count to each heatmap region (use --no-annotate to disable)
|
|
117
116
|
--animate-by-week
|
|
118
117
|
create an animation for each day of the current week
|
|
119
118
|
-q, --quiet
|
|
@@ -28,7 +28,7 @@ classifiers = [
|
|
|
28
28
|
"Programming Language :: Python",
|
|
29
29
|
"Topic :: Scientific/Engineering :: Visualization",
|
|
30
30
|
]
|
|
31
|
-
version = "0.
|
|
31
|
+
version = "0.27.0"
|
|
32
32
|
keywords = ["heatmap", "cli", "visualization", "calendar", "data-viz"]
|
|
33
33
|
dependencies = [
|
|
34
34
|
"matplotlib",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
from __future__ import annotations
|
|
19
19
|
|
|
20
20
|
import argparse
|
|
21
|
-
import datetime
|
|
22
21
|
import logging
|
|
23
22
|
import platform
|
|
24
23
|
import random
|
|
@@ -134,13 +133,16 @@ class DemoAction(argparse.Action):
|
|
|
134
133
|
values: object,
|
|
135
134
|
_option_string: str | None = None,
|
|
136
135
|
) -> None:
|
|
137
|
-
"""
|
|
136
|
+
"""Record how many demo heatmaps to generate.
|
|
137
|
+
|
|
138
|
+
Only ``namespace.demo`` is set here. The demo flow's year, week,
|
|
139
|
+
colourbar and colormap defaults are applied once parsing has
|
|
140
|
+
finished (see `heatmap_cli.cli._apply_demo_overrides`), so that the
|
|
141
|
+
position of ``--demo`` on the command line cannot change the
|
|
142
|
+
outcome.
|
|
143
|
+
"""
|
|
138
144
|
demo_count = min(cast("int", values), len(CMAPS))
|
|
139
|
-
|
|
140
|
-
namespace.year = [datetime.datetime.now(tz=datetime.timezone.utc).year]
|
|
141
|
-
namespace.week = 52
|
|
142
|
-
namespace.cbar = True
|
|
143
|
-
namespace.demo = demo_count
|
|
145
|
+
namespace.demo = max(demo_count, 1)
|
|
144
146
|
|
|
145
147
|
|
|
146
148
|
def generate_demo(config: argparse.Namespace) -> None:
|
|
@@ -79,6 +79,19 @@ DEFAULT_CMAP = "RdYlGn_r"
|
|
|
79
79
|
CMAP_ITEMS_PER_ROW = 6
|
|
80
80
|
MAX_ISO_WEEK = 53
|
|
81
81
|
|
|
82
|
+
# Options that --demo overrides. --demo synthesises its own sample data for
|
|
83
|
+
# the current ISO year, so the options that select or restyle *that* data have
|
|
84
|
+
# nothing left to act on. -b/--cbar is absent on purpose: it is a store_true
|
|
85
|
+
# already defaulted to False, and --demo forces it to True, which is exactly
|
|
86
|
+
# what -b asks for, so there is nothing to report.
|
|
87
|
+
DEMO_IGNORED_OPTIONS = (
|
|
88
|
+
("-y/--year", "year"),
|
|
89
|
+
("-w/--week", "week"),
|
|
90
|
+
("-s/--start-date", "start_date"),
|
|
91
|
+
("-e/--end-date", "end_date"),
|
|
92
|
+
("-c/--cmap", "cmap"),
|
|
93
|
+
)
|
|
94
|
+
|
|
82
95
|
|
|
83
96
|
def _valid_date(s: str) -> datetime.date:
|
|
84
97
|
"""Validate date format.
|
|
@@ -148,7 +161,8 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
148
161
|
dest="demo",
|
|
149
162
|
help=(
|
|
150
163
|
"generate number of heatmaps by colormaps "
|
|
151
|
-
f"(default: '{len(CMAPS)}')"
|
|
164
|
+
f"(default: '{len(CMAPS)}'). "
|
|
165
|
+
"Implied: covers the current ISO year; -y/-w/-s/-e/-c are ignored."
|
|
152
166
|
),
|
|
153
167
|
metavar="NUMBER_OF_COLORMAP",
|
|
154
168
|
)
|
|
@@ -247,15 +261,6 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
247
261
|
),
|
|
248
262
|
)
|
|
249
263
|
|
|
250
|
-
parser.add_argument(
|
|
251
|
-
"-v",
|
|
252
|
-
"--verbose",
|
|
253
|
-
default=0,
|
|
254
|
-
action="count",
|
|
255
|
-
dest="verbose",
|
|
256
|
-
help="show verbosity of debugging log. Use -vv, -vvv for more details",
|
|
257
|
-
)
|
|
258
|
-
|
|
259
264
|
parser.add_argument(
|
|
260
265
|
"input_filename",
|
|
261
266
|
help="CSV filename (required unless --demo is used)",
|
|
@@ -531,6 +536,47 @@ def _resolve_date_filter_overrides(
|
|
|
531
536
|
parsed_args.week = week
|
|
532
537
|
|
|
533
538
|
|
|
539
|
+
def _apply_demo_overrides(parsed_args: argparse.Namespace) -> None:
|
|
540
|
+
"""Apply the --demo defaults, discarding options that cannot apply.
|
|
541
|
+
|
|
542
|
+
--demo generates its own sample data covering the current ISO year, so
|
|
543
|
+
the options that filter that data (-y, -w, -s, -e) and the option that
|
|
544
|
+
picks the colormaps (-c) are reported as ignored rather than silently
|
|
545
|
+
dropped. The defaults are applied here, after parsing has finished, so
|
|
546
|
+
that the position of --demo on the command line cannot change the
|
|
547
|
+
outcome.
|
|
548
|
+
|
|
549
|
+
Args:
|
|
550
|
+
parsed_args (argparse.Namespace): The parsed arguments, mutated in
|
|
551
|
+
place.
|
|
552
|
+
|
|
553
|
+
Returns:
|
|
554
|
+
None
|
|
555
|
+
"""
|
|
556
|
+
ignored = [
|
|
557
|
+
option
|
|
558
|
+
for option, dest in DEMO_IGNORED_OPTIONS
|
|
559
|
+
if getattr(parsed_args, dest) is not None
|
|
560
|
+
]
|
|
561
|
+
if ignored:
|
|
562
|
+
logger.warning(
|
|
563
|
+
"argument --demo: %s ignored, the demo data covers the "
|
|
564
|
+
"current year only.",
|
|
565
|
+
", ".join(ignored),
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
iso_year = (
|
|
569
|
+
datetime.datetime.now(
|
|
570
|
+
tz=datetime.timezone.utc,
|
|
571
|
+
)
|
|
572
|
+
.isocalendar()
|
|
573
|
+
.year
|
|
574
|
+
)
|
|
575
|
+
parsed_args.year = [iso_year]
|
|
576
|
+
parsed_args.week = _weeks_in_iso_year(iso_year)
|
|
577
|
+
parsed_args.cbar = True
|
|
578
|
+
|
|
579
|
+
|
|
534
580
|
def _default_year_and_week(
|
|
535
581
|
now: datetime.datetime,
|
|
536
582
|
) -> tuple[list[int], int]:
|
|
@@ -572,7 +618,14 @@ def _process_args(
|
|
|
572
618
|
# double filter between the ISO-week year column and the raw date column.
|
|
573
619
|
# When only one endpoint is given it derives a partial-year view; when
|
|
574
620
|
# both are given --end-date wins for the year/week since it caps the range.
|
|
575
|
-
|
|
621
|
+
#
|
|
622
|
+
# --demo is exempt: it brings its own data for the current ISO year, so
|
|
623
|
+
# resolving a date range against it would only produce a misleading
|
|
624
|
+
# warning about the demo's own year.
|
|
625
|
+
if parsed_args.demo:
|
|
626
|
+
_apply_demo_overrides(parsed_args)
|
|
627
|
+
else:
|
|
628
|
+
_resolve_date_filter_overrides(parsed_args)
|
|
576
629
|
|
|
577
630
|
if (
|
|
578
631
|
parsed_args.start_date
|
|
@@ -288,11 +288,28 @@ def _generate_static_heatmaps(
|
|
|
288
288
|
]
|
|
289
289
|
logger.debug(args)
|
|
290
290
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
291
|
+
generated_files: list[Path | None] = []
|
|
292
|
+
if len(config.cmap) == 1:
|
|
293
|
+
# For a single colormap, avoid spawning a multiprocessing Pool (and
|
|
294
|
+
# the associated per-worker imports on spawn-based platforms). This
|
|
295
|
+
# removes unnecessary overhead for the common default case while
|
|
296
|
+
# still returning the generated file so opening works as before.
|
|
297
|
+
seq, cmap = args[0][:2] # (seq, cmap, ...)
|
|
298
|
+
generated_files = [
|
|
299
|
+
_generate_heatmap(
|
|
300
|
+
seq,
|
|
301
|
+
cmap,
|
|
302
|
+
config,
|
|
303
|
+
pivoted_dataframe,
|
|
304
|
+
return_image=False,
|
|
305
|
+
)
|
|
306
|
+
]
|
|
307
|
+
else:
|
|
308
|
+
with multiprocessing.Pool(
|
|
309
|
+
initializer=_init_worker_logging,
|
|
310
|
+
initargs=(config,),
|
|
311
|
+
) as pool:
|
|
312
|
+
generated_files = pool.starmap(_generate_heatmap_wrapper, args)
|
|
296
313
|
|
|
297
314
|
# Workers never open browsers; open the finished heatmaps from the main
|
|
298
315
|
# process instead, so -o does not spawn a tab per background worker.
|
|
@@ -893,12 +910,14 @@ def _refresh_output_dir(config: argparse.Namespace) -> None:
|
|
|
893
910
|
try:
|
|
894
911
|
shutil.rmtree(output_dir)
|
|
895
912
|
except OSError as e:
|
|
913
|
+
# Logged and skipped rather than returned from: bailing out
|
|
914
|
+
# here would skip the mkdir below and leave the caller with
|
|
915
|
+
# no output directory at all.
|
|
896
916
|
logger.error(
|
|
897
917
|
"Error removing directory: %s - %s.",
|
|
898
918
|
output_dir,
|
|
899
919
|
e,
|
|
900
920
|
)
|
|
901
|
-
return
|
|
902
921
|
|
|
903
922
|
# Ensure the output directory exists for writing files.
|
|
904
923
|
# This will create it if it doesn't exist or was just purged.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: heatmap_cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.27.0
|
|
4
4
|
Summary: A console program that generates a yearly calendar heatmap.
|
|
5
5
|
Author-email: Kian-Meng Ang <kianmeng@cpan.org>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
@@ -56,7 +56,7 @@ heatmap -h -v
|
|
|
56
56
|
```console
|
|
57
57
|
usage: heatmap_cli [--demo [NUMBER_OF_COLORMAP]] [--seed SEED] [-y YEAR]
|
|
58
58
|
[-w WEEK] [-e END_DATE] [-s START_DATE] [-O OUTPUT_DIR]
|
|
59
|
-
[-o] [-p] [-
|
|
59
|
+
[-o] [-p] [-t TITLE] [-u AUTHOR] [-f IMAGE_FORMAT]
|
|
60
60
|
[-c COLORMAP] [-i COLORMAP_MIN_VALUE]
|
|
61
61
|
[-x COLORMAP_MAX_VALUE] [-b]
|
|
62
62
|
[-a | --annotate | --no-annotate] [--animate-by-week] [-q]
|
|
@@ -75,32 +75,30 @@ positional arguments:
|
|
|
75
75
|
|
|
76
76
|
options:
|
|
77
77
|
--demo [NUMBER_OF_COLORMAP]
|
|
78
|
-
generate number of heatmaps by colormaps (default: '
|
|
78
|
+
generate number of heatmaps by colormaps (default: '194'). Implied: covers the current ISO year; -y/-w/-s/-e/-c are ignored.
|
|
79
79
|
--seed SEED
|
|
80
80
|
set random seed for reproducible --demo output (default: None)
|
|
81
|
-
-y
|
|
81
|
+
-y, --year YEAR
|
|
82
82
|
filter by year from the CSV file (default: 'None')
|
|
83
|
-
-w
|
|
83
|
+
-w, --week WEEK
|
|
84
84
|
filter until week of the year from the CSV file (default: current week)
|
|
85
|
-
-e
|
|
85
|
+
-e, --end-date END_DATE
|
|
86
86
|
filter until the date of the year from the CSV file and this will overwrite -y and -w option (default: None)
|
|
87
|
-
-s
|
|
87
|
+
-s, --start-date START_DATE
|
|
88
88
|
filter from the date of the year from the CSV file and this will overwrite -y and -w option (default: None)
|
|
89
|
-
-O
|
|
89
|
+
-O, --output-dir OUTPUT_DIR
|
|
90
90
|
set default output folder (default: 'output')
|
|
91
91
|
-o, --open
|
|
92
92
|
open the generated heatmap using the default program (default: False)
|
|
93
93
|
-p, --purge
|
|
94
94
|
remove all leftover artifacts set by --output-dir folder (default: False)
|
|
95
|
-
-
|
|
96
|
-
show verbosity of debugging log. Use -vv, -vvv for more details
|
|
97
|
-
-t TITLE, --title TITLE
|
|
95
|
+
-t, --title TITLE
|
|
98
96
|
set title for the heatmap (default: None)
|
|
99
|
-
-u
|
|
97
|
+
-u, --author AUTHOR
|
|
100
98
|
set author for the heatmap (default: kianmeng.org)
|
|
101
|
-
-f
|
|
99
|
+
-f, --format IMAGE_FORMAT
|
|
102
100
|
set the default image format (default: 'png')
|
|
103
|
-
-c
|
|
101
|
+
-c, --cmap COLORMAP
|
|
104
102
|
Set default colormap. (default: 'RdYlGn_r')
|
|
105
103
|
Available colormaps:
|
|
106
104
|
Accent, Accent_r, afmhot, afmhot_r, autumn, autumn_r
|
|
@@ -119,30 +117,31 @@ options:
|
|
|
119
117
|
hot, hot_r, hsv, hsv_r, icefire, icefire_r
|
|
120
118
|
inferno, inferno_r, jet, jet_r, magma, magma_r
|
|
121
119
|
mako, mako_r, managua, managua_r, nipy_spectral, nipy_spectral_r
|
|
122
|
-
ocean, ocean_r,
|
|
123
|
-
Paired, Paired_r, Pastel1, Pastel1_r
|
|
124
|
-
pink, pink_r, PiYG, PiYG_r
|
|
125
|
-
PRGn, PRGn_r, prism, prism_r
|
|
126
|
-
PuBuGn, PuBuGn_r, PuOr, PuOr_r
|
|
127
|
-
Purples, Purples_r, rainbow, rainbow_r
|
|
128
|
-
RdGy, RdGy_r, RdPu, RdPu_r
|
|
129
|
-
RdYlGn, RdYlGn_r, Reds, Reds_r
|
|
130
|
-
seismic, seismic_r, Set1, Set1_r
|
|
131
|
-
Set3, Set3_r, Spectral, Spectral_r
|
|
132
|
-
summer, summer_r, tab10, tab10_r
|
|
133
|
-
tab20b, tab20b_r, tab20c, tab20c_r
|
|
134
|
-
turbo, turbo_r, twilight, twilight_r
|
|
135
|
-
vanimo, vanimo_r, viridis, viridis_r
|
|
136
|
-
winter, winter_r, Wistia, Wistia_r
|
|
137
|
-
YlGnBu, YlGnBu_r, YlOrBr, YlOrBr_r
|
|
138
|
-
|
|
120
|
+
ocean, ocean_r, okabe_ito, okabe_ito_r, Oranges, Oranges_r
|
|
121
|
+
OrRd, OrRd_r, Paired, Paired_r, Pastel1, Pastel1_r
|
|
122
|
+
Pastel2, Pastel2_r, pink, pink_r, PiYG, PiYG_r
|
|
123
|
+
plasma, plasma_r, PRGn, PRGn_r, prism, prism_r
|
|
124
|
+
PuBu, PuBu_r, PuBuGn, PuBuGn_r, PuOr, PuOr_r
|
|
125
|
+
PuRd, PuRd_r, Purples, Purples_r, rainbow, rainbow_r
|
|
126
|
+
RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r
|
|
127
|
+
RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r
|
|
128
|
+
rocket, rocket_r, seismic, seismic_r, Set1, Set1_r
|
|
129
|
+
Set2, Set2_r, Set3, Set3_r, Spectral, Spectral_r
|
|
130
|
+
spring, spring_r, summer, summer_r, tab10, tab10_r
|
|
131
|
+
tab20, tab20_r, tab20b, tab20b_r, tab20c, tab20c_r
|
|
132
|
+
terrain, terrain_r, turbo, turbo_r, twilight, twilight_r
|
|
133
|
+
twilight_shifted, twilight_shifted_r, vanimo, vanimo_r, viridis, viridis_r
|
|
134
|
+
vlag, vlag_r, winter, winter_r, Wistia, Wistia_r
|
|
135
|
+
YlGn, YlGn_r, YlGnBu, YlGnBu_r, YlOrBr, YlOrBr_r
|
|
136
|
+
YlOrRd, YlOrRd_r
|
|
137
|
+
-i, --cmap-min COLORMAP_MIN_VALUE
|
|
139
138
|
Set the minimum value of the colormap range (default: None)
|
|
140
|
-
-x
|
|
139
|
+
-x, --cmap-max COLORMAP_MAX_VALUE
|
|
141
140
|
Set the maximum value of the colormap range (default: None)
|
|
142
141
|
-b, --cbar
|
|
143
142
|
show colorbar (default: False)
|
|
144
143
|
-a, --annotate, --no-annotate
|
|
145
|
-
add count to each heatmap region (use --no-annotate to disable)
|
|
144
|
+
add count to each heatmap region (use --no-annotate to disable)
|
|
146
145
|
--animate-by-week
|
|
147
146
|
create an animation for each day of the current week
|
|
148
147
|
-q, --quiet
|
|
@@ -59,8 +59,12 @@ def test_readme_help_block_is_in_sync(cli_runner):
|
|
|
59
59
|
"colormap set; re-run `nox -s readme`"
|
|
60
60
|
)
|
|
61
61
|
|
|
62
|
+
# argparse reflows the usage block to the terminal width, so compare
|
|
63
|
+
# wording only, not line wrapping.
|
|
64
|
+
collapse_whitespace = lambda text: " ".join(text.split()) # noqa: E731
|
|
65
|
+
|
|
62
66
|
ret = cli_runner("-h", expect_error=False)
|
|
63
|
-
assert block == ret.stdout
|
|
67
|
+
assert collapse_whitespace(block) == collapse_whitespace(ret.stdout)
|
|
64
68
|
|
|
65
69
|
|
|
66
70
|
def test_help_output_has_no_trailing_whitespace(cli_runner):
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# Copyright (C) 2023,2024,2025,2026 Kian-Meng Ang
|
|
2
|
-
#
|
|
3
|
-
# This program is free software: you can redistribute it and/or modify
|
|
4
|
-
# it under the terms of the GNU Affero General Public License as published
|
|
5
|
-
# by the Free Software Foundation, either version 3 of the License, or
|
|
6
|
-
# (at your option) any later version.
|
|
7
|
-
#
|
|
8
|
-
# This program is distributed in the hope that it will be useful,
|
|
9
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
-
# GNU Affero General Public License for more details.
|
|
12
|
-
#
|
|
13
|
-
# You should have received a copy of the GNU Affero General Public License
|
|
14
|
-
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
-
|
|
16
|
-
import pytest
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
@pytest.mark.parametrize("option", ["-v", "--verbose"])
|
|
20
|
-
def test_debug_logs(cli_runner, csv_file, option):
|
|
21
|
-
csv = csv_file("sample.csv")
|
|
22
|
-
ret = cli_runner(csv, "-d", option)
|
|
23
|
-
assert "verbose=1" in ret.stderr
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def test_verbose_count(cli_runner, csv_file):
|
|
27
|
-
csv = csv_file("sample.csv")
|
|
28
|
-
for count in range(1, 4):
|
|
29
|
-
verbose = "v" * count
|
|
30
|
-
ret = cli_runner(csv, "-d", f"-{verbose}")
|
|
31
|
-
assert f"verbose={count}" in ret.stderr
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|