heatmap_cli 0.25.4__tar.gz → 0.25.5__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 (51) hide show
  1. {heatmap_cli-0.25.4/src/heatmap_cli.egg-info → heatmap_cli-0.25.5}/PKG-INFO +1 -1
  2. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/pyproject.toml +4 -1
  3. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/src/heatmap_cli/__init__.py +3 -2
  4. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/src/heatmap_cli/heatmap.py +22 -6
  5. heatmap_cli-0.25.5/src/heatmap_cli/py.typed +0 -0
  6. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5/src/heatmap_cli.egg-info}/PKG-INFO +1 -1
  7. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/src/heatmap_cli.egg-info/SOURCES.txt +1 -0
  8. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_animate_by_week.py +18 -0
  9. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_heatmap_errors.py +11 -0
  10. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_no_annotate.py +1 -1
  11. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/LICENSE.md +0 -0
  12. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/README.md +0 -0
  13. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/setup.cfg +0 -0
  14. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/src/heatmap_cli/__main__.py +0 -0
  15. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/src/heatmap_cli/cli.py +0 -0
  16. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/src/heatmap_cli.egg-info/dependency_links.txt +0 -0
  17. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/src/heatmap_cli.egg-info/entry_points.txt +0 -0
  18. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/src/heatmap_cli.egg-info/requires.txt +0 -0
  19. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/src/heatmap_cli.egg-info/top_level.txt +0 -0
  20. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_animate_no_frames.py +0 -0
  21. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_animate_open.py +0 -0
  22. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_annotate_flag.py +0 -0
  23. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_annotation_truncation.py +0 -0
  24. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_cbar_flag.py +0 -0
  25. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_cmap_option.py +0 -0
  26. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_cmax_option.py +0 -0
  27. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_cmin_option.py +0 -0
  28. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_configure_cbar.py +0 -0
  29. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_debug_flag.py +0 -0
  30. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_demo_option.py +0 -0
  31. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_end_date_option.py +0 -0
  32. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_env_flag.py +0 -0
  33. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_heatmap_direct.py +0 -0
  34. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_heatmap_open.py +0 -0
  35. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_heatmap_utils.py +0 -0
  36. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_heatmap_wrapper.py +0 -0
  37. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_help_flag.py +0 -0
  38. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_iso_53_week_year.py +0 -0
  39. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_open_heatmap.py +0 -0
  40. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_output_dir_option.py +0 -0
  41. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_purge_flag.py +0 -0
  42. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_quiet_flag.py +0 -0
  43. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_refresh_output_dir.py +0 -0
  44. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_setup_logging.py +0 -0
  45. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_start_date_option.py +0 -0
  46. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_title_option.py +0 -0
  47. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_verbose_flag.py +0 -0
  48. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_version_flag.py +0 -0
  49. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_week_option.py +0 -0
  50. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/tests/test_year_option.py +0 -0
  51. {heatmap_cli-0.25.4 → heatmap_cli-0.25.5}/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.25.4
3
+ Version: 0.25.5
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
@@ -5,6 +5,9 @@ build-backend = "setuptools.build_meta"
5
5
  [tool.setuptools.packages.find]
6
6
  where = ["src"]
7
7
 
8
+ [tool.setuptools.package-data]
9
+ heatmap_cli = ["py.typed"]
10
+
8
11
  [project]
9
12
  name = "heatmap_cli"
10
13
  description = "A console program that generates a yearly calendar heatmap."
@@ -25,7 +28,7 @@ classifiers = [
25
28
  "Programming Language :: Python",
26
29
  "Topic :: Scientific/Engineering :: Visualization",
27
30
  ]
28
- version = "0.25.4"
31
+ version = "0.25.5"
29
32
  keywords = ["heatmap", "cli", "visualization", "calendar", "data-viz"]
30
33
  dependencies = [
31
34
  "matplotlib",
@@ -28,7 +28,6 @@ from pathlib import Path
28
28
  from typing import Any, cast
29
29
 
30
30
  import matplotlib as mpl
31
- import matplotlib.pyplot as plt
32
31
  import pandas as pd
33
32
  import seaborn as sns
34
33
 
@@ -48,7 +47,9 @@ DEFAULT_DEMO_SEED = 42
48
47
  DEMO_SAMPLE_FILENAME = "heatmap_demo_sample.csv"
49
48
 
50
49
  # Sort colormaps in a case-insensitive manner.
51
- CMAPS = sorted(plt.colormaps, key=str.casefold)
50
+ # The colormap registry is read from matplotlib directly, not pyplot, so that
51
+ # importing the package never pulls in the pyplot backend machinery.
52
+ CMAPS = sorted(mpl.colormaps, key=str.casefold)
52
53
 
53
54
  logger = logging.getLogger(__name__)
54
55
 
@@ -180,6 +180,13 @@ def _generate_animated_heatmap(
180
180
  base_dataframe (pd.DataFrame): The base dataframe with all data.
181
181
  config (argparse.Namespace): Config from command line arguments.
182
182
  """
183
+ if len(config.cmap) > 1:
184
+ logger.warning(
185
+ "--animate-by-week uses only the first colormap; "
186
+ "%d colormap(s) ignored.",
187
+ len(config.cmap) - 1,
188
+ )
189
+
183
190
  # pivot the data once for the entire week to get the final state
184
191
  final_pivoted_df = _filter_and_pivot_data(base_dataframe, config)
185
192
  logger.debug(final_pivoted_df)
@@ -349,7 +356,17 @@ def _read_and_prepare_data(config: argparse.Namespace) -> pd.DataFrame:
349
356
  msg = f"Input CSV file is empty: {config.input_filename}"
350
357
  raise ValueError(msg)
351
358
 
352
- dataframe["date"] = pd.to_datetime(dataframe["date"])
359
+ try:
360
+ dataframe["date"] = pd.to_datetime(
361
+ dataframe["date"],
362
+ format="%Y-%m-%d",
363
+ )
364
+ except ValueError as error:
365
+ msg = (
366
+ "Invalid date format in input CSV: "
367
+ f"{config.input_filename}, expected YYYY-MM-DD."
368
+ )
369
+ raise ValueError(msg) from error
353
370
 
354
371
  negative_counts = dataframe[dataframe["count"] < 0]
355
372
  if not negative_counts.empty:
@@ -514,7 +531,7 @@ def _setup_plot_artists(
514
531
  labelsize=DEFAULT_TICK_LABEL_FONTSIZE,
515
532
  )
516
533
 
517
- options, _ = _configure_heatmap_options(config, cmap, axis)
534
+ options = _configure_heatmap_options(config, cmap, axis)
518
535
  res = sns.heatmap(dataframe, **options)
519
536
 
520
537
  if config.annotate:
@@ -567,7 +584,7 @@ def _configure_heatmap_options(
567
584
  config: argparse.Namespace,
568
585
  cmap: str,
569
586
  axis: Axes,
570
- ) -> tuple[dict[str, Any], dict[str, Any]]:
587
+ ) -> dict[str, Any]:
571
588
  """Configure options for the heatmap plot.
572
589
 
573
590
  Args:
@@ -576,8 +593,7 @@ def _configure_heatmap_options(
576
593
  axis (Axes): Matplotlib axes object.
577
594
 
578
595
  Returns:
579
- tuple[dict, dict]: A tuple containing heatmap options and colorbar
580
- options.
596
+ dict: The options to pass to seaborn's heatmap.
581
597
  """
582
598
  cbar_options = {
583
599
  "orientation": "horizontal",
@@ -611,7 +627,7 @@ def _configure_heatmap_options(
611
627
  "linewidth": 0,
612
628
  },
613
629
  )
614
- return options, cbar_options
630
+ return options
615
631
 
616
632
 
617
633
  def _apply_annotations(res: Axes) -> None:
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: heatmap_cli
3
- Version: 0.25.4
3
+ Version: 0.25.5
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
@@ -5,6 +5,7 @@ src/heatmap_cli/__init__.py
5
5
  src/heatmap_cli/__main__.py
6
6
  src/heatmap_cli/cli.py
7
7
  src/heatmap_cli/heatmap.py
8
+ src/heatmap_cli/py.typed
8
9
  src/heatmap_cli.egg-info/PKG-INFO
9
10
  src/heatmap_cli.egg-info/SOURCES.txt
10
11
  src/heatmap_cli.egg-info/dependency_links.txt
@@ -65,3 +65,21 @@ def test_gif_format_implies_animate_by_week(cli_runner, csv_file, tmpdir):
65
65
  gif_files = list(output_dir.glob("*.gif"))
66
66
  assert len(gif_files) == 1
67
67
  assert "animated" in gif_files[0].name
68
+
69
+
70
+ def test_animate_by_week_warns_on_extra_colormaps(cli_runner, csv_file):
71
+ csv = csv_file("sample.csv")
72
+ ret = cli_runner(
73
+ csv,
74
+ "--animate-by-week",
75
+ "-y",
76
+ "2023",
77
+ "-w",
78
+ "1",
79
+ "-c",
80
+ "vlag",
81
+ "-c",
82
+ "magma",
83
+ )
84
+ assert ret.returncode == 0
85
+ assert "--animate-by-week uses only the first colormap" in ret.stderr
@@ -65,6 +65,17 @@ def test_empty_csv_error_direct(tmpdir):
65
65
  _read_and_prepare_data(config)
66
66
 
67
67
 
68
+ def test_invalid_date_format_error_direct(tmpdir):
69
+ csv_path = Path(tmpdir) / "bad_date.csv"
70
+ with Path(csv_path).open("w") as f:
71
+ f.write("2023/01/01,100\n")
72
+ f.write("2023-01-02,200\n")
73
+
74
+ config = argparse.Namespace(input_filename=str(csv_path), annotate=False)
75
+ with pytest.raises(ValueError, match="expected YYYY-MM-DD"):
76
+ _read_and_prepare_data(config)
77
+
78
+
68
79
  def test_empty_csv_error_cli(cli_runner, tmpdir):
69
80
  csv_path = Path(tmpdir) / "empty.csv"
70
81
  csv_path.write_text("")
@@ -65,5 +65,5 @@ def test_configure_heatmap_options_no_annotate():
65
65
  cmap_max=None,
66
66
  )
67
67
 
68
- options, _ = _configure_heatmap_options(config, "vlag", axis)
68
+ options = _configure_heatmap_options(config, "vlag", axis)
69
69
  assert "annot" not in options
File without changes
File without changes
File without changes