heatmap_cli 0.22.34__tar.gz → 0.22.35__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.22.34/src/heatmap_cli.egg-info → heatmap_cli-0.22.35}/PKG-INFO +1 -1
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/pyproject.toml +1 -1
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/src/heatmap_cli/__init__.py +2 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/src/heatmap_cli/__main__.py +2 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/src/heatmap_cli/cli.py +8 -3
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/src/heatmap_cli/heatmap.py +25 -23
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35/src/heatmap_cli.egg-info}/PKG-INFO +1 -1
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/LICENSE.md +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/README.md +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/setup.cfg +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/src/heatmap_cli.egg-info/SOURCES.txt +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/src/heatmap_cli.egg-info/dependency_links.txt +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/src/heatmap_cli.egg-info/entry_points.txt +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/src/heatmap_cli.egg-info/requires.txt +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/src/heatmap_cli.egg-info/top_level.txt +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_animate_by_week.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_annotate_flag.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_cbar_flag.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_cmap_option.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_cmax_option.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_cmin_option.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_debug_flag.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_demo_option.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_end_date_option.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_env_flag.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_heatmap_direct.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_heatmap_errors.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_heatmap_utils.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_help_flag.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_output_dir_option.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_purge_flag.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_quiet_flag.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_start_date_option.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_title_option.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_verbose_flag.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_version_flag.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_week_option.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_year_option.py +0 -0
- {heatmap_cli-0.22.34 → heatmap_cli-0.22.35}/tests/test_yes_flag.py +0 -0
|
@@ -25,7 +25,7 @@ classifiers = [
|
|
|
25
25
|
"Programming Language :: Python",
|
|
26
26
|
"Topic :: Scientific/Engineering :: Visualization",
|
|
27
27
|
]
|
|
28
|
-
version = "0.22.
|
|
28
|
+
version = "0.22.35"
|
|
29
29
|
keywords = ["heatmap", "cli", "visualization", "calendar", "data-viz"]
|
|
30
30
|
dependencies = [
|
|
31
31
|
"matplotlib",
|
|
@@ -20,12 +20,17 @@ changelog: https://github.com/kianmeng/heatmap_cli/blob/master/CHANGELOG.md
|
|
|
20
20
|
issues: https://github.com/kianmeng/heatmap_cli/issues
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
23
25
|
import argparse
|
|
24
26
|
import datetime
|
|
25
27
|
import multiprocessing
|
|
26
28
|
import sys
|
|
27
|
-
from collections.abc import Sequence
|
|
28
29
|
from itertools import zip_longest
|
|
30
|
+
from typing import TYPE_CHECKING
|
|
31
|
+
|
|
32
|
+
if TYPE_CHECKING:
|
|
33
|
+
from collections.abc import Sequence
|
|
29
34
|
|
|
30
35
|
from heatmap_cli import (
|
|
31
36
|
CMAPS,
|
|
@@ -57,6 +62,7 @@ IMAGE_FORMATS = [
|
|
|
57
62
|
logger = multiprocessing.get_logger()
|
|
58
63
|
|
|
59
64
|
DEFAULT_CMAP = "RdYlGn_r"
|
|
65
|
+
CMAP_ITEMS_PER_ROW = 6
|
|
60
66
|
|
|
61
67
|
|
|
62
68
|
def _valid_date(s: str) -> str:
|
|
@@ -361,9 +367,8 @@ def _generate_cmap_help() -> str:
|
|
|
361
367
|
cmap_default = f" (default: '{DEFAULT_CMAP}')"
|
|
362
368
|
|
|
363
369
|
# Always show all colormaps in help text
|
|
364
|
-
items_per_row = 6
|
|
365
370
|
cmap_choices = "\nAvailable colormaps:\n"
|
|
366
|
-
cmap_bygroups = zip_longest(*(iter(CMAPS),) *
|
|
371
|
+
cmap_bygroups = zip_longest(*(iter(CMAPS),) * CMAP_ITEMS_PER_ROW)
|
|
367
372
|
for cmap_bygroup in cmap_bygroups:
|
|
368
373
|
cmap_choices += " " + ", ".join(filter(None, cmap_bygroup)) + "\n"
|
|
369
374
|
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
"""Main logic to generate heatmap."""
|
|
17
17
|
|
|
18
|
-
import
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
19
20
|
import copy
|
|
20
21
|
import io
|
|
21
22
|
import multiprocessing
|
|
@@ -24,7 +25,10 @@ import shutil
|
|
|
24
25
|
import webbrowser
|
|
25
26
|
from datetime import datetime, timedelta, timezone
|
|
26
27
|
from pathlib import Path
|
|
27
|
-
from typing import Any
|
|
28
|
+
from typing import TYPE_CHECKING, Any
|
|
29
|
+
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
import argparse
|
|
28
32
|
|
|
29
33
|
import matplotlib as mpl
|
|
30
34
|
import matplotlib.pyplot as plt
|
|
@@ -544,7 +548,11 @@ def _configure_cbar(res: plt.Axes) -> None:
|
|
|
544
548
|
Args:
|
|
545
549
|
res (plt.Axes): The matplotlib axes object returned by seaborn.
|
|
546
550
|
"""
|
|
551
|
+
if not res.collections:
|
|
552
|
+
return
|
|
547
553
|
cbar = res.collections[0].colorbar
|
|
554
|
+
if cbar is None:
|
|
555
|
+
return
|
|
548
556
|
cbar.set_label(cbar.ax.get_xlabel(), rotation=0, labelpad=8, loc="left")
|
|
549
557
|
|
|
550
558
|
|
|
@@ -625,7 +633,7 @@ def _open_heatmap(filename: Path) -> None:
|
|
|
625
633
|
Returns:
|
|
626
634
|
None
|
|
627
635
|
"""
|
|
628
|
-
file_uri =
|
|
636
|
+
file_uri = filename.resolve().as_uri()
|
|
629
637
|
webbrowser.open(file_uri)
|
|
630
638
|
logger.info("Open heatmap: %s using default program.", filename.resolve())
|
|
631
639
|
|
|
@@ -719,27 +727,21 @@ def _refresh_output_dir(config: argparse.Namespace) -> None:
|
|
|
719
727
|
"""
|
|
720
728
|
output_dir = _get_output_dir(config)
|
|
721
729
|
|
|
722
|
-
# Determine if purging is required based on --purge and --yes flags.
|
|
723
|
-
should_purge = False
|
|
724
730
|
if config.purge:
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
shutil.rmtree(output_dir)
|
|
740
|
-
except OSError as e:
|
|
741
|
-
logger.error("Error removing directory: %s - %s.", output_dir, e)
|
|
742
|
-
return
|
|
731
|
+
should_purge = config.yes or input(
|
|
732
|
+
f"Are you sure to purge output folder: {output_dir}? [y/N] "
|
|
733
|
+
).lower() in {"y", "yes"}
|
|
734
|
+
if should_purge and output_dir.exists():
|
|
735
|
+
logger.info("Purging output folder: %s", output_dir.absolute())
|
|
736
|
+
try:
|
|
737
|
+
shutil.rmtree(output_dir)
|
|
738
|
+
except OSError as e:
|
|
739
|
+
logger.error(
|
|
740
|
+
"Error removing directory: %s - %s.",
|
|
741
|
+
output_dir,
|
|
742
|
+
e,
|
|
743
|
+
)
|
|
744
|
+
return
|
|
743
745
|
|
|
744
746
|
# Ensure the output directory exists for writing files.
|
|
745
747
|
# This will create it if it doesn't exist or was just purged.
|
|
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
|