dycw-utilities 0.124.0__py3-none-any.whl → 0.124.1__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.124.0
3
+ Version: 0.124.1
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.21; extra == 'test'
9
+ Requires-Dist: hypothesis<6.132,>=6.131.24; 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'
@@ -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.21; extra == 'zzz-test-hypothesis'
83
+ Requires-Dist: hypothesis<6.132,>=6.131.24; 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.6; extra == 'zzz-test-hypothesis'
86
86
  Requires-Dist: pathvalidate<3.3,>=3.2.3; extra == 'zzz-test-hypothesis'
@@ -1,4 +1,4 @@
1
- utilities/__init__.py,sha256=HeZfuK-rk7XFCrcSKl_fSwvax77ZgizR9BO2AjEIbLs,60
1
+ utilities/__init__.py,sha256=dKnQvkqkUeTn_Fv1OMEAfo6Y3pQb7Z1vdJNhQAe_NYM,60
2
2
  utilities/altair.py,sha256=Gpja-flOo-Db0PIPJLJsgzAlXWoKUjPU1qY-DQ829ek,9156
3
3
  utilities/astor.py,sha256=xuDUkjq0-b6fhtwjhbnebzbqQZAjMSHR1IIS5uOodVg,777
4
4
  utilities/asyncio.py,sha256=joGmwv-WiDLYoK4q41TtVgfIT23s8Ok46jT_yEQGjaM,28240
@@ -36,7 +36,7 @@ utilities/luigi.py,sha256=fpH9MbxJDuo6-k9iCXRayFRtiVbUtibCJKugf7ygpv0,5988
36
36
  utilities/math.py,sha256=-mQgbah-dPJwOEWf3SonrFoVZ2AVxMgpeQ3dfVa-oJA,26764
37
37
  utilities/memory_profiler.py,sha256=tf2C51P2lCujPGvRt2Rfc7VEw5LDXmVPCG3z_AvBmbU,962
38
38
  utilities/modules.py,sha256=iuvLluJya-hvl1Q25-Jk3dLgx2Es3ck4SjJiEkAlVTs,3195
39
- utilities/more_itertools.py,sha256=6T0225gBFZtv47-B0JRFOKMz836Wg3Hct79ePPLGpuo,5827
39
+ utilities/more_itertools.py,sha256=fYsGyIPB2s1KRWoH3AkV3CxJxnMLvmidqBf8l1VQnyE,7193
40
40
  utilities/numpy.py,sha256=Xn23sA2ZbVNqwUYEgNJD3XBYH6IbCri_WkHSNhg3NkY,26122
41
41
  utilities/operator.py,sha256=0M2yZJ0PODH47ogFEnkGMBe_cfxwZR02T_92LZVZvHo,3715
42
42
  utilities/optuna.py,sha256=loyJGWTzljgdJaoLhP09PT8Jz6o_pwBOwehY33lHkhw,1923
@@ -88,7 +88,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
88
88
  utilities/whenever.py,sha256=jS31ZAY5OMxFxLja_Yo5Fidi87Pd-GoVZ7Vi_teqVDA,16743
89
89
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
90
90
  utilities/zoneinfo.py,sha256=-5j7IQ9nb7gR43rdgA7ms05im-XuqhAk9EJnQBXxCoQ,1874
91
- dycw_utilities-0.124.0.dist-info/METADATA,sha256=-1BZhlwOBb6JkkxdOqznS-XXxhlcvdZfGawiKrjB7Fc,12943
92
- dycw_utilities-0.124.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
- dycw_utilities-0.124.0.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
- dycw_utilities-0.124.0.dist-info/RECORD,,
91
+ dycw_utilities-0.124.1.dist-info/METADATA,sha256=oaCBE9DgOXYJkT6-mZs_e6X54BEOtn_snXqk5zrtmNQ,12943
92
+ dycw_utilities-0.124.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
+ dycw_utilities-0.124.1.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
+ dycw_utilities-0.124.1.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.124.0"
3
+ __version__ = "0.124.1"
@@ -37,25 +37,81 @@ _U = TypeVar("_U")
37
37
 
38
38
  @overload
39
39
  def bucket_mapping(
40
- iterable: Iterable[_T], func: Callable[[_T], THashable], /, *, list: Literal[True]
40
+ iterable: Iterable[_T],
41
+ func: Callable[[_T], THashable],
42
+ /,
43
+ *,
44
+ transform: Callable[[_T], _U],
45
+ list: Literal[True],
46
+ ) -> Mapping[THashable, Sequence[_U]]: ...
47
+ @overload
48
+ def bucket_mapping(
49
+ iterable: Iterable[_T],
50
+ func: Callable[[_T], THashable],
51
+ /,
52
+ *,
53
+ transform: Callable[[_T], _U],
54
+ list: bool = False,
55
+ ) -> Mapping[THashable, Iterator[_U]]: ...
56
+ @overload
57
+ def bucket_mapping(
58
+ iterable: Iterable[_T],
59
+ func: Callable[[_T], THashable],
60
+ /,
61
+ *,
62
+ transform: Callable[[_T], _U] | None = None,
63
+ list: Literal[True],
41
64
  ) -> Mapping[THashable, Sequence[_T]]: ...
42
65
  @overload
43
66
  def bucket_mapping(
44
- iterable: Iterable[_T], func: Callable[[_T], THashable], /, *, list: bool = False
67
+ iterable: Iterable[_T],
68
+ func: Callable[[_T], THashable],
69
+ /,
70
+ *,
71
+ transform: Callable[[_T], _U] | None = None,
72
+ list: bool = False,
45
73
  ) -> Mapping[THashable, Iterator[_T]]: ...
74
+ @overload
75
+ def bucket_mapping(
76
+ iterable: Iterable[_T],
77
+ func: Callable[[_T], THashable],
78
+ /,
79
+ *,
80
+ transform: Callable[[_T], _U] | None = None,
81
+ list: bool = False,
82
+ ) -> (
83
+ Mapping[THashable, Iterator[_T]]
84
+ | Mapping[THashable, Iterator[_U]]
85
+ | Mapping[THashable, Sequence[_T]]
86
+ | Mapping[THashable, Sequence[_U]]
87
+ ): ...
46
88
  def bucket_mapping(
47
89
  iterable: Iterable[_T],
48
90
  func: Callable[[_T], THashable],
49
91
  /,
50
92
  *,
93
+ transform: Callable[[_T], _U] | None = None,
51
94
  list: bool = False, # noqa: A002
52
- ) -> Mapping[THashable, Iterator[_T]] | Mapping[THashable, Sequence[_T]]:
95
+ ) -> (
96
+ Mapping[THashable, Iterator[_T]]
97
+ | Mapping[THashable, Iterator[_U]]
98
+ | Mapping[THashable, Sequence[_T]]
99
+ | Mapping[THashable, Sequence[_U]]
100
+ ):
53
101
  """Bucket the values of iterable into a mapping."""
54
102
  b = bucket(iterable, func)
55
103
  mapping = {key: b[key] for key in b}
56
- if list:
57
- return {key: builtins.list(value) for key, value in mapping.items()}
58
- return mapping
104
+ match transform, list:
105
+ case None, False:
106
+ return mapping
107
+ case None, True:
108
+ return {k: builtins.list(v) for k, v in mapping.items()}
109
+ case _, False:
110
+ return {k: map(transform, v) for k, v in mapping.items()}
111
+ case _, True:
112
+ return {k: builtins.list(map(transform, v)) for k, v in mapping.items()}
113
+ case _ as never:
114
+ assert_never(never)
59
115
 
60
116
 
61
117
  ##