dycw-utilities 0.109.11__py3-none-any.whl → 0.109.13__py3-none-any.whl

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.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-utilities
3
- Version: 0.109.11
3
+ Version: 0.109.13
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
7
7
  Requires-Dist: typing-extensions<4.14,>=4.13.1
8
8
  Provides-Extra: test
9
- Requires-Dist: hypothesis<6.132,>=6.131.6; extra == 'test'
9
+ Requires-Dist: hypothesis<6.132,>=6.131.7; extra == 'test'
10
10
  Requires-Dist: pytest-asyncio<0.27,>=0.26.0; extra == 'test'
11
11
  Requires-Dist: pytest-cov<6.2,>=6.1.1; extra == 'test'
12
12
  Requires-Dist: pytest-instafail<0.6,>=0.5.0; extra == 'test'
@@ -62,7 +62,7 @@ Requires-Dist: fastapi<0.116,>=0.115.11; extra == 'zzz-test-fastapi'
62
62
  Requires-Dist: httpx<0.29,>=0.28.1; extra == 'zzz-test-fastapi'
63
63
  Requires-Dist: uvicorn<0.35,>=0.34.1; extra == 'zzz-test-fastapi'
64
64
  Provides-Extra: zzz-test-fpdf2
65
- Requires-Dist: fpdf2<2.9,>=2.8.2; extra == 'zzz-test-fpdf2'
65
+ Requires-Dist: fpdf2<2.9,>=2.8.3; extra == 'zzz-test-fpdf2'
66
66
  Requires-Dist: tzlocal<5.4,>=5.3.1; extra == 'zzz-test-fpdf2'
67
67
  Provides-Extra: zzz-test-functions
68
68
  Provides-Extra: zzz-test-functools
@@ -80,7 +80,7 @@ Provides-Extra: zzz-test-hypothesis
80
80
  Requires-Dist: aiosqlite<0.22,>=0.21.0; extra == 'zzz-test-hypothesis'
81
81
  Requires-Dist: asyncpg<0.31,>=0.30.0; extra == 'zzz-test-hypothesis'
82
82
  Requires-Dist: greenlet<3.3,>=3.2.0; extra == 'zzz-test-hypothesis'
83
- Requires-Dist: hypothesis<6.132,>=6.131.6; extra == 'zzz-test-hypothesis'
83
+ Requires-Dist: hypothesis<6.132,>=6.131.7; extra == 'zzz-test-hypothesis'
84
84
  Requires-Dist: luigi<3.7,>=3.6.0; extra == 'zzz-test-hypothesis'
85
85
  Requires-Dist: numpy<2.3,>=2.2.5; extra == 'zzz-test-hypothesis'
86
86
  Requires-Dist: pathvalidate<3.3,>=3.2.3; extra == 'zzz-test-hypothesis'
@@ -117,7 +117,7 @@ Provides-Extra: zzz-test-memory-profiler
117
117
  Requires-Dist: memory-profiler<0.62,>=0.61.0; extra == 'zzz-test-memory-profiler'
118
118
  Provides-Extra: zzz-test-modules
119
119
  Provides-Extra: zzz-test-more-itertools
120
- Requires-Dist: more-itertools<10.7,>=10.6.0; extra == 'zzz-test-more-itertools'
120
+ Requires-Dist: more-itertools<10.8,>=10.7.0; extra == 'zzz-test-more-itertools'
121
121
  Provides-Extra: zzz-test-numpy
122
122
  Requires-Dist: numpy<2.3,>=2.2.5; extra == 'zzz-test-numpy'
123
123
  Provides-Extra: zzz-test-operator
@@ -1,5 +1,5 @@
1
- utilities/__init__.py,sha256=_vRzPvVy8_Ku0AnpYTnc9dnxOxrQYmBHHCFsFCtY3eY,61
2
- utilities/altair.py,sha256=NSyDsm8QlkAGmsGdxVwCkHnPxt_35yJBa9Lg7bz9Ays,9054
1
+ utilities/__init__.py,sha256=8b_ivOe7dAl9N0yVvE9__TwO49X5ejp8NxQ28w6Xp0g,61
2
+ utilities/altair.py,sha256=5WPwsHJoM-ZDh9iek4eSqf8_Ifb3w3KDwi7f2mrtXn4,9174
3
3
  utilities/astor.py,sha256=xuDUkjq0-b6fhtwjhbnebzbqQZAjMSHR1IIS5uOodVg,777
4
4
  utilities/asyncio.py,sha256=41oQUurWMvadFK5gFnaG21hMM0Vmfn2WS6OpC0R9mas,14757
5
5
  utilities/atomicwrites.py,sha256=geFjn9Pwn-tTrtoGjDDxWli9NqbYfy3gGL6ZBctiqSo,5393
@@ -26,7 +26,7 @@ utilities/hashlib.py,sha256=SVTgtguur0P4elppvzOBbLEjVM3Pea0eWB61yg2ilxo,309
26
26
  utilities/http.py,sha256=WcahTcKYRtZ04WXQoWt5EGCgFPcyHD3EJdlMfxvDt-0,946
27
27
  utilities/hypothesis.py,sha256=sLqYcrFn0I3o0R7maqliIERRtAcREk2CKG8rSHY1t5U,46205
28
28
  utilities/ipython.py,sha256=V2oMYHvEKvlNBzxDXdLvKi48oUq2SclRg5xasjaXStw,763
29
- utilities/iterables.py,sha256=AZSoLfHdttfdGx71s801YkkhoZ6s5RbJbTsjmf02Xjg,44381
29
+ utilities/iterables.py,sha256=GRuwMOPP7jqOnDdF113XYPjVg23VYn0ts1UlV-1Tzzo,45014
30
30
  utilities/jupyter.py,sha256=ft5JA7fBxXKzP-L9W8f2-wbF0QeYc_2uLQNFDVk4Z-M,2917
31
31
  utilities/logging.py,sha256=opIwFjGKOYyMntVeCsFNXOmTY2z02hMf2UtCB76SaI4,25142
32
32
  utilities/loguru.py,sha256=MEMQVWrdECxk1e3FxGzmOf21vWT9j8CAir98SEXFKPA,3809
@@ -85,7 +85,7 @@ utilities/warnings.py,sha256=yUgjnmkCRf6QhdyAXzl7u0qQFejhQG3PrjoSwxpbHrs,1819
85
85
  utilities/whenever.py,sha256=TjoTAJ1R27-rKXiXzdE4GzPidmYqm0W58XydDXp-QZM,17786
86
86
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
87
87
  utilities/zoneinfo.py,sha256=-DQz5a0Ikw9jfSZtL0BEQkXOMC9yGn_xiJYNCLMiqEc,1989
88
- dycw_utilities-0.109.11.dist-info/METADATA,sha256=JziFm-4YsBmXqBY-ItflFiFP7cZHo4t6jNVlnKEFY1c,13005
89
- dycw_utilities-0.109.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
90
- dycw_utilities-0.109.11.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
91
- dycw_utilities-0.109.11.dist-info/RECORD,,
88
+ dycw_utilities-0.109.13.dist-info/METADATA,sha256=7LZJJAQIYMDDVTGd220fgWLkFlrPCQQYDATGv4AnkeI,13005
89
+ dycw_utilities-0.109.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
90
+ dycw_utilities-0.109.13.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
91
+ dycw_utilities-0.109.13.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.109.11"
3
+ __version__ = "0.109.13"
utilities/altair.py CHANGED
@@ -62,6 +62,7 @@ def plot_dataframes(
62
62
  height: int = _HEIGHT,
63
63
  width: int = _WIDTH,
64
64
  interpolate: Any = Undefined,
65
+ title: str | None = None,
65
66
  ) -> VConcatChart:
66
67
  """Plot a DataFrame as a set of time series, with a multi-line tooltip."""
67
68
  import polars as pl
@@ -143,9 +144,12 @@ def plot_dataframes(
143
144
  for line, pts, rls, spec in zip(lines, points, rules, specs, strict=True)
144
145
  ]
145
146
  zoom = selection_interval(bind="scales", encodings=["x"])
146
- return (
147
+ chart = (
147
148
  vconcat(*layers).add_params(zoom).resolve_scale(color="independent", x="shared")
148
149
  )
150
+ if title is not None:
151
+ chart = chart.properties(title=title)
152
+ return chart
149
153
 
150
154
 
151
155
  def _plot_dataframes_get_spec(
utilities/iterables.py CHANGED
@@ -19,7 +19,7 @@ from enum import Enum
19
19
  from functools import cmp_to_key, partial, reduce
20
20
  from itertools import accumulate, chain, groupby, islice, pairwise, product
21
21
  from math import isnan
22
- from operator import add, or_
22
+ from operator import add, itemgetter, or_
23
23
  from typing import (
24
24
  TYPE_CHECKING,
25
25
  Any,
@@ -861,6 +861,24 @@ def filter_include_and_exclude(
861
861
  ##
862
862
 
863
863
 
864
+ def group_consecutive_integers(iterable: Iterable[int], /) -> Iterable[tuple[int, int]]:
865
+ """Group consecutive integers."""
866
+ integers = sorted(iterable)
867
+ for _, group in groupby(enumerate(integers), key=lambda x: x[1] - x[0]):
868
+ as_list = list(map(itemgetter(1), group))
869
+ yield as_list[0], as_list[-1]
870
+
871
+
872
+ def ungroup_consecutive_integers(
873
+ iterable: Iterable[tuple[int, int]], /
874
+ ) -> Iterable[int]:
875
+ """Ungroup consecutive integers."""
876
+ return chain.from_iterable(range(start, end + 1) for start, end in iterable)
877
+
878
+
879
+ ##
880
+
881
+
864
882
  @overload
865
883
  def groupby_lists(
866
884
  iterable: Iterable[_T], /, *, key: None = None
@@ -1504,6 +1522,7 @@ __all__ = [
1504
1522
  "ensure_iterable_not_str",
1505
1523
  "expanding_window",
1506
1524
  "filter_include_and_exclude",
1525
+ "group_consecutive_integers",
1507
1526
  "groupby_lists",
1508
1527
  "hashable_to_iterable",
1509
1528
  "is_iterable",
@@ -1525,5 +1544,6 @@ __all__ = [
1525
1544
  "sum_mappings",
1526
1545
  "take",
1527
1546
  "transpose",
1547
+ "ungroup_consecutive_integers",
1528
1548
  "unique_everseen",
1529
1549
  ]