dycw-utilities 0.150.15__py3-none-any.whl → 0.151.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.
- {dycw_utilities-0.150.15.dist-info → dycw_utilities-0.151.1.dist-info}/METADATA +1 -1
- {dycw_utilities-0.150.15.dist-info → dycw_utilities-0.151.1.dist-info}/RECORD +9 -9
- utilities/__init__.py +1 -1
- utilities/hypothesis.py +37 -1
- utilities/polars.py +22 -4
- utilities/sqlalchemy_polars.py +2 -2
- {dycw_utilities-0.150.15.dist-info → dycw_utilities-0.151.1.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.150.15.dist-info → dycw_utilities-0.151.1.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.150.15.dist-info → dycw_utilities-0.151.1.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=bBf9Tl-C2hugDGfPB8K4pQzyp1XJyFusRFY_wkOtfbk,60
|
2
2
|
utilities/altair.py,sha256=92E2lCdyHY4Zb-vCw6rEJIsWdKipuu-Tu2ab1ufUfAk,9079
|
3
3
|
utilities/asyncio.py,sha256=2m2a2C-Qgc6OHTTHL332-t66A7xDITt_SORT7a1DJWo,16792
|
4
4
|
utilities/atomicwrites.py,sha256=xcOWenTBRS0oat3kg7Sqe51AohNThMQ2ixPL7QCG8hw,5795
|
@@ -23,7 +23,7 @@ utilities/getpass.py,sha256=DfN5UgMAtFCqS3dSfFHUfqIMZX2shXvwphOz_6J6f6A,103
|
|
23
23
|
utilities/gzip.py,sha256=fkGP3KdsBfXlstodT4wtlp-PwNyUsogpbDCVVVGdsm4,781
|
24
24
|
utilities/hashlib.py,sha256=SVTgtguur0P4elppvzOBbLEjVM3Pea0eWB61yg2ilxo,309
|
25
25
|
utilities/http.py,sha256=TsavEfHlRtlLaeV21Z6KZh0qbPw-kvD1zsQdZ7Kep5Q,977
|
26
|
-
utilities/hypothesis.py,sha256=
|
26
|
+
utilities/hypothesis.py,sha256=muEtgWd8ZR7z4Iv-demKK3dBJY6dC26FYIzNcDd0ViE,40267
|
27
27
|
utilities/importlib.py,sha256=mV1xT_O_zt_GnZZ36tl3xOmMaN_3jErDWY54fX39F6Y,429
|
28
28
|
utilities/inflect.py,sha256=UWOsMRJUJXqcR3rgrQmb35mat-Theu5xo-M9E33eTIE,586
|
29
29
|
utilities/ipython.py,sha256=V2oMYHvEKvlNBzxDXdLvKi48oUq2SclRg5xasjaXStw,763
|
@@ -47,7 +47,7 @@ utilities/pathlib.py,sha256=FnteXeVeMOSc6QTN7oF6UrobjOX9gXv_5tG1slg83W8,8496
|
|
47
47
|
utilities/period.py,sha256=hsHdAKAstfMzB2Ar5EbxjkbMff3CA-B5wtYNVZOXVXI,10127
|
48
48
|
utilities/pickle.py,sha256=MBT2xZCsv0pH868IXLGKnlcqNx2IRVKYNpRcqiQQqxw,653
|
49
49
|
utilities/platform.py,sha256=Ue9LSxYvg9yUXGKuz5aZoy_qkUEXde-v6B09exgSctU,2813
|
50
|
-
utilities/polars.py,sha256=
|
50
|
+
utilities/polars.py,sha256=wusyiQTHMxcPrRzsjWWt975rgcMQBRcaY4cJgkNUzw4,72501
|
51
51
|
utilities/polars_ols.py,sha256=Uc9V5kvlWZ5cU93lKZ-cfAKdVFFw81tqwLW9PxtUvMs,5618
|
52
52
|
utilities/postgres.py,sha256=48km6Mb6hRUb1-0FWg7FKEfrW75z8-7AY1jahtdu_KY,12406
|
53
53
|
utilities/pottery.py,sha256=u0uvyGgYyujxftEMlsv6ppYTKQoVVjHt5jnVxxYz9s4,6596
|
@@ -67,7 +67,7 @@ utilities/shelve.py,sha256=4OzjQI6kGuUbJciqf535rwnao-_IBv66gsT6tRGiUt0,759
|
|
67
67
|
utilities/slack_sdk.py,sha256=ppFBvKgfg5IRWiIoKPtpTyzBtBF4XmwEvU3I5wLJikM,2140
|
68
68
|
utilities/socket.py,sha256=K77vfREvzoVTrpYKo6MZakol0EYu2q1sWJnnZqL0So0,118
|
69
69
|
utilities/sqlalchemy.py,sha256=QbCFKefrkkqL23iDF5WdOKRfISMj6c-SyrI3rvBATE4,39641
|
70
|
-
utilities/sqlalchemy_polars.py,sha256=
|
70
|
+
utilities/sqlalchemy_polars.py,sha256=TqNLQz85ow3gMjf17T_3WKL0MWYgSi0sXOgMYMxdNSU,14249
|
71
71
|
utilities/statsmodels.py,sha256=koyiBHvpMcSiBfh99wFUfSggLNx7cuAw3rwyfAhoKpQ,3410
|
72
72
|
utilities/string.py,sha256=MB0X6UPTUc06JdAdj-PctZ238IXeCjE5dAJibNw6ZrU,587
|
73
73
|
utilities/tempfile.py,sha256=HxB2BF28CcecDJLQ3Bx2Ej-Pb6RJc6W9ngSpB9CnP4k,2018
|
@@ -89,8 +89,8 @@ utilities/zoneinfo.py,sha256=oEH-nL3t4h9uawyZqWDtNtDAl6M-CLpLYGI_nI6DulM,1971
|
|
89
89
|
utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
90
90
|
utilities/pytest_plugins/pytest_randomly.py,sha256=NXzCcGKbpgYouz5yehKb4jmxmi2SexKKpgF4M65bi10,414
|
91
91
|
utilities/pytest_plugins/pytest_regressions.py,sha256=Iwhfv_OJH7UCPZCfoh7ugZ2Xjqjil-BBBsOb8sDwiGI,1471
|
92
|
-
dycw_utilities-0.
|
93
|
-
dycw_utilities-0.
|
94
|
-
dycw_utilities-0.
|
95
|
-
dycw_utilities-0.
|
96
|
-
dycw_utilities-0.
|
92
|
+
dycw_utilities-0.151.1.dist-info/METADATA,sha256=Ooil0Z8qgBzFL5vPNHUBYeOBu0IY_K6DKtX1is2oQ08,1696
|
93
|
+
dycw_utilities-0.151.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
94
|
+
dycw_utilities-0.151.1.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
95
|
+
dycw_utilities-0.151.1.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
96
|
+
dycw_utilities-0.151.1.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/hypothesis.py
CHANGED
@@ -56,12 +56,16 @@ from utilities.math import (
|
|
56
56
|
MAX_FLOAT64,
|
57
57
|
MAX_INT32,
|
58
58
|
MAX_INT64,
|
59
|
+
MAX_UINT8,
|
60
|
+
MAX_UINT16,
|
59
61
|
MAX_UINT32,
|
60
62
|
MAX_UINT64,
|
61
63
|
MIN_FLOAT32,
|
62
64
|
MIN_FLOAT64,
|
63
65
|
MIN_INT32,
|
64
66
|
MIN_INT64,
|
67
|
+
MIN_UINT8,
|
68
|
+
MIN_UINT16,
|
65
69
|
MIN_UINT32,
|
66
70
|
MIN_UINT64,
|
67
71
|
is_zero,
|
@@ -836,7 +840,7 @@ def random_states(
|
|
836
840
|
"""Strategy for generating `numpy` random states."""
|
837
841
|
from numpy.random import RandomState
|
838
842
|
|
839
|
-
seed_ = draw2(draw, seed,
|
843
|
+
seed_ = draw2(draw, seed, uint32s())
|
840
844
|
return RandomState(seed=seed_)
|
841
845
|
|
842
846
|
|
@@ -1226,6 +1230,36 @@ def _triples_map[T](elements: list[T], /) -> tuple[T, T, T]:
|
|
1226
1230
|
##
|
1227
1231
|
|
1228
1232
|
|
1233
|
+
@composite
|
1234
|
+
def uint8s(
|
1235
|
+
draw: DrawFn,
|
1236
|
+
/,
|
1237
|
+
*,
|
1238
|
+
min_value: MaybeSearchStrategy[int] = MIN_UINT8,
|
1239
|
+
max_value: MaybeSearchStrategy[int] = MAX_UINT8,
|
1240
|
+
) -> int:
|
1241
|
+
"""Strategy for generating uint8s."""
|
1242
|
+
min_value_, max_value_ = [draw2(draw, v) for v in [min_value, max_value]]
|
1243
|
+
min_value_ = max(min_value_, MIN_UINT8)
|
1244
|
+
max_value_ = min(max_value_, MAX_UINT8)
|
1245
|
+
return draw(integers(min_value=min_value_, max_value=max_value_))
|
1246
|
+
|
1247
|
+
|
1248
|
+
@composite
|
1249
|
+
def uint16s(
|
1250
|
+
draw: DrawFn,
|
1251
|
+
/,
|
1252
|
+
*,
|
1253
|
+
min_value: MaybeSearchStrategy[int] = MIN_UINT16,
|
1254
|
+
max_value: MaybeSearchStrategy[int] = MAX_UINT16,
|
1255
|
+
) -> int:
|
1256
|
+
"""Strategy for generating uint16s."""
|
1257
|
+
min_value_, max_value_ = [draw2(draw, v) for v in [min_value, max_value]]
|
1258
|
+
min_value_ = max(min_value_, MIN_UINT16)
|
1259
|
+
max_value_ = min(max_value_, MAX_UINT16)
|
1260
|
+
return draw(integers(min_value=min_value_, max_value=max_value_))
|
1261
|
+
|
1262
|
+
|
1229
1263
|
@composite
|
1230
1264
|
def uint32s(
|
1231
1265
|
draw: DrawFn,
|
@@ -1426,6 +1460,8 @@ __all__ = [
|
|
1426
1460
|
"time_deltas",
|
1427
1461
|
"times",
|
1428
1462
|
"triples",
|
1463
|
+
"uint8s",
|
1464
|
+
"uint16s",
|
1429
1465
|
"uint32s",
|
1430
1466
|
"uint64s",
|
1431
1467
|
"urls",
|
utilities/polars.py
CHANGED
@@ -1097,7 +1097,7 @@ def _dataclass_to_schema_datetime(
|
|
1097
1097
|
) -> PolarsDataType:
|
1098
1098
|
if field.value.tzinfo is None:
|
1099
1099
|
return Datetime
|
1100
|
-
return
|
1100
|
+
return zoned_datetime_dtype(time_zone=ensure_time_zone(field.value.tzinfo))
|
1101
1101
|
|
1102
1102
|
|
1103
1103
|
def _dataclass_to_schema_one(
|
@@ -2259,7 +2259,7 @@ def _struct_from_dataclass_one(
|
|
2259
2259
|
if ann is dt.datetime:
|
2260
2260
|
if time_zone is None:
|
2261
2261
|
raise _StructFromDataClassTimeZoneMissingError
|
2262
|
-
return
|
2262
|
+
return zoned_datetime_dtype(time_zone=time_zone)
|
2263
2263
|
if is_dataclass_class(ann):
|
2264
2264
|
return struct_from_dataclass(ann, time_zone=time_zone)
|
2265
2265
|
if (isinstance(ann, type) and issubclass(ann, enum.Enum)) or (
|
@@ -2388,13 +2388,30 @@ def week_num(column: IntoExprColumn, /, *, start: WeekDay = "mon") -> Expr | Ser
|
|
2388
2388
|
##
|
2389
2389
|
|
2390
2390
|
|
2391
|
-
def
|
2391
|
+
def zoned_datetime_dtype(
|
2392
2392
|
*, time_unit: TimeUnit = "us", time_zone: TimeZoneLike = UTC
|
2393
2393
|
) -> Datetime:
|
2394
2394
|
"""Create a zoned datetime data type."""
|
2395
2395
|
return Datetime(time_unit=time_unit, time_zone=get_time_zone_name(time_zone))
|
2396
2396
|
|
2397
2397
|
|
2398
|
+
def zoned_datetime_period_dtype(
|
2399
|
+
*,
|
2400
|
+
time_unit: TimeUnit = "us",
|
2401
|
+
time_zone: TimeZoneLike | tuple[TimeZoneLike, TimeZoneLike] = UTC,
|
2402
|
+
) -> Struct:
|
2403
|
+
"""Create a zoned datetime period data type."""
|
2404
|
+
match time_zone:
|
2405
|
+
case start, end:
|
2406
|
+
return struct_dtype(
|
2407
|
+
start=zoned_datetime_dtype(time_unit=time_unit, time_zone=start),
|
2408
|
+
end=zoned_datetime_dtype(time_unit=time_unit, time_zone=end),
|
2409
|
+
)
|
2410
|
+
case _:
|
2411
|
+
dtype = zoned_datetime_dtype(time_unit=time_unit, time_zone=time_zone)
|
2412
|
+
return struct_dtype(start=dtype, end=dtype)
|
2413
|
+
|
2414
|
+
|
2398
2415
|
__all__ = [
|
2399
2416
|
"BooleanValueCountsError",
|
2400
2417
|
"CheckPolarsDataFrameError",
|
@@ -2470,5 +2487,6 @@ __all__ = [
|
|
2470
2487
|
"unique_element",
|
2471
2488
|
"write_dataframe",
|
2472
2489
|
"write_series",
|
2473
|
-
"
|
2490
|
+
"zoned_datetime_dtype",
|
2491
|
+
"zoned_datetime_period_dtype",
|
2474
2492
|
]
|
utilities/sqlalchemy_polars.py
CHANGED
@@ -35,7 +35,7 @@ from utilities.iterables import (
|
|
35
35
|
chunked,
|
36
36
|
one,
|
37
37
|
)
|
38
|
-
from utilities.polars import
|
38
|
+
from utilities.polars import zoned_datetime_dtype
|
39
39
|
from utilities.reprlib import get_repr
|
40
40
|
from utilities.sqlalchemy import (
|
41
41
|
CHUNK_SIZE_FRAC,
|
@@ -390,7 +390,7 @@ def _select_to_dataframe_map_table_column_type_to_dtype(
|
|
390
390
|
return pl.Date
|
391
391
|
if is_subclass_gen(py_type, dt.datetime):
|
392
392
|
has_tz: bool = type_use.timezone
|
393
|
-
return
|
393
|
+
return zoned_datetime_dtype(time_zone=time_zone) if has_tz else Datetime()
|
394
394
|
if issubclass(py_type, dt.time):
|
395
395
|
return Time
|
396
396
|
if issubclass(py_type, dt.timedelta):
|
File without changes
|
File without changes
|
File without changes
|