mayutils 1.2.4__tar.gz → 1.2.6__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.
- {mayutils-1.2.4 → mayutils-1.2.6}/PKG-INFO +1 -1
- {mayutils-1.2.4 → mayutils-1.2.6}/pyproject.toml +1 -1
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/objects/datetime.py +168 -112
- {mayutils-1.2.4 → mayutils-1.2.6}/LICENSE +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/README.md +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/core/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/core/constants.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/data/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/data/analysis/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/data/cache/.gitkeep +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/data/live.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/data/local.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/data/queries/.gitkeep +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/data/queries/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/data/queries/examples/.gitkeep +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/data/read.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/environment/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/environment/benchmarking.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/environment/databases.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/environment/filesystem.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/environment/logging.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/environment/memoisation.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/environment/oauth.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/environment/webdrivers.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/export/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/export/images.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/export/pdf.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/export/slides.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/interfaces/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/interfaces/google.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/interfaces/microsoft.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/interfaces/streamlit.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/mathematics/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/mathematics/numba.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/mathematics/numpy.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/objects/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/objects/classes.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/objects/colours.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/objects/dataframes.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/objects/decorators.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/objects/dictionaries.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/objects/functions.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/objects/hashing.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/objects/numbers.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/objects/strings.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/objects/types.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/scripts/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/scripts/clear_cache.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/scripts/versioning.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/testing/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/visualisation/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/visualisation/console.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/visualisation/graphs/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/visualisation/graphs/combine.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/visualisation/graphs/matplotlib/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/visualisation/graphs/matplotlib/template.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/visualisation/graphs/plotly/__init__.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/visualisation/graphs/plotly/charts.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/visualisation/graphs/plotly/templates.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/visualisation/graphs/plotly/traces.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/visualisation/graphs/plotly/utilities.py +0 -0
- {mayutils-1.2.4 → mayutils-1.2.6}/src/mayutils/visualisation/notebook.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
from contextlib import _GeneratorContextManager
|
|
2
3
|
from sqlite3 import register_adapter
|
|
3
|
-
from typing import Any, Optional, Self, Literal
|
|
4
|
+
from typing import Any, Iterator, Optional, Self, Literal, overload
|
|
4
5
|
import datetime as _datetime
|
|
5
6
|
import numpy as np
|
|
6
7
|
from pendulum import (
|
|
@@ -96,6 +97,125 @@ class Timezone(BaseTimezone):
|
|
|
96
97
|
UTC = Timezone(key="UTC")
|
|
97
98
|
|
|
98
99
|
|
|
100
|
+
class Date(BaseDate):
|
|
101
|
+
@classmethod
|
|
102
|
+
def from_base(
|
|
103
|
+
cls,
|
|
104
|
+
base: BaseDate,
|
|
105
|
+
) -> Self:
|
|
106
|
+
return cls(
|
|
107
|
+
year=base.year,
|
|
108
|
+
month=base.month,
|
|
109
|
+
day=base.day,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
@classmethod
|
|
113
|
+
def from_datetime(
|
|
114
|
+
cls,
|
|
115
|
+
date: _datetime.date,
|
|
116
|
+
) -> Self:
|
|
117
|
+
return cls(
|
|
118
|
+
year=date.year,
|
|
119
|
+
month=date.month,
|
|
120
|
+
day=date.day,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
@classmethod
|
|
124
|
+
def parse(
|
|
125
|
+
cls,
|
|
126
|
+
input,
|
|
127
|
+
) -> Self:
|
|
128
|
+
output = parse(input=input)
|
|
129
|
+
|
|
130
|
+
if not isinstance(output, cls):
|
|
131
|
+
raise ValueError("Could not parse to date")
|
|
132
|
+
|
|
133
|
+
return output
|
|
134
|
+
|
|
135
|
+
def to_datetime(
|
|
136
|
+
self,
|
|
137
|
+
tz: str | Timezone = UTC,
|
|
138
|
+
) -> DateTime:
|
|
139
|
+
return DateTime.create(
|
|
140
|
+
year=self.year,
|
|
141
|
+
month=self.month,
|
|
142
|
+
day=self.day,
|
|
143
|
+
hour=0,
|
|
144
|
+
minute=0,
|
|
145
|
+
second=0,
|
|
146
|
+
microsecond=0,
|
|
147
|
+
tz=tz,
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
def to_numpy(
|
|
151
|
+
self,
|
|
152
|
+
) -> np.datetime64:
|
|
153
|
+
return np.datetime64(self)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class Time(BaseTime):
|
|
157
|
+
@classmethod
|
|
158
|
+
def from_base(
|
|
159
|
+
cls,
|
|
160
|
+
base: BaseTime,
|
|
161
|
+
) -> Self:
|
|
162
|
+
return cls(
|
|
163
|
+
hour=base.hour,
|
|
164
|
+
minute=base.minute,
|
|
165
|
+
second=base.second,
|
|
166
|
+
microsecond=base.microsecond,
|
|
167
|
+
tzinfo=base.tzinfo,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
@classmethod
|
|
171
|
+
def from_datetime(
|
|
172
|
+
cls,
|
|
173
|
+
time: _datetime.time,
|
|
174
|
+
tz: str | Timezone | FixedTimezone | _datetime.tzinfo | None = UTC,
|
|
175
|
+
) -> Self:
|
|
176
|
+
return cls.instance(
|
|
177
|
+
t=time,
|
|
178
|
+
tz=tz,
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
@classmethod
|
|
182
|
+
def parse(
|
|
183
|
+
cls,
|
|
184
|
+
input,
|
|
185
|
+
) -> Self:
|
|
186
|
+
output = parse(input=input)
|
|
187
|
+
|
|
188
|
+
if not isinstance(output, cls):
|
|
189
|
+
raise ValueError("Could not parse to time")
|
|
190
|
+
|
|
191
|
+
return output
|
|
192
|
+
|
|
193
|
+
def today(
|
|
194
|
+
self,
|
|
195
|
+
) -> DateTime:
|
|
196
|
+
return DateTime.now(tz=self.tzinfo).at(
|
|
197
|
+
hour=self.hour,
|
|
198
|
+
minute=self.minute,
|
|
199
|
+
second=self.second,
|
|
200
|
+
microsecond=self.microsecond,
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
def on(
|
|
204
|
+
self,
|
|
205
|
+
date: Date,
|
|
206
|
+
) -> DateTime:
|
|
207
|
+
return DateTime(
|
|
208
|
+
year=date.year,
|
|
209
|
+
month=date.month,
|
|
210
|
+
day=date.day,
|
|
211
|
+
hour=self.hour,
|
|
212
|
+
minute=self.minute,
|
|
213
|
+
second=self.second,
|
|
214
|
+
microsecond=self.microsecond,
|
|
215
|
+
tzinfo=self.tzinfo,
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
|
|
99
219
|
class DateTime(BaseDateTime):
|
|
100
220
|
@classmethod
|
|
101
221
|
def from_base(
|
|
@@ -277,129 +397,25 @@ class DateTime(BaseDateTime):
|
|
|
277
397
|
microsecond=self.microsecond,
|
|
278
398
|
)
|
|
279
399
|
|
|
280
|
-
def
|
|
281
|
-
|
|
282
|
-
) -> np.datetime64:
|
|
283
|
-
return np.datetime64(self)
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
class Date(BaseDate):
|
|
287
|
-
@classmethod
|
|
288
|
-
def from_base(
|
|
289
|
-
cls,
|
|
290
|
-
base: BaseDate,
|
|
291
|
-
) -> Self:
|
|
292
|
-
return cls(
|
|
293
|
-
year=base.year,
|
|
294
|
-
month=base.month,
|
|
295
|
-
day=base.day,
|
|
296
|
-
)
|
|
297
|
-
|
|
298
|
-
@classmethod
|
|
299
|
-
def from_datetime(
|
|
300
|
-
cls,
|
|
301
|
-
date: _datetime.date,
|
|
302
|
-
) -> Self:
|
|
303
|
-
return cls(
|
|
304
|
-
year=date.year,
|
|
305
|
-
month=date.month,
|
|
306
|
-
day=date.day,
|
|
307
|
-
)
|
|
308
|
-
|
|
309
|
-
@classmethod
|
|
310
|
-
def parse(
|
|
311
|
-
cls,
|
|
312
|
-
input,
|
|
313
|
-
) -> Self:
|
|
314
|
-
output = parse(input=input)
|
|
315
|
-
|
|
316
|
-
if not isinstance(output, cls):
|
|
317
|
-
raise ValueError("Could not parse to date")
|
|
318
|
-
|
|
319
|
-
return output
|
|
320
|
-
|
|
321
|
-
def to_datetime(
|
|
322
|
-
self,
|
|
323
|
-
tz: str | Timezone = UTC,
|
|
324
|
-
) -> DateTime:
|
|
325
|
-
return DateTime.create(
|
|
400
|
+
def date(self) -> Date:
|
|
401
|
+
return Date(
|
|
326
402
|
year=self.year,
|
|
327
403
|
month=self.month,
|
|
328
404
|
day=self.day,
|
|
329
|
-
hour=0,
|
|
330
|
-
minute=0,
|
|
331
|
-
second=0,
|
|
332
|
-
microsecond=0,
|
|
333
|
-
tz=tz,
|
|
334
405
|
)
|
|
335
406
|
|
|
336
|
-
def
|
|
337
|
-
|
|
338
|
-
) -> np.datetime64:
|
|
339
|
-
return np.datetime64(self)
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
class Time(BaseTime):
|
|
343
|
-
@classmethod
|
|
344
|
-
def from_base(
|
|
345
|
-
cls,
|
|
346
|
-
base: BaseTime,
|
|
347
|
-
) -> Self:
|
|
348
|
-
return cls(
|
|
349
|
-
hour=base.hour,
|
|
350
|
-
minute=base.minute,
|
|
351
|
-
second=base.second,
|
|
352
|
-
microsecond=base.microsecond,
|
|
353
|
-
tzinfo=base.tzinfo,
|
|
354
|
-
)
|
|
355
|
-
|
|
356
|
-
@classmethod
|
|
357
|
-
def from_datetime(
|
|
358
|
-
cls,
|
|
359
|
-
time: _datetime.time,
|
|
360
|
-
tz: str | Timezone | FixedTimezone | _datetime.tzinfo | None = UTC,
|
|
361
|
-
) -> Self:
|
|
362
|
-
return cls.instance(
|
|
363
|
-
t=time,
|
|
364
|
-
tz=tz,
|
|
365
|
-
)
|
|
366
|
-
|
|
367
|
-
@classmethod
|
|
368
|
-
def parse(
|
|
369
|
-
cls,
|
|
370
|
-
input,
|
|
371
|
-
) -> Self:
|
|
372
|
-
output = parse(input=input)
|
|
373
|
-
|
|
374
|
-
if not isinstance(output, cls):
|
|
375
|
-
raise ValueError("Could not parse to time")
|
|
376
|
-
|
|
377
|
-
return output
|
|
378
|
-
|
|
379
|
-
def today(
|
|
380
|
-
self,
|
|
381
|
-
) -> DateTime:
|
|
382
|
-
return DateTime.now(tz=self.tzinfo).at(
|
|
407
|
+
def time(self) -> Time:
|
|
408
|
+
return Time(
|
|
383
409
|
hour=self.hour,
|
|
384
410
|
minute=self.minute,
|
|
385
411
|
second=self.second,
|
|
386
412
|
microsecond=self.microsecond,
|
|
387
413
|
)
|
|
388
414
|
|
|
389
|
-
def
|
|
415
|
+
def to_numpy(
|
|
390
416
|
self,
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
return DateTime(
|
|
394
|
-
year=date.year,
|
|
395
|
-
month=date.month,
|
|
396
|
-
day=date.day,
|
|
397
|
-
hour=self.hour,
|
|
398
|
-
minute=self.minute,
|
|
399
|
-
second=self.second,
|
|
400
|
-
microsecond=self.microsecond,
|
|
401
|
-
tzinfo=self.tzinfo,
|
|
402
|
-
)
|
|
417
|
+
) -> np.datetime64:
|
|
418
|
+
return np.datetime64(self)
|
|
403
419
|
|
|
404
420
|
|
|
405
421
|
# TODO: NewInterval for working with pandas? nah add to pandas accessor? Or maybe to convert to pandas indexable thing
|
|
@@ -499,6 +515,46 @@ class Intervals(object):
|
|
|
499
515
|
|
|
500
516
|
return self
|
|
501
517
|
|
|
518
|
+
def __repr__(
|
|
519
|
+
self,
|
|
520
|
+
) -> str:
|
|
521
|
+
return f"Intervals(\n\t{'\n\t'.join([repr(interval) for interval in self.intervals])}\n)"
|
|
522
|
+
|
|
523
|
+
def __iter__(
|
|
524
|
+
self,
|
|
525
|
+
) -> Iterator[Interval]:
|
|
526
|
+
return iter(self.intervals)
|
|
527
|
+
|
|
528
|
+
def __len__(
|
|
529
|
+
self,
|
|
530
|
+
) -> int:
|
|
531
|
+
return len(self.intervals)
|
|
532
|
+
|
|
533
|
+
@overload
|
|
534
|
+
def __getitem__(
|
|
535
|
+
self,
|
|
536
|
+
key: int,
|
|
537
|
+
) -> Interval: ...
|
|
538
|
+
|
|
539
|
+
@overload
|
|
540
|
+
def __getitem__(
|
|
541
|
+
self,
|
|
542
|
+
key: slice,
|
|
543
|
+
) -> Intervals: ...
|
|
544
|
+
|
|
545
|
+
def __getitem__(
|
|
546
|
+
self,
|
|
547
|
+
key: int | slice,
|
|
548
|
+
) -> Intervals | Interval:
|
|
549
|
+
if isinstance(key, slice):
|
|
550
|
+
return Intervals(*self.intervals[key])
|
|
551
|
+
|
|
552
|
+
elif isinstance(key, int):
|
|
553
|
+
return self.intervals[key]
|
|
554
|
+
|
|
555
|
+
else:
|
|
556
|
+
raise TypeError("Invalid key type")
|
|
557
|
+
|
|
502
558
|
|
|
503
559
|
class Traveller(BaseTraveller):
|
|
504
560
|
def __init__(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|