heatmap_cli 0.27.0__tar.gz → 0.27.1__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.
Files changed (53) hide show
  1. {heatmap_cli-0.27.0/src/heatmap_cli.egg-info → heatmap_cli-0.27.1}/PKG-INFO +1 -1
  2. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/pyproject.toml +1 -1
  3. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1/src/heatmap_cli.egg-info}/PKG-INFO +1 -1
  4. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/src/heatmap_cli.egg-info/SOURCES.txt +3 -0
  5. heatmap_cli-0.27.1/tests/test_agg_backend.py +40 -0
  6. heatmap_cli-0.27.1/tests/test_animate_future_day.py +60 -0
  7. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_cmap_option.py +23 -0
  8. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_demo_option.py +11 -0
  9. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_heatmap_open.py +26 -0
  10. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_setup_logging.py +9 -0
  11. heatmap_cli-0.27.1/tests/test_supported_formats.py +46 -0
  12. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/LICENSE.md +0 -0
  13. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/README.md +0 -0
  14. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/setup.cfg +0 -0
  15. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/src/heatmap_cli/__init__.py +0 -0
  16. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/src/heatmap_cli/__main__.py +0 -0
  17. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/src/heatmap_cli/cli.py +0 -0
  18. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/src/heatmap_cli/heatmap.py +0 -0
  19. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/src/heatmap_cli/py.typed +0 -0
  20. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/src/heatmap_cli.egg-info/dependency_links.txt +0 -0
  21. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/src/heatmap_cli.egg-info/entry_points.txt +0 -0
  22. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/src/heatmap_cli.egg-info/requires.txt +0 -0
  23. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/src/heatmap_cli.egg-info/top_level.txt +0 -0
  24. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_animate_by_week.py +0 -0
  25. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_animate_no_frames.py +0 -0
  26. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_animate_open.py +0 -0
  27. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_annotate_flag.py +0 -0
  28. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_annotation_truncation.py +0 -0
  29. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_cbar_flag.py +0 -0
  30. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_cmax_option.py +0 -0
  31. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_cmin_option.py +0 -0
  32. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_configure_cbar.py +0 -0
  33. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_debug_flag.py +0 -0
  34. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_end_date_option.py +0 -0
  35. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_env_flag.py +0 -0
  36. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_heatmap_direct.py +0 -0
  37. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_heatmap_errors.py +0 -0
  38. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_heatmap_utils.py +0 -0
  39. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_heatmap_wrapper.py +0 -0
  40. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_help_flag.py +0 -0
  41. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_iso_53_week_year.py +0 -0
  42. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_no_annotate.py +0 -0
  43. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_open_heatmap.py +0 -0
  44. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_output_dir_option.py +0 -0
  45. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_purge_flag.py +0 -0
  46. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_quiet_flag.py +0 -0
  47. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_refresh_output_dir.py +0 -0
  48. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_start_date_option.py +0 -0
  49. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_title_option.py +0 -0
  50. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_version_flag.py +0 -0
  51. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_week_option.py +0 -0
  52. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/tests/test_year_option.py +0 -0
  53. {heatmap_cli-0.27.0 → heatmap_cli-0.27.1}/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.27.0
3
+ Version: 0.27.1
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
@@ -28,7 +28,7 @@ classifiers = [
28
28
  "Programming Language :: Python",
29
29
  "Topic :: Scientific/Engineering :: Visualization",
30
30
  ]
31
- version = "0.27.0"
31
+ version = "0.27.1"
32
32
  keywords = ["heatmap", "cli", "visualization", "calendar", "data-viz"]
33
33
  dependencies = [
34
34
  "matplotlib",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: heatmap_cli
3
- Version: 0.27.0
3
+ Version: 0.27.1
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
@@ -12,7 +12,9 @@ src/heatmap_cli.egg-info/dependency_links.txt
12
12
  src/heatmap_cli.egg-info/entry_points.txt
13
13
  src/heatmap_cli.egg-info/requires.txt
14
14
  src/heatmap_cli.egg-info/top_level.txt
15
+ tests/test_agg_backend.py
15
16
  tests/test_animate_by_week.py
17
+ tests/test_animate_future_day.py
16
18
  tests/test_animate_no_frames.py
17
19
  tests/test_animate_open.py
18
20
  tests/test_annotate_flag.py
@@ -41,6 +43,7 @@ tests/test_quiet_flag.py
41
43
  tests/test_refresh_output_dir.py
42
44
  tests/test_setup_logging.py
43
45
  tests/test_start_date_option.py
46
+ tests/test_supported_formats.py
44
47
  tests/test_title_option.py
45
48
  tests/test_version_flag.py
46
49
  tests/test_week_option.py
@@ -0,0 +1,40 @@
1
+ # Copyright (C) 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
+ """Tests for the Agg backend switch in ``run``."""
17
+
18
+ from pathlib import Path
19
+
20
+
21
+ def test_run_keeps_agg_backend_when_already_active(
22
+ cli_runner,
23
+ csv_file,
24
+ tmpdir,
25
+ monkeypatch,
26
+ ):
27
+ """When matplotlib already uses Agg, ``run`` must not switch again.
28
+
29
+ Matplotlib defaults to ``tkagg`` on a desktop machine, but headless
30
+ environments (CI, ``MPLBACKEND=agg``) start on Agg, so the guard at the
31
+ top of ``run`` has to skip ``mpl.use``.
32
+ """
33
+ monkeypatch.setenv("MPLBACKEND", "agg")
34
+ csv = csv_file("sample.csv")
35
+
36
+ ret = cli_runner(csv, "-y", "2023", "-w", "1", expect_error=False)
37
+
38
+ assert ret.returncode == 0
39
+ output_dir = Path(str(tmpdir.join("scripttest", "output")))
40
+ assert len(list(output_dir.glob("*.png"))) >= 1
@@ -0,0 +1,60 @@
1
+ # Copyright (C) 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
+ """Tests for masking future days in the weekly animation."""
17
+
18
+ import argparse
19
+ from unittest.mock import patch
20
+
21
+ import pandas as pd
22
+
23
+ from heatmap_cli.heatmap import _generate_animated_heatmap
24
+
25
+
26
+ def test_animated_heatmap_skips_future_day_absent_from_pivot():
27
+ """A future day missing from the pivot must be skipped, not crash.
28
+
29
+ ``_filter_and_pivot_data`` normally returns a full 53-week pivot, but the
30
+ guard in ``_generate_animated_heatmap`` still checks membership before
31
+ writing, so exercise the path where the week column is absent.
32
+ """
33
+ config = argparse.Namespace(
34
+ annotate=False,
35
+ cbar=False,
36
+ cmap_min=None,
37
+ cmap_max=None,
38
+ author="Test Author",
39
+ title=None,
40
+ output_dir=".",
41
+ format="png",
42
+ open=False,
43
+ year=2023,
44
+ week=1,
45
+ start_date=None,
46
+ end_date=None,
47
+ cmap=["vlag"],
48
+ animate_by_week=True,
49
+ )
50
+ base_df = pd.DataFrame({"date": []})
51
+ sparse_pivot = pd.DataFrame([[1]], index=[1], columns=["02"])
52
+
53
+ with (
54
+ patch(
55
+ "heatmap_cli.heatmap._filter_and_pivot_data",
56
+ return_value=sparse_pivot,
57
+ ),
58
+ patch("heatmap_cli.heatmap._generate_heatmap", return_value=None),
59
+ ):
60
+ _generate_animated_heatmap(base_df, config)
@@ -13,6 +13,8 @@
13
13
  # You should have received a copy of the GNU Affero General Public License
14
14
  # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
15
 
16
+ from pathlib import Path
17
+
16
18
  import pytest
17
19
 
18
20
 
@@ -42,3 +44,24 @@ def test_multiple_cmaps(cli_runner, csv_file, option):
42
44
  csv = csv_file("sample.csv")
43
45
  ret = cli_runner(csv, "-d", option, "autumn", option, "RdYlGn_r")
44
46
  assert "cmap=['autumn', 'RdYlGn_r']" in ret.stderr
47
+
48
+
49
+ def test_multiple_cmaps_generate_heatmaps(cli_runner, csv_file, tmpdir):
50
+ """Two colormaps must render two heatmaps through the worker pool."""
51
+ csv = csv_file("sample.csv")
52
+ ret = cli_runner(
53
+ csv,
54
+ "-c",
55
+ "autumn",
56
+ "-c",
57
+ "viridis",
58
+ "-y",
59
+ "2023",
60
+ "-w",
61
+ "1",
62
+ expect_error=False,
63
+ )
64
+ assert ret.returncode == 0
65
+
66
+ output_dir = Path(str(tmpdir.join("scripttest", "output")))
67
+ assert len(list(output_dir.glob("*.png"))) == 2
@@ -102,6 +102,17 @@ def test_demo_does_not_clobber_user_sample(tmpdir, cli_runner):
102
102
  assert (output_dir / DEMO_SAMPLE_FILENAME).exists()
103
103
 
104
104
 
105
+ def test_demo_warns_on_ignored_year(cli_runner):
106
+ """-y is overridden by --demo, so the user must be told it is ignored."""
107
+ ret = cli_runner("--demo", 1, "-y", "2020", expect_error=False)
108
+
109
+ assert ret.returncode == 0
110
+ assert (
111
+ "argument --demo: -y/--year ignored, the demo data covers the "
112
+ "current year only." in ret.stderr
113
+ )
114
+
115
+
105
116
  def test_demo_with_purge_survives(cli_runner):
106
117
  """--demo --purge must not delete the sample CSV it just generated."""
107
118
  ret = cli_runner("--demo", 1, "-p", "-Y", expect_error=False)
@@ -81,3 +81,29 @@ def test_static_heatmaps_open_once_after_pool(tmpdir):
81
81
  _generate_static_heatmaps(df, config)
82
82
  assert mocked_open.call_count == 1
83
83
  assert mocked_open.call_args.args[0].exists()
84
+
85
+
86
+ def test_static_heatmaps_open_skips_missing_file(tmpdir):
87
+ """A heatmap that produced no file must not be opened."""
88
+ config = argparse.Namespace(
89
+ annotate=False,
90
+ cbar=False,
91
+ cmap_min=None,
92
+ cmap_max=None,
93
+ author="Test Author",
94
+ title="Test Title",
95
+ output_dir=str(tmpdir),
96
+ format="png",
97
+ open=True,
98
+ cmap=["vlag"],
99
+ )
100
+
101
+ df = pd.DataFrame([[10, 20], [30, 40]], index=[1, 2], columns=["01", "02"])
102
+
103
+ with (
104
+ patch("heatmap_cli.heatmap._generate_heatmap", return_value=None),
105
+ patch("heatmap_cli.heatmap._open_heatmap") as mocked_open,
106
+ ):
107
+ _generate_static_heatmaps(df, config)
108
+
109
+ mocked_open.assert_not_called()
@@ -16,6 +16,7 @@
16
16
  import argparse
17
17
 
18
18
  from heatmap_cli import logger, setup_logging
19
+ from heatmap_cli.heatmap import _init_worker_logging
19
20
 
20
21
 
21
22
  def _make_config(**overrides) -> argparse.Namespace:
@@ -44,3 +45,11 @@ def test_setup_logging_switches_from_quiet_to_verbose():
44
45
  setup_logging(_make_config(debug=True))
45
46
  assert len(logger.handlers) == 1
46
47
  assert logger.level == 10
48
+
49
+
50
+ def test_init_worker_logging_reapplies_setup():
51
+ """Pool workers on spawn platforms call this to reapply logging."""
52
+ _init_worker_logging(_make_config(debug=True))
53
+
54
+ assert len(logger.handlers) == 1
55
+ assert logger.level == 10
@@ -0,0 +1,46 @@
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
+ """Tests for the ``--format`` choices derived from the Agg backend."""
17
+
18
+ from matplotlib.backends.backend_agg import FigureCanvasAgg
19
+
20
+ from heatmap_cli.cli import _get_supported_formats
21
+
22
+
23
+ def test_supported_formats_include_backend_types():
24
+ """Every format the Agg backend can write must be offered."""
25
+ formats = _get_supported_formats()
26
+ backend_types = FigureCanvasAgg.get_supported_filetypes()
27
+
28
+ assert set(backend_types).issubset(formats)
29
+
30
+
31
+ def test_supported_formats_add_gif_when_backend_lacks_it(monkeypatch):
32
+ """``gif`` is offered even on backends that do not list it.
33
+
34
+ The GIF is emitted by the ``--animate-by-week`` path via PIL, not by
35
+ ``savefig``, so it must be appended when the backend omits it.
36
+ """
37
+ monkeypatch.setattr(
38
+ FigureCanvasAgg,
39
+ "get_supported_filetypes",
40
+ classmethod(lambda *_: {"png": "Portable Network Graphics"}),
41
+ )
42
+
43
+ formats = _get_supported_formats()
44
+
45
+ assert "gif" in formats
46
+ assert "png" in formats
File without changes
File without changes
File without changes