pixeltable 0.3.1__py3-none-any.whl → 0.3.3__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.

Potentially problematic release.


This version of pixeltable might be problematic. Click here for more details.

Files changed (147) hide show
  1. pixeltable/__init__.py +64 -11
  2. pixeltable/__version__.py +2 -2
  3. pixeltable/catalog/__init__.py +1 -1
  4. pixeltable/catalog/catalog.py +50 -27
  5. pixeltable/catalog/column.py +27 -11
  6. pixeltable/catalog/dir.py +6 -4
  7. pixeltable/catalog/globals.py +8 -1
  8. pixeltable/catalog/insertable_table.py +25 -15
  9. pixeltable/catalog/named_function.py +10 -6
  10. pixeltable/catalog/path.py +3 -2
  11. pixeltable/catalog/path_dict.py +8 -6
  12. pixeltable/catalog/schema_object.py +2 -1
  13. pixeltable/catalog/table.py +123 -103
  14. pixeltable/catalog/table_version.py +292 -143
  15. pixeltable/catalog/table_version_path.py +8 -5
  16. pixeltable/catalog/view.py +68 -27
  17. pixeltable/dataframe.py +102 -72
  18. pixeltable/env.py +39 -23
  19. pixeltable/exec/__init__.py +2 -2
  20. pixeltable/exec/aggregation_node.py +10 -4
  21. pixeltable/exec/cache_prefetch_node.py +5 -3
  22. pixeltable/exec/component_iteration_node.py +9 -8
  23. pixeltable/exec/data_row_batch.py +21 -10
  24. pixeltable/exec/exec_context.py +10 -3
  25. pixeltable/exec/exec_node.py +23 -12
  26. pixeltable/exec/expr_eval/evaluators.py +18 -17
  27. pixeltable/exec/expr_eval/expr_eval_node.py +29 -16
  28. pixeltable/exec/expr_eval/globals.py +33 -11
  29. pixeltable/exec/expr_eval/row_buffer.py +5 -6
  30. pixeltable/exec/expr_eval/schedulers.py +170 -42
  31. pixeltable/exec/in_memory_data_node.py +8 -7
  32. pixeltable/exec/row_update_node.py +15 -5
  33. pixeltable/exec/sql_node.py +56 -27
  34. pixeltable/exprs/__init__.py +2 -2
  35. pixeltable/exprs/arithmetic_expr.py +57 -26
  36. pixeltable/exprs/array_slice.py +1 -1
  37. pixeltable/exprs/column_property_ref.py +2 -1
  38. pixeltable/exprs/column_ref.py +20 -15
  39. pixeltable/exprs/comparison.py +6 -2
  40. pixeltable/exprs/compound_predicate.py +1 -3
  41. pixeltable/exprs/data_row.py +2 -2
  42. pixeltable/exprs/expr.py +101 -72
  43. pixeltable/exprs/expr_dict.py +2 -1
  44. pixeltable/exprs/expr_set.py +3 -1
  45. pixeltable/exprs/function_call.py +39 -41
  46. pixeltable/exprs/globals.py +1 -0
  47. pixeltable/exprs/in_predicate.py +2 -2
  48. pixeltable/exprs/inline_expr.py +20 -17
  49. pixeltable/exprs/json_mapper.py +4 -2
  50. pixeltable/exprs/json_path.py +12 -18
  51. pixeltable/exprs/literal.py +5 -9
  52. pixeltable/exprs/method_ref.py +1 -0
  53. pixeltable/exprs/object_ref.py +1 -1
  54. pixeltable/exprs/row_builder.py +31 -16
  55. pixeltable/exprs/rowid_ref.py +14 -5
  56. pixeltable/exprs/similarity_expr.py +11 -6
  57. pixeltable/exprs/sql_element_cache.py +1 -1
  58. pixeltable/exprs/type_cast.py +24 -9
  59. pixeltable/ext/__init__.py +1 -0
  60. pixeltable/ext/functions/__init__.py +1 -0
  61. pixeltable/ext/functions/whisperx.py +2 -2
  62. pixeltable/ext/functions/yolox.py +11 -11
  63. pixeltable/func/aggregate_function.py +17 -13
  64. pixeltable/func/callable_function.py +6 -6
  65. pixeltable/func/expr_template_function.py +15 -14
  66. pixeltable/func/function.py +16 -16
  67. pixeltable/func/function_registry.py +11 -8
  68. pixeltable/func/globals.py +4 -2
  69. pixeltable/func/query_template_function.py +12 -13
  70. pixeltable/func/signature.py +18 -9
  71. pixeltable/func/tools.py +10 -17
  72. pixeltable/func/udf.py +106 -11
  73. pixeltable/functions/__init__.py +21 -2
  74. pixeltable/functions/anthropic.py +21 -15
  75. pixeltable/functions/fireworks.py +63 -5
  76. pixeltable/functions/gemini.py +13 -3
  77. pixeltable/functions/globals.py +18 -6
  78. pixeltable/functions/huggingface.py +20 -38
  79. pixeltable/functions/image.py +7 -3
  80. pixeltable/functions/json.py +1 -0
  81. pixeltable/functions/llama_cpp.py +1 -4
  82. pixeltable/functions/mistralai.py +31 -20
  83. pixeltable/functions/ollama.py +4 -18
  84. pixeltable/functions/openai.py +214 -109
  85. pixeltable/functions/replicate.py +11 -10
  86. pixeltable/functions/string.py +70 -7
  87. pixeltable/functions/timestamp.py +21 -8
  88. pixeltable/functions/together.py +66 -52
  89. pixeltable/functions/video.py +1 -0
  90. pixeltable/functions/vision.py +14 -11
  91. pixeltable/functions/whisper.py +2 -1
  92. pixeltable/globals.py +61 -28
  93. pixeltable/index/__init__.py +1 -1
  94. pixeltable/index/btree.py +5 -3
  95. pixeltable/index/embedding_index.py +15 -14
  96. pixeltable/io/__init__.py +1 -1
  97. pixeltable/io/external_store.py +30 -25
  98. pixeltable/io/fiftyone.py +6 -14
  99. pixeltable/io/globals.py +33 -27
  100. pixeltable/io/hf_datasets.py +3 -2
  101. pixeltable/io/label_studio.py +80 -71
  102. pixeltable/io/pandas.py +33 -9
  103. pixeltable/io/parquet.py +10 -13
  104. pixeltable/iterators/__init__.py +1 -0
  105. pixeltable/iterators/audio.py +205 -0
  106. pixeltable/iterators/document.py +19 -8
  107. pixeltable/iterators/image.py +6 -24
  108. pixeltable/iterators/string.py +3 -6
  109. pixeltable/iterators/video.py +1 -7
  110. pixeltable/metadata/__init__.py +9 -2
  111. pixeltable/metadata/converters/convert_10.py +2 -2
  112. pixeltable/metadata/converters/convert_15.py +1 -5
  113. pixeltable/metadata/converters/convert_16.py +2 -4
  114. pixeltable/metadata/converters/convert_17.py +2 -4
  115. pixeltable/metadata/converters/convert_18.py +2 -4
  116. pixeltable/metadata/converters/convert_19.py +2 -5
  117. pixeltable/metadata/converters/convert_20.py +1 -4
  118. pixeltable/metadata/converters/convert_21.py +4 -6
  119. pixeltable/metadata/converters/convert_22.py +1 -0
  120. pixeltable/metadata/converters/convert_23.py +5 -5
  121. pixeltable/metadata/converters/convert_24.py +12 -13
  122. pixeltable/metadata/converters/convert_26.py +23 -0
  123. pixeltable/metadata/converters/util.py +3 -4
  124. pixeltable/metadata/notes.py +1 -0
  125. pixeltable/metadata/schema.py +13 -2
  126. pixeltable/plan.py +173 -98
  127. pixeltable/store.py +42 -26
  128. pixeltable/type_system.py +130 -85
  129. pixeltable/utils/arrow.py +1 -7
  130. pixeltable/utils/coco.py +16 -17
  131. pixeltable/utils/code.py +1 -1
  132. pixeltable/utils/console_output.py +44 -0
  133. pixeltable/utils/description_helper.py +7 -7
  134. pixeltable/utils/documents.py +3 -1
  135. pixeltable/utils/filecache.py +13 -8
  136. pixeltable/utils/http_server.py +9 -8
  137. pixeltable/utils/media_store.py +2 -1
  138. pixeltable/utils/pytorch.py +11 -14
  139. pixeltable/utils/s3.py +1 -0
  140. pixeltable/utils/sql.py +1 -0
  141. pixeltable/utils/transactional_directory.py +2 -2
  142. {pixeltable-0.3.1.dist-info → pixeltable-0.3.3.dist-info}/METADATA +7 -8
  143. pixeltable-0.3.3.dist-info/RECORD +163 -0
  144. pixeltable-0.3.1.dist-info/RECORD +0 -160
  145. {pixeltable-0.3.1.dist-info → pixeltable-0.3.3.dist-info}/LICENSE +0 -0
  146. {pixeltable-0.3.1.dist-info → pixeltable-0.3.3.dist-info}/WHEEL +0 -0
  147. {pixeltable-0.3.1.dist-info → pixeltable-0.3.3.dist-info}/entry_points.txt +0 -0
@@ -18,6 +18,7 @@ if TYPE_CHECKING:
18
18
  @register_client('replicate')
19
19
  def _(api_token: str) -> 'replicate.Client':
20
20
  import replicate
21
+
21
22
  return replicate.Client(api_token=api_token)
22
23
 
23
24
 
@@ -25,17 +26,17 @@ def _replicate_client() -> 'replicate.Client':
25
26
  return Env.get().get_client('replicate')
26
27
 
27
28
 
28
- @pxt.udf
29
- def run(
30
- input: dict[str, Any],
31
- *,
32
- ref: str,
33
- ) -> dict[str, Any]:
29
+ @pxt.udf(resource_pool='request-rate:replicate')
30
+ async def run(input: dict[str, Any], *, ref: str) -> dict[str, Any]:
34
31
  """
35
32
  Run a model on Replicate.
36
33
 
37
34
  For additional details, see: <https://replicate.com/docs/topics/models/run-a-model>
38
35
 
36
+ Request throttling:
37
+ Applies the rate limit set in the config (section `replicate`, key `rate_limit`). If no rate
38
+ limit is configured, uses a default of 600 RPM.
39
+
39
40
  __Requirements:__
40
41
 
41
42
  - `pip install replicate`
@@ -52,17 +53,17 @@ def run(
52
53
  to an existing Pixeltable column `tbl.prompt` of the table `tbl`:
53
54
 
54
55
  >>> input = {'system_prompt': 'You are a helpful assistant.', 'prompt': tbl.prompt}
55
- ... tbl['response'] = run(input, ref='meta/meta-llama-3-8b-instruct')
56
+ ... tbl.add_computed_column(response=run(input, ref='meta/meta-llama-3-8b-instruct'))
56
57
 
57
58
  Add a computed column that uses the model `black-forest-labs/flux-schnell`
58
59
  to generate images from an existing Pixeltable column `tbl.prompt`:
59
60
 
60
61
  >>> input = {'prompt': tbl.prompt, 'go_fast': True, 'megapixels': '1'}
61
- ... tbl['response'] = run(input, ref='black-forest-labs/flux-schnell')
62
- ... tbl['image'] = tbl.response.output[0].astype(pxt.Image)
62
+ ... tbl.add_computed_column(response=run(input, ref='black-forest-labs/flux-schnell'))
63
+ ... tbl.add_computed_column(image=tbl.response.output[0].astype(pxt.Image))
63
64
  """
64
65
  Env.get().require_package('replicate')
65
- return _replicate_client().run(ref, input, use_file_output=False)
66
+ return await _replicate_client().async_run(ref, input, use_file_output=False)
66
67
 
67
68
 
68
69
  __all__ = local_public_names(__name__)
@@ -28,6 +28,7 @@ def capitalize(self: str) -> str:
28
28
  """
29
29
  return self.capitalize()
30
30
 
31
+
31
32
  @pxt.udf(is_method=True)
32
33
  def casefold(self: str) -> str:
33
34
  """
@@ -37,6 +38,7 @@ def casefold(self: str) -> str:
37
38
  """
38
39
  return self.casefold()
39
40
 
41
+
40
42
  @pxt.udf(is_method=True)
41
43
  def center(self: str, width: int, fillchar: str = ' ') -> str:
42
44
  """
@@ -50,6 +52,7 @@ def center(self: str, width: int, fillchar: str = ' ') -> str:
50
52
  """
51
53
  return self.center(width, fillchar)
52
54
 
55
+
53
56
  @pxt.udf(is_method=True)
54
57
  def contains(self: str, pattern: str, case: bool = True, flags: int = 0, regex: bool = True) -> bool:
55
58
  """
@@ -63,6 +66,7 @@ def contains(self: str, pattern: str, case: bool = True, flags: int = 0, regex:
63
66
  """
64
67
  if regex:
65
68
  import re
69
+
66
70
  if not case:
67
71
  flags |= re.IGNORECASE
68
72
  return bool(re.search(pattern, self, flags))
@@ -72,6 +76,7 @@ def contains(self: str, pattern: str, case: bool = True, flags: int = 0, regex:
72
76
  else:
73
77
  return pattern.lower() in self.lower()
74
78
 
79
+
75
80
  @pxt.udf(is_method=True)
76
81
  def count(self: str, pattern: str, flags: int = 0) -> int:
77
82
  """
@@ -83,8 +88,10 @@ def count(self: str, pattern: str, flags: int = 0) -> int:
83
88
  """
84
89
  import re
85
90
  from builtins import len
91
+
86
92
  return len(re.findall(pattern, self, flags))
87
93
 
94
+
88
95
  @pxt.udf(is_method=True)
89
96
  def endswith(self: str, pattern: str) -> bool:
90
97
  """
@@ -97,6 +104,7 @@ def endswith(self: str, pattern: str) -> bool:
97
104
  """
98
105
  return self.endswith(pattern)
99
106
 
107
+
100
108
  @pxt.udf(is_method=True)
101
109
  def fill(self: str, width: int, **kwargs: Any) -> str:
102
110
  """
@@ -109,8 +117,10 @@ def fill(self: str, width: int, **kwargs: Any) -> str:
109
117
  kwargs: Additional keyword arguments to pass to `textwrap.fill()`.
110
118
  """
111
119
  import textwrap
120
+
112
121
  return textwrap.fill(self, width, **kwargs)
113
122
 
123
+
114
124
  @pxt.udf(is_method=True)
115
125
  def find(self: str, substr: str, start: Optional[int] = 0, end: Optional[int] = None) -> int:
116
126
  """
@@ -125,6 +135,7 @@ def find(self: str, substr: str, start: Optional[int] = 0, end: Optional[int] =
125
135
  """
126
136
  return self.find(substr, start, end)
127
137
 
138
+
128
139
  @pxt.udf(is_method=True)
129
140
  def findall(self: str, pattern: str, flags: int = 0) -> list:
130
141
  """
@@ -137,8 +148,10 @@ def findall(self: str, pattern: str, flags: int = 0) -> list:
137
148
  flags: [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module
138
149
  """
139
150
  import re
151
+
140
152
  return re.findall(pattern, self, flags)
141
153
 
154
+
142
155
  @pxt.udf(is_method=True)
143
156
  def format(self: str, *args: Any, **kwargs: Any) -> str:
144
157
  """
@@ -148,6 +161,7 @@ def format(self: str, *args: Any, **kwargs: Any) -> str:
148
161
  """
149
162
  return self.format(*args, **kwargs)
150
163
 
164
+
151
165
  @pxt.udf(is_method=True)
152
166
  def fullmatch(self: str, pattern: str, case: bool = True, flags: int = 0) -> bool:
153
167
  """
@@ -161,11 +175,13 @@ def fullmatch(self: str, pattern: str, case: bool = True, flags: int = 0) -> boo
161
175
  flags: [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module
162
176
  """
163
177
  import re
178
+
164
179
  if not case:
165
180
  flags |= re.IGNORECASE
166
181
  _ = bool(re.fullmatch(pattern, self, flags))
167
182
  return bool(re.fullmatch(pattern, self, flags))
168
183
 
184
+
169
185
  @pxt.udf(is_method=True)
170
186
  def index(self: str, substr: str, start: Optional[int] = 0, end: Optional[int] = None) -> int:
171
187
  """
@@ -181,6 +197,7 @@ def index(self: str, substr: str, start: Optional[int] = 0, end: Optional[int] =
181
197
  """
182
198
  return self.index(substr, start, end)
183
199
 
200
+
184
201
  @pxt.udf(is_method=True)
185
202
  def isalnum(self: str) -> bool:
186
203
  """
@@ -191,6 +208,7 @@ def isalnum(self: str) -> bool:
191
208
  """
192
209
  return self.isalnum()
193
210
 
211
+
194
212
  @pxt.udf(is_method=True)
195
213
  def isalpha(self: str) -> bool:
196
214
  """
@@ -200,6 +218,7 @@ def isalpha(self: str) -> bool:
200
218
  """
201
219
  return self.isalpha()
202
220
 
221
+
203
222
  @pxt.udf(is_method=True)
204
223
  def isascii(self: str) -> bool:
205
224
  """
@@ -209,6 +228,7 @@ def isascii(self: str) -> bool:
209
228
  """
210
229
  return self.isascii()
211
230
 
231
+
212
232
  @pxt.udf(is_method=True)
213
233
  def isdecimal(self: str) -> bool:
214
234
  """
@@ -219,6 +239,7 @@ def isdecimal(self: str) -> bool:
219
239
  """
220
240
  return self.isdecimal()
221
241
 
242
+
222
243
  @pxt.udf(is_method=True)
223
244
  def isdigit(self: str) -> bool:
224
245
  """
@@ -228,6 +249,7 @@ def isdigit(self: str) -> bool:
228
249
  """
229
250
  return self.isdigit()
230
251
 
252
+
231
253
  @pxt.udf(is_method=True)
232
254
  def isidentifier(self: str) -> bool:
233
255
  """
@@ -247,6 +269,7 @@ def islower(self: str) -> bool:
247
269
  """
248
270
  return self.islower()
249
271
 
272
+
250
273
  @pxt.udf(is_method=True)
251
274
  def isnumeric(self: str) -> bool:
252
275
  """
@@ -256,6 +279,7 @@ def isnumeric(self: str) -> bool:
256
279
  """
257
280
  return self.isnumeric()
258
281
 
282
+
259
283
  @pxt.udf(is_method=True)
260
284
  def isupper(self: str) -> bool:
261
285
  """
@@ -265,6 +289,7 @@ def isupper(self: str) -> bool:
265
289
  """
266
290
  return self.isupper()
267
291
 
292
+
268
293
  @pxt.udf(is_method=True)
269
294
  def istitle(self: str) -> bool:
270
295
  """
@@ -274,6 +299,7 @@ def istitle(self: str) -> bool:
274
299
  """
275
300
  return self.istitle()
276
301
 
302
+
277
303
  @pxt.udf(is_method=True)
278
304
  def isspace(self: str) -> bool:
279
305
  """
@@ -283,6 +309,7 @@ def isspace(self: str) -> bool:
283
309
  """
284
310
  return self.isspace()
285
311
 
312
+
286
313
  @pxt.udf
287
314
  def join(sep: str, elements: list) -> str:
288
315
  """
@@ -292,6 +319,7 @@ def join(sep: str, elements: list) -> str:
292
319
  """
293
320
  return sep.join(elements)
294
321
 
322
+
295
323
  @pxt.udf(is_method=True)
296
324
  def len(self: str) -> int:
297
325
  """
@@ -301,6 +329,7 @@ def len(self: str) -> int:
301
329
  """
302
330
  return self.__len__()
303
331
 
332
+
304
333
  @pxt.udf(is_method=True)
305
334
  def ljust(self: str, width: int, fillchar: str = ' ') -> str:
306
335
  """
@@ -314,6 +343,7 @@ def ljust(self: str, width: int, fillchar: str = ' ') -> str:
314
343
  """
315
344
  return self.ljust(width, fillchar)
316
345
 
346
+
317
347
  @pxt.udf(is_method=True)
318
348
  def lower(self: str) -> str:
319
349
  """
@@ -323,6 +353,7 @@ def lower(self: str) -> str:
323
353
  """
324
354
  return self.lower()
325
355
 
356
+
326
357
  @pxt.udf(is_method=True)
327
358
  def lstrip(self: str, chars: Optional[str] = None) -> str:
328
359
  """
@@ -336,6 +367,7 @@ def lstrip(self: str, chars: Optional[str] = None) -> str:
336
367
  """
337
368
  return self.lstrip(chars)
338
369
 
370
+
339
371
  @pxt.udf(is_method=True)
340
372
  def match(self: str, pattern: str, case: bool = True, flags: int = 0) -> bool:
341
373
  """
@@ -347,10 +379,12 @@ def match(self: str, pattern: str, case: bool = True, flags: int = 0) -> bool:
347
379
  flags: [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module
348
380
  """
349
381
  import re
382
+
350
383
  if not case:
351
384
  flags |= re.IGNORECASE
352
385
  return bool(re.match(pattern, self, flags))
353
386
 
387
+
354
388
  @pxt.udf(is_method=True)
355
389
  def normalize(self: str, form: str) -> str:
356
390
  """
@@ -362,8 +396,10 @@ def normalize(self: str, form: str) -> str:
362
396
  form: Unicode normal form (`‘NFC’`, `‘NFKC’`, `‘NFD’`, `‘NFKD’`)
363
397
  """
364
398
  import unicodedata
399
+
365
400
  return unicodedata.normalize(form, self) # type: ignore[arg-type]
366
401
 
402
+
367
403
  @pxt.udf(is_method=True)
368
404
  def pad(self: str, width: int, side: str = 'left', fillchar: str = ' ') -> str:
369
405
  """
@@ -381,7 +417,8 @@ def pad(self: str, width: int, side: str = 'left', fillchar: str = ' ') -> str:
381
417
  elif side == 'both':
382
418
  return self.center(width, fillchar)
383
419
  else:
384
- raise ValueError(f"Invalid side: {side}")
420
+ raise ValueError(f'Invalid side: {side}')
421
+
385
422
 
386
423
  @pxt.udf(is_method=True)
387
424
  def partition(self: str, sep: str = ' ') -> list:
@@ -394,7 +431,9 @@ def partition(self: str, sep: str = ' ') -> list:
394
431
  if idx == -1:
395
432
  return [self, '', '']
396
433
  from builtins import len
397
- return [self[:idx], sep, self[idx + len(sep):]]
434
+
435
+ return [self[:idx], sep, self[idx + len(sep) :]]
436
+
398
437
 
399
438
  @pxt.udf(is_method=True)
400
439
  def removeprefix(self: str, prefix: str) -> str:
@@ -404,9 +443,11 @@ def removeprefix(self: str, prefix: str) -> str:
404
443
  if self.startswith(prefix):
405
444
  # we need to avoid referring to our symbol 'len'
406
445
  from builtins import len
407
- return self[len(prefix):]
446
+
447
+ return self[len(prefix) :]
408
448
  return self
409
449
 
450
+
410
451
  @pxt.udf(is_method=True)
411
452
  def removesuffix(self: str, suffix: str) -> str:
412
453
  """
@@ -415,9 +456,11 @@ def removesuffix(self: str, suffix: str) -> str:
415
456
  if self.endswith(suffix):
416
457
  # we need to avoid referring to our symbol 'len'
417
458
  from builtins import len
418
- return self[:-len(suffix)]
459
+
460
+ return self[: -len(suffix)]
419
461
  return self
420
462
 
463
+
421
464
  @pxt.udf(is_method=True)
422
465
  def repeat(self: str, n: int) -> str:
423
466
  """
@@ -425,9 +468,10 @@ def repeat(self: str, n: int) -> str:
425
468
  """
426
469
  return self * n
427
470
 
471
+
428
472
  @pxt.udf(is_method=True)
429
473
  def replace(
430
- self: str, pattern: str, repl: str, n: int = -1, case: bool = True, flags: int = 0, regex: bool = False
474
+ self: str, pattern: str, repl: str, n: int = -1, case: bool = True, flags: int = 0, regex: bool = False
431
475
  ) -> str:
432
476
  """
433
477
  Replace occurrences of `pattern` with `repl`.
@@ -445,12 +489,14 @@ def replace(
445
489
  """
446
490
  if regex:
447
491
  import re
492
+
448
493
  if not case:
449
494
  flags |= re.IGNORECASE
450
495
  return re.sub(pattern, repl, self, 0 if n == -1 else n, flags)
451
496
  else:
452
497
  return self.replace(pattern, repl, n)
453
498
 
499
+
454
500
  @pxt.udf(is_method=True)
455
501
  def rfind(self: str, substr: str, start: Optional[int] = 0, end: Optional[int] = None) -> int:
456
502
  """
@@ -465,6 +511,7 @@ def rfind(self: str, substr: str, start: Optional[int] = 0, end: Optional[int] =
465
511
  """
466
512
  return self.rfind(substr, start, end)
467
513
 
514
+
468
515
  @pxt.udf(is_method=True)
469
516
  def rindex(self: str, substr: str, start: Optional[int] = 0, end: Optional[int] = None) -> int:
470
517
  """
@@ -475,6 +522,7 @@ def rindex(self: str, substr: str, start: Optional[int] = 0, end: Optional[int]
475
522
  """
476
523
  return self.rindex(substr, start, end)
477
524
 
525
+
478
526
  @pxt.udf(is_method=True)
479
527
  def rjust(self: str, width: int, fillchar: str = ' ') -> str:
480
528
  """
@@ -488,6 +536,7 @@ def rjust(self: str, width: int, fillchar: str = ' ') -> str:
488
536
  """
489
537
  return self.rjust(width, fillchar)
490
538
 
539
+
491
540
  @pxt.udf(is_method=True)
492
541
  def rpartition(self: str, sep: str = ' ') -> list:
493
542
  """
@@ -498,7 +547,9 @@ def rpartition(self: str, sep: str = ' ') -> list:
498
547
  if idx == -1:
499
548
  return [self, '', '']
500
549
  from builtins import len
501
- return [self[:idx], sep, self[idx + len(sep):]]
550
+
551
+ return [self[:idx], sep, self[idx + len(sep) :]]
552
+
502
553
 
503
554
  @pxt.udf(is_method=True)
504
555
  def rstrip(self: str, chars: Optional[str] = None) -> str:
@@ -512,6 +563,7 @@ def rstrip(self: str, chars: Optional[str] = None) -> str:
512
563
  """
513
564
  return self.rstrip(chars)
514
565
 
566
+
515
567
  @pxt.udf(is_method=True)
516
568
  def slice(self: str, start: Optional[int] = None, stop: Optional[int] = None, step: Optional[int] = None) -> str:
517
569
  """
@@ -524,8 +576,11 @@ def slice(self: str, start: Optional[int] = None, stop: Optional[int] = None, st
524
576
  """
525
577
  return self[start:stop:step]
526
578
 
579
+
527
580
  @pxt.udf(is_method=True)
528
- def slice_replace(self: str, start: Optional[int] = None, stop: Optional[int] = None, repl: Optional[str] = None) -> str:
581
+ def slice_replace(
582
+ self: str, start: Optional[int] = None, stop: Optional[int] = None, repl: Optional[str] = None
583
+ ) -> str:
529
584
  """
530
585
  Replace a positional slice with another value.
531
586
 
@@ -536,6 +591,7 @@ def slice_replace(self: str, start: Optional[int] = None, stop: Optional[int] =
536
591
  """
537
592
  return self[:start] + repl + self[stop:]
538
593
 
594
+
539
595
  @pxt.udf(is_method=True)
540
596
  def startswith(self: str, pattern: str) -> int:
541
597
  """
@@ -548,6 +604,7 @@ def startswith(self: str, pattern: str) -> int:
548
604
  """
549
605
  return self.startswith(pattern)
550
606
 
607
+
551
608
  @pxt.udf(is_method=True)
552
609
  def strip(self: str, chars: Optional[str] = None) -> str:
553
610
  """
@@ -560,6 +617,7 @@ def strip(self: str, chars: Optional[str] = None) -> str:
560
617
  """
561
618
  return self.strip(chars)
562
619
 
620
+
563
621
  @pxt.udf(is_method=True)
564
622
  def swapcase(self: str) -> str:
565
623
  """
@@ -569,6 +627,7 @@ def swapcase(self: str) -> str:
569
627
  """
570
628
  return self.swapcase()
571
629
 
630
+
572
631
  @pxt.udf(is_method=True)
573
632
  def title(self: str) -> str:
574
633
  """
@@ -579,6 +638,7 @@ def title(self: str) -> str:
579
638
  """
580
639
  return self.title()
581
640
 
641
+
582
642
  @pxt.udf(is_method=True)
583
643
  def upper(self: str) -> str:
584
644
  """
@@ -588,6 +648,7 @@ def upper(self: str) -> str:
588
648
  """
589
649
  return self.upper()
590
650
 
651
+
591
652
  @pxt.udf(is_method=True)
592
653
  def wrap(self: str, width: int, **kwargs: Any) -> list[str]:
593
654
  """
@@ -601,8 +662,10 @@ def wrap(self: str, width: int, **kwargs: Any) -> list[str]:
601
662
  kwargs: Additional keyword arguments to pass to `textwrap.fill()`.
602
663
  """
603
664
  import textwrap
665
+
604
666
  return textwrap.wrap(self, width, **kwargs)
605
667
 
668
+
606
669
  @pxt.udf(is_method=True)
607
670
  def zfill(self: str, width: int) -> str:
608
671
  """
@@ -135,6 +135,7 @@ def astimezone(self: datetime, tz: str) -> datetime:
135
135
  tz: The time zone to convert to. Must be a valid time zone name from the IANA Time Zone Database.
136
136
  """
137
137
  from zoneinfo import ZoneInfo
138
+
138
139
  tzinfo = ZoneInfo(tz)
139
140
  return self.astimezone(tzinfo)
140
141
 
@@ -210,7 +211,7 @@ def strftime(self: datetime, format: str) -> str:
210
211
 
211
212
  @pxt.udf(is_method=True)
212
213
  def make_timestamp(
213
- year: int, month: int, day: int, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0
214
+ year: int, month: int, day: int, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0
214
215
  ) -> datetime:
215
216
  """
216
217
  Create a timestamp.
@@ -222,9 +223,13 @@ def make_timestamp(
222
223
 
223
224
  @make_timestamp.to_sql
224
225
  def _(
225
- year: sql.ColumnElement, month: sql.ColumnElement, day: sql.ColumnElement,
226
- hour: sql.ColumnElement = sql.literal(0), minute: sql.ColumnElement = sql.literal(0),
227
- second: sql.ColumnElement = sql.literal(0), microsecond: sql.ColumnElement = sql.literal(0)
226
+ year: sql.ColumnElement,
227
+ month: sql.ColumnElement,
228
+ day: sql.ColumnElement,
229
+ hour: sql.ColumnElement = sql.literal(0),
230
+ minute: sql.ColumnElement = sql.literal(0),
231
+ second: sql.ColumnElement = sql.literal(0),
232
+ microsecond: sql.ColumnElement = sql.literal(0),
228
233
  ) -> sql.ColumnElement:
229
234
  return sql.func.make_timestamptz(
230
235
  sql.cast(year, sql.Integer),
@@ -232,7 +237,9 @@ def _(
232
237
  sql.cast(day, sql.Integer),
233
238
  sql.cast(hour, sql.Integer),
234
239
  sql.cast(minute, sql.Integer),
235
- sql.cast(second + microsecond / 1000000.0, sql.Float))
240
+ sql.cast(second + microsecond / 1000000.0, sql.Float),
241
+ )
242
+
236
243
 
237
244
  # @pxt.udf
238
245
  # def date(self: datetime) -> datetime:
@@ -258,9 +265,15 @@ def _(
258
265
 
259
266
  @pxt.udf(is_method=True)
260
267
  def replace(
261
- self: datetime, year: Optional[int] = None, month: Optional[int] = None, day: Optional[int] = None,
262
- hour: Optional[int] = None, minute: Optional[int] = None, second: Optional[int] = None,
263
- microsecond: Optional[int] = None) -> datetime:
268
+ self: datetime,
269
+ year: Optional[int] = None,
270
+ month: Optional[int] = None,
271
+ day: Optional[int] = None,
272
+ hour: Optional[int] = None,
273
+ minute: Optional[int] = None,
274
+ second: Optional[int] = None,
275
+ microsecond: Optional[int] = None,
276
+ ) -> datetime:
264
277
  """
265
278
  Return a datetime with the same attributes, except for those attributes given new values by whichever keyword
266
279
  arguments are specified.