pixeltable 0.2.13__py3-none-any.whl → 0.2.14__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 (51) hide show
  1. pixeltable/__init__.py +1 -1
  2. pixeltable/__version__.py +2 -2
  3. pixeltable/catalog/column.py +5 -0
  4. pixeltable/catalog/globals.py +8 -0
  5. pixeltable/catalog/table.py +22 -4
  6. pixeltable/catalog/table_version.py +30 -55
  7. pixeltable/catalog/view.py +1 -1
  8. pixeltable/exec/__init__.py +2 -1
  9. pixeltable/exec/row_update_node.py +61 -0
  10. pixeltable/exec/{sql_scan_node.py → sql_node.py} +120 -56
  11. pixeltable/exprs/__init__.py +1 -1
  12. pixeltable/exprs/expr.py +35 -22
  13. pixeltable/exprs/function_call.py +60 -29
  14. pixeltable/exprs/globals.py +2 -0
  15. pixeltable/exprs/inline_array.py +18 -11
  16. pixeltable/exprs/method_ref.py +63 -0
  17. pixeltable/ext/__init__.py +9 -0
  18. pixeltable/ext/functions/__init__.py +8 -0
  19. pixeltable/ext/functions/whisperx.py +45 -5
  20. pixeltable/ext/functions/yolox.py +60 -14
  21. pixeltable/func/callable_function.py +12 -4
  22. pixeltable/func/expr_template_function.py +1 -1
  23. pixeltable/func/function.py +12 -2
  24. pixeltable/func/function_registry.py +24 -9
  25. pixeltable/func/udf.py +32 -4
  26. pixeltable/functions/__init__.py +1 -1
  27. pixeltable/functions/fireworks.py +33 -0
  28. pixeltable/functions/huggingface.py +96 -6
  29. pixeltable/functions/image.py +226 -41
  30. pixeltable/functions/openai.py +214 -0
  31. pixeltable/functions/string.py +195 -218
  32. pixeltable/functions/timestamp.py +210 -0
  33. pixeltable/functions/together.py +106 -0
  34. pixeltable/functions/video.py +2 -2
  35. pixeltable/functions/whisper.py +32 -0
  36. pixeltable/io/__init__.py +1 -1
  37. pixeltable/io/globals.py +133 -1
  38. pixeltable/io/pandas.py +52 -27
  39. pixeltable/metadata/__init__.py +1 -1
  40. pixeltable/metadata/converters/convert_18.py +39 -0
  41. pixeltable/metadata/notes.py +10 -0
  42. pixeltable/plan.py +76 -1
  43. pixeltable/tool/create_test_db_dump.py +3 -4
  44. pixeltable/tool/doc_plugins/griffe.py +4 -0
  45. pixeltable/type_system.py +15 -14
  46. {pixeltable-0.2.13.dist-info → pixeltable-0.2.14.dist-info}/METADATA +1 -1
  47. {pixeltable-0.2.13.dist-info → pixeltable-0.2.14.dist-info}/RECORD +50 -45
  48. pixeltable/exprs/image_member_access.py +0 -96
  49. {pixeltable-0.2.13.dist-info → pixeltable-0.2.14.dist-info}/LICENSE +0 -0
  50. {pixeltable-0.2.13.dist-info → pixeltable-0.2.14.dist-info}/WHEEL +0 -0
  51. {pixeltable-0.2.13.dist-info → pixeltable-0.2.14.dist-info}/entry_points.txt +0 -0
@@ -15,49 +15,46 @@ t.select(pxt_str.capitalize(t.str_col)).collect()
15
15
  from typing import Any, Optional
16
16
 
17
17
  import pixeltable.func as func
18
- from pixeltable.type_system import StringType
19
18
  from pixeltable.utils.code import local_public_names
20
19
 
21
20
 
22
- @func.udf
23
- def capitalize(s: str) -> str:
21
+ @func.udf(is_method=True)
22
+ def capitalize(self: str) -> str:
24
23
  """
25
- Return `s` with its first character capitalized and the rest lowercased.
24
+ Return string with its first character capitalized and the rest lowercased.
26
25
 
27
26
  Equivalent to [`str.capitalize()`](https://docs.python.org/3/library/stdtypes.html#str.capitalize).
28
27
  """
29
- return s.capitalize()
28
+ return self.capitalize()
30
29
 
31
- @func.udf
32
- def casefold(s: str) -> str:
30
+ @func.udf(is_method=True)
31
+ def casefold(self: str) -> str:
33
32
  """
34
- Return a casefolded copy of `s`.
33
+ Return a casefolded copy of string.
35
34
 
36
35
  Equivalent to [`str.casefold()`](https://docs.python.org/3/library/stdtypes.html#str.casefold).
37
36
  """
38
- return s.casefold()
37
+ return self.casefold()
39
38
 
40
- @func.udf
41
- def center(s: str, width: int, fillchar: str = ' ') -> str:
39
+ @func.udf(is_method=True)
40
+ def center(self: str, width: int, fillchar: str = ' ') -> str:
42
41
  """
43
42
  Return a centered string of length `width`.
44
43
 
45
44
  Equivalent to [`str.center()`](https://docs.python.org/3/library/stdtypes.html#str.center).
46
45
 
47
46
  Args:
48
- s: String.
49
47
  width: Total width of the resulting string.
50
48
  fillchar: Character used for padding.
51
49
  """
52
- return s.center(width, fillchar)
50
+ return self.center(width, fillchar)
53
51
 
54
- @func.udf
55
- def contains(s: str, pattern: str, case: bool = True, flags: int = 0, regex: bool = True) -> bool:
52
+ @func.udf(is_method=True)
53
+ def contains(self: str, pattern: str, case: bool = True, flags: int = 0, regex: bool = True) -> bool:
56
54
  """
57
- Test if pattern or regex is contained within a string.
55
+ Test if string contains pattern or regex.
58
56
 
59
57
  Args:
60
- s: String.
61
58
  pattern: string literal or regular expression
62
59
  case: if False, ignore case
63
60
  flags: [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module
@@ -67,103 +64,97 @@ def contains(s: str, pattern: str, case: bool = True, flags: int = 0, regex: boo
67
64
  import re
68
65
  if not case:
69
66
  flags |= re.IGNORECASE
70
- return bool(re.search(pattern, s, flags))
67
+ return bool(re.search(pattern, self, flags))
71
68
  else:
72
69
  if case:
73
- return pattern in s
70
+ return pattern in self
74
71
  else:
75
- return pattern.lower() in s.lower()
72
+ return pattern.lower() in self.lower()
76
73
 
77
- @func.udf
78
- def count(s: str, pattern: str, flags: int = 0) -> int:
74
+ @func.udf(is_method=True)
75
+ def count(self: str, pattern: str, flags: int = 0) -> int:
79
76
  """
80
- Count occurrences of pattern or regex in `s`.
77
+ Count occurrences of pattern or regex.
81
78
 
82
79
  Args:
83
- s: String.
84
80
  pattern: string literal or regular expression
85
81
  flags: [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module
86
82
  """
87
83
  import re
88
84
  from builtins import len
89
- return len(re.findall(pattern, s, flags))
85
+ return len(re.findall(pattern, self, flags))
90
86
 
91
- @func.udf
92
- def endswith(s: str, pattern: str) -> bool:
87
+ @func.udf(is_method=True)
88
+ def endswith(self: str, pattern: str) -> bool:
93
89
  """
94
90
  Return `True` if the string ends with the specified suffix, otherwise return `False`.
95
91
 
96
92
  Equivalent to [`str.endswith()`](https://docs.python.org/3/library/stdtypes.html#str.endswith).
97
93
 
98
94
  Args:
99
- s: String.
100
95
  pattern: string literal
101
96
  """
102
- return s.endswith(pattern)
97
+ return self.endswith(pattern)
103
98
 
104
- @func.udf
105
- def fill(s: str, width: int, **kwargs: Any) -> str:
99
+ @func.udf(is_method=True)
100
+ def fill(self: str, width: int, **kwargs: Any) -> str:
106
101
  """
107
- Wraps the single paragraph in `s`, and returns a single string containing the wrapped paragraph.
102
+ Wraps the single paragraph in string, and returns a single string containing the wrapped paragraph.
108
103
 
109
104
  Equivalent to [`textwrap.fill()`](https://docs.python.org/3/library/textwrap.html#textwrap.fill).
110
105
 
111
106
  Args:
112
- s: String.
113
107
  width: Maximum line width.
114
108
  kwargs: Additional keyword arguments to pass to `textwrap.fill()`.
115
109
  """
116
110
  import textwrap
117
- return textwrap.fill(s, width, **kwargs)
111
+ return textwrap.fill(self, width, **kwargs)
118
112
 
119
- @func.udf
120
- def find(s: str, substr: str, start: Optional[int] = 0, end: Optional[int] = None) -> int:
113
+ @func.udf(is_method=True)
114
+ def find(self: str, substr: str, start: Optional[int] = 0, end: Optional[int] = None) -> int:
121
115
  """
122
- Return the lowest index in `s` where `substr` is found within the slice `s[start:end]`.
116
+ Return the lowest index in string where `substr` is found within the slice `s[start:end]`.
123
117
 
124
118
  Equivalent to [`str.find()`](https://docs.python.org/3/library/stdtypes.html#str.find).
125
119
 
126
120
  Args:
127
- s: String.
128
121
  substr: substring to search for
129
122
  start: slice start
130
123
  end: slice end
131
124
  """
132
- return s.find(substr, start, end)
125
+ return self.find(substr, start, end)
133
126
 
134
- @func.udf
135
- def findall(s: str, pattern: str, flags: int = 0) -> list:
127
+ @func.udf(is_method=True)
128
+ def findall(self: str, pattern: str, flags: int = 0) -> list:
136
129
  """
137
- Find all occurrences of a regular expression pattern in a string.
130
+ Find all occurrences of a regular expression pattern in string.
138
131
 
139
132
  Equivalent to [`re.findall()`](https://docs.python.org/3/library/re.html#re.findall).
140
133
 
141
134
  Args:
142
- s: String.
143
135
  pattern: regular expression pattern
144
136
  flags: [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module
145
137
  """
146
138
  import re
147
- return re.findall(pattern, s, flags)
139
+ return re.findall(pattern, self, flags)
148
140
 
149
- @func.udf
150
- def format(s: str, *args: Any, **kwargs: Any) -> str:
141
+ @func.udf(is_method=True)
142
+ def format(self: str, *args: Any, **kwargs: Any) -> str:
151
143
  """
152
144
  Perform string formatting.
153
145
 
154
146
  Equivalent to [`str.format()`](https://docs.python.org/3/library/stdtypes.html#str.format).
155
147
  """
156
- return s.format(*args, **kwargs)
148
+ return self.format(*args, **kwargs)
157
149
 
158
- @func.udf
159
- def fullmatch(s: str, pattern: str, case: bool = True, flags: int = 0) -> bool:
150
+ @func.udf(is_method=True)
151
+ def fullmatch(self: str, pattern: str, case: bool = True, flags: int = 0) -> bool:
160
152
  """
161
- Determine if `s` fully matches a regular expression.
153
+ Determine if string fully matches a regular expression.
162
154
 
163
155
  Equivalent to [`re.fullmatch()`](https://docs.python.org/3/library/re.html#re.fullmatch).
164
156
 
165
157
  Args:
166
- s: String.
167
158
  pattern: regular expression pattern
168
159
  case: if False, ignore case
169
160
  flags: [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module
@@ -171,160 +162,159 @@ def fullmatch(s: str, pattern: str, case: bool = True, flags: int = 0) -> bool:
171
162
  import re
172
163
  if not case:
173
164
  flags |= re.IGNORECASE
174
- _ = bool(re.fullmatch(pattern, s, flags))
175
- return bool(re.fullmatch(pattern, s, flags))
165
+ _ = bool(re.fullmatch(pattern, self, flags))
166
+ return bool(re.fullmatch(pattern, self, flags))
176
167
 
177
- @func.udf
178
- def index(s: str, substr: str, start: Optional[int] = 0, end: Optional[int] = None) -> int:
168
+ @func.udf(is_method=True)
169
+ def index(self: str, substr: str, start: Optional[int] = 0, end: Optional[int] = None) -> int:
179
170
  """
180
- Return the lowest index in `s` where `substr` is found within the slice `s[start:end]`. Raises ValueError if `substr` is not found.
171
+ Return the lowest index in string where `substr` is found within the slice `[start:end]`.
172
+ Raises ValueError if `substr` is not found.
181
173
 
182
174
  Equivalent to [`str.index()`](https://docs.python.org/3/library/stdtypes.html#str.index).
183
175
 
184
176
  Args:
185
- s: String.
186
177
  substr: substring to search for
187
178
  start: slice start
188
179
  end: slice end
189
180
  """
190
- return s.index(substr, start, end)
181
+ return self.index(substr, start, end)
191
182
 
192
- @func.udf
193
- def isalnum(s: str) -> bool:
183
+ @func.udf(is_method=True)
184
+ def isalnum(self: str) -> bool:
194
185
  """
195
186
  Return `True` if all characters in the string are alphanumeric and there is at least one character, `False`
196
187
  otherwise.
197
188
 
198
189
  Equivalent to [`str.isalnum()`](https://docs.python.org/3/library/stdtypes.html#str.isalnum
199
190
  """
200
- return s.isalnum()
191
+ return self.isalnum()
201
192
 
202
- @func.udf
203
- def isalpha(s: str) -> bool:
193
+ @func.udf(is_method=True)
194
+ def isalpha(self: str) -> bool:
204
195
  """
205
196
  Return `True` if all characters in the string are alphabetic and there is at least one character, `False` otherwise.
206
197
 
207
198
  Equivalent to [`str.isalpha()`](https://docs.python.org/3/library/stdtypes.html#str.isalpha).
208
199
  """
209
- return s.isalpha()
200
+ return self.isalpha()
210
201
 
211
- @func.udf
212
- def isascii(s: str) -> bool:
202
+ @func.udf(is_method=True)
203
+ def isascii(self: str) -> bool:
213
204
  """
214
205
  Return `True` if the string is empty or all characters in the string are ASCII, `False` otherwise.
215
206
 
216
207
  Equivalent to [`str.isascii()`](https://docs.python.org/3/library/stdtypes.html#str.isascii).
217
208
  """
218
- return s.isascii()
209
+ return self.isascii()
219
210
 
220
- @func.udf
221
- def isdecimal(s: str) -> bool:
211
+ @func.udf(is_method=True)
212
+ def isdecimal(self: str) -> bool:
222
213
  """
223
214
  Return `True` if all characters in the string are decimal characters and there is at least one character, `False`
224
215
  otherwise.
225
216
 
226
217
  Equivalent to [`str.isdecimal()`](https://docs.python.org/3/library/stdtypes.html#str.isdecimal).
227
218
  """
228
- return s.isdecimal()
219
+ return self.isdecimal()
229
220
 
230
- @func.udf
231
- def isdigit(s: str) -> bool:
221
+ @func.udf(is_method=True)
222
+ def isdigit(self: str) -> bool:
232
223
  """
233
224
  Return `True` if all characters in the string are digits and there is at least one character, `False` otherwise.
234
225
 
235
226
  Equivalent to [`str.isdigit()`](https://docs.python.org/3/library/stdtypes.html#str.isdigit).
236
227
  """
237
- return s.isdigit()
228
+ return self.isdigit()
238
229
 
239
- @func.udf
240
- def isidentifier(s: str) -> bool:
230
+ @func.udf(is_method=True)
231
+ def isidentifier(self: str) -> bool:
241
232
  """
242
233
  Return `True` if the string is a valid identifier according to the language definition, `False` otherwise.
243
234
 
244
235
  Equivalent to [`str.isidentifier()`](https://docs.python.org/3/library/stdtypes.html#str.isidentifier)
245
236
  """
246
- return s.isidentifier()
237
+ return self.isidentifier()
247
238
 
248
239
 
249
- @func.udf
250
- def islower(s: str) -> bool:
240
+ @func.udf(is_method=True)
241
+ def islower(self: str) -> bool:
251
242
  """
252
243
  Return `True` if all cased characters in the string are lowercase and there is at least one cased character, `False` otherwise.
253
244
 
254
245
  Equivalent to [`str.islower()`](https://docs.python.org/3/library/stdtypes.html#str.islower)
255
246
  """
256
- return s.islower()
247
+ return self.islower()
257
248
 
258
- @func.udf
259
- def isnumeric(s: str) -> bool:
249
+ @func.udf(is_method=True)
250
+ def isnumeric(self: str) -> bool:
260
251
  """
261
252
  Return `True` if all characters in the string are numeric characters, `False` otherwise.
262
253
 
263
254
  Equivalent to [`str.isnumeric()`](https://docs.python.org/3/library/stdtypes.html#str.isnumeric)
264
255
  """
265
- return s.isnumeric()
256
+ return self.isnumeric()
266
257
 
267
- @func.udf
268
- def isupper(s: str) -> bool:
258
+ @func.udf(is_method=True)
259
+ def isupper(self: str) -> bool:
269
260
  """
270
261
  Return `True` if all cased characters in the string are uppercase and there is at least one cased character, `False` otherwise.
271
262
 
272
263
  Equivalent to [`str.isupper()`](https://docs.python.org/3/library/stdtypes.html#str.isupper)
273
264
  """
274
- return s.isupper()
265
+ return self.isupper()
275
266
 
276
- @func.udf
277
- def istitle(s: str) -> bool:
267
+ @func.udf(is_method=True)
268
+ def istitle(self: str) -> bool:
278
269
  """
279
270
  Return `True` if the string is a titlecased string and there is at least one character, `False` otherwise.
280
271
 
281
272
  Equivalent to [`str.istitle()`](https://docs.python.org/3/library/stdtypes.html#str.istitle)
282
273
  """
283
- return s.istitle()
274
+ return self.istitle()
284
275
 
285
- @func.udf
286
- def isspace(s: str) -> bool:
276
+ @func.udf(is_method=True)
277
+ def isspace(self: str) -> bool:
287
278
  """
288
279
  Return `True` if there are only whitespace characters in the string and there is at least one character, `False` otherwise.
289
280
 
290
281
  Equivalent to [`str.isspace()`](https://docs.python.org/3/library/stdtypes.html#str.isspace)
291
282
  """
292
- return s.isspace()
283
+ return self.isspace()
293
284
 
294
- @func.udf
295
- def len(s: str) -> int:
285
+ @func.udf(is_method=True)
286
+ def len(self: str) -> int:
296
287
  """
297
288
  Return the number of characters in the string.
298
289
 
299
290
  Equivalent to [`len(str)`](https://docs.python.org/3/library/functions.html#len)
300
291
  """
301
- return s.__len__()
292
+ return self.__len__()
302
293
 
303
- @func.udf
304
- def ljust(s: str, width: int, fillchar: str = ' ') -> str:
294
+ @func.udf(is_method=True)
295
+ def ljust(self: str, width: int, fillchar: str = ' ') -> str:
305
296
  """
306
- Return the string left-justified in a string of length `width`. Padding is done using the specified `fillchar` (default is a space).
297
+ Return the string left-justified in a string of length `width`.
307
298
 
308
299
  Equivalent to [`str.ljust()`](https://docs.python.org/3/library/stdtypes.html#str.ljust)
309
300
 
310
301
  Args:
311
- s: String.
312
302
  width: Minimum width of resulting string; additional characters will be filled with character defined in `fillchar`.
313
303
  fillchar: Additional character for filling.
314
304
  """
315
- return s.ljust(width, fillchar)
305
+ return self.ljust(width, fillchar)
316
306
 
317
- @func.udf
318
- def lower(s: str) -> str:
307
+ @func.udf(is_method=True)
308
+ def lower(self: str) -> str:
319
309
  """
320
310
  Return a copy of the string with all the cased characters converted to lowercase.
321
311
 
322
312
  Equivalent to [`str.lower()`](https://docs.python.org/3/library/stdtypes.html#str.lower)
323
313
  """
324
- return s.lower()
314
+ return self.lower()
325
315
 
326
- @func.udf
327
- def lstrip(s: str, chars: Optional[str] = None) -> str:
316
+ @func.udf(is_method=True)
317
+ def lstrip(self: str, chars: Optional[str] = None) -> str:
328
318
  """
329
319
  Return a copy of the string with leading characters removed. The `chars` argument is a string specifying the set of
330
320
  characters to be removed. If omitted or `None`, whitespace characters are removed.
@@ -332,18 +322,16 @@ def lstrip(s: str, chars: Optional[str] = None) -> str:
332
322
  Equivalent to [`str.lstrip()`](https://docs.python.org/3/library/stdtypes.html#str.lstrip)
333
323
 
334
324
  Args:
335
- s: String.
336
325
  chars: The set of characters to be removed.
337
326
  """
338
- return s.lstrip(chars)
327
+ return self.lstrip(chars)
339
328
 
340
- @func.udf
341
- def match(s: str, pattern: str, case: bool = True, flags: int = 0) -> bool:
329
+ @func.udf(is_method=True)
330
+ def match(self: str, pattern: str, case: bool = True, flags: int = 0) -> bool:
342
331
  """
343
332
  Determine if string starts with a match of a regular expression
344
333
 
345
334
  Args:
346
- s: String.
347
335
  pattern: regular expression pattern
348
336
  case: if False, ignore case
349
337
  flags: [flags](https://docs.python.org/3/library/re.html#flags) for the `re` module
@@ -351,96 +339,93 @@ def match(s: str, pattern: str, case: bool = True, flags: int = 0) -> bool:
351
339
  import re
352
340
  if not case:
353
341
  flags |= re.IGNORECASE
354
- return bool(re.match(pattern, s, flags))
342
+ return bool(re.match(pattern, self, flags))
355
343
 
356
- @func.udf
357
- def normalize(s: str, form: str) -> str:
344
+ @func.udf(is_method=True)
345
+ def normalize(self: str, form: str) -> str:
358
346
  """
359
- Return the Unicode normal form for `s`.
347
+ Return the Unicode normal form.
360
348
 
361
349
  Equivalent to [`unicodedata.normalize()`](https://docs.python.org/3/library/unicodedata.html#unicodedata.normalize)
362
350
 
363
351
  Args:
364
- s: String.
365
352
  form: Unicode normal form (`‘NFC’`, `‘NFKC’`, `‘NFD’`, `‘NFKD’`)
366
353
  """
367
354
  import unicodedata
368
- return unicodedata.normalize(form, s)
355
+ return unicodedata.normalize(form, self)
369
356
 
370
- @func.udf
371
- def pad(s: str, width: int, side: str = 'left', fillchar: str = ' ') -> str:
357
+ @func.udf(is_method=True)
358
+ def pad(self: str, width: int, side: str = 'left', fillchar: str = ' ') -> str:
372
359
  """
373
360
  Pad string up to width
374
361
 
375
362
  Args:
376
- s: String.
377
363
  width: Minimum width of resulting string; additional characters will be filled with character defined in `fillchar`.
378
364
  side: Side from which to fill resulting string (`‘left’`, `‘right’`, `‘both’`)
379
365
  fillchar: Additional character for filling
380
366
  """
381
367
  if side == 'left':
382
- return s.ljust(width, fillchar)
368
+ return self.ljust(width, fillchar)
383
369
  elif side == 'right':
384
- return s.rjust(width, fillchar)
370
+ return self.rjust(width, fillchar)
385
371
  elif side == 'both':
386
- return s.center(width, fillchar)
372
+ return self.center(width, fillchar)
387
373
  else:
388
374
  raise ValueError(f"Invalid side: {side}")
389
375
 
390
- @func.udf
391
- def partition(s: str, sep: str = ' ') -> list:
376
+ @func.udf(is_method=True)
377
+ def partition(self: str, sep: str = ' ') -> list:
392
378
  """
393
- Splits `s` at the first occurrence of `sep`, and returns 3 elements containing the part before the
379
+ Splits string at the first occurrence of `sep`, and returns 3 elements containing the part before the
394
380
  separator, the separator itself, and the part after the separator. If the separator is not found, return 3 elements
395
- containing `s` itself, followed by two empty strings.
381
+ containing string itself, followed by two empty strings.
396
382
  """
397
- idx = s.find(sep)
383
+ idx = self.find(sep)
398
384
  if idx == -1:
399
- return [s, '', '']
385
+ return [self, '', '']
400
386
  from builtins import len
401
- return [s[:idx], sep, s[idx + len(sep):]]
387
+ return [self[:idx], sep, self[idx + len(sep):]]
402
388
 
403
- @func.udf
404
- def removeprefix(s: str, prefix: str) -> str:
389
+ @func.udf(is_method=True)
390
+ def removeprefix(self: str, prefix: str) -> str:
405
391
  """
406
- Remove prefix from `s`. If the prefix is not present, returns `s`.
392
+ Remove prefix. If the prefix is not present, returns string.
407
393
  """
408
- if s.startswith(prefix):
394
+ if self.startswith(prefix):
409
395
  # we need to avoid referring to our symbol 'len'
410
396
  from builtins import len
411
- return s[len(prefix):]
412
- return s
397
+ return self[len(prefix):]
398
+ return self
413
399
 
414
- @func.udf
415
- def removesuffix(s: str, suffix: str) -> str:
400
+ @func.udf(is_method=True)
401
+ def removesuffix(self: str, suffix: str) -> str:
416
402
  """
417
- Remove suffix from `s`. If the suffix is not present, returns `s`.
403
+ Remove suffix. If the suffix is not present, returns string.
418
404
  """
419
- if s.endswith(suffix):
405
+ if self.endswith(suffix):
420
406
  # we need to avoid referring to our symbol 'len'
421
407
  from builtins import len
422
- return s[:-len(suffix)]
423
- return s
408
+ return self[:-len(suffix)]
409
+ return self
424
410
 
425
- @func.udf
426
- def repeat(s: str, n: int) -> str:
411
+ @func.udf(is_method=True)
412
+ def repeat(self: str, n: int) -> str:
427
413
  """
428
- Repeat `s` `n` times.
414
+ Repeat string `n` times.
429
415
  """
430
- return s * n
416
+ return self * n
431
417
 
432
- @func.udf
418
+ @func.udf(is_method=True)
433
419
  def replace(
434
- s: str, pattern: str, repl: str, n: int = -1, case: bool = True, flags: int = 0, regex: bool = False
420
+ self: str, pattern: str, repl: str, n: int = -1, case: bool = True, flags: int = 0, regex: bool = False
435
421
  ) -> str:
436
422
  """
437
- Replace occurrences of `pattern` in `s` with `repl`.
423
+ Replace occurrences of `pattern` with `repl`.
438
424
 
439
425
  Equivalent to [`str.replace()`](https://docs.python.org/3/library/stdtypes.html#str.replace) or
440
426
  [`re.sub()`](https://docs.python.org/3/library/re.html#re.sub), depending on the value of regex.
441
427
 
442
428
  Args:
443
- s: String.
444
429
  pattern: string literal or regular expression
445
430
  repl: replacement string
446
431
  n: number of replacements to make (-1 for all)
@@ -452,181 +437,173 @@ def replace(
452
437
  import re
453
438
  if not case:
454
439
  flags |= re.IGNORECASE
455
- return re.sub(pattern, repl, s, 0 if n == -1 else n, flags)
440
+ return re.sub(pattern, repl, self, 0 if n == -1 else n, flags)
456
441
  else:
457
- return s.replace(pattern, repl, n)
442
+ return self.replace(pattern, repl, n)
458
443
 
459
- @func.udf
460
- def rfind(s: str, substr: str, start: Optional[int] = 0, end: Optional[int] = None) -> int:
444
+ @func.udf(is_method=True)
445
+ def rfind(self: str, substr: str, start: Optional[int] = 0, end: Optional[int] = None) -> int:
461
446
  """
462
- Return the highest index in `s` where `substr` is found, such that `substr` is contained within `s[start:end]`.
447
+ Return the highest index where `substr` is found, such that `substr` is contained within `[start:end]`.
463
448
 
464
449
  Equivalent to [`str.rfind()`](https://docs.python.org/3/library/stdtypes.html#str.rfind).
465
450
 
466
451
  Args:
467
- s: String.
468
452
  substr: substring to search for
469
453
  start: slice start
470
454
  end: slice end
471
455
  """
472
- return s.rfind(substr, start, end)
456
+ return self.rfind(substr, start, end)
473
457
 
474
- @func.udf
475
- def rindex(s: str, substr: str, start: Optional[int] = 0, end: Optional[int] = None) -> int:
458
+ @func.udf(is_method=True)
459
+ def rindex(self: str, substr: str, start: Optional[int] = 0, end: Optional[int] = None) -> int:
476
460
  """
477
- Return the highest index in `s` where `substr` is found, such that `substr` is contained within `s[start:end]`.
461
+ Return the highest index where `substr` is found, such that `substr` is contained within `[start:end]`.
478
462
  Raises ValueError if `substr` is not found.
479
463
 
480
464
  Equivalent to [`str.rindex()`](https://docs.python.org/3/library/stdtypes.html#str.rindex).
481
465
  """
482
- return s.rindex(substr, start, end)
466
+ return self.rindex(substr, start, end)
483
467
 
484
- @func.udf
485
- def rjust(s: str, width: int, fillchar: str = ' ') -> str:
468
+ @func.udf(is_method=True)
469
+ def rjust(self: str, width: int, fillchar: str = ' ') -> str:
486
470
  """
487
- Return `s` right-justified in a string of length `width`.
471
+ Return the string right-justified in a string of length `width`.
488
472
 
489
473
  Equivalent to [`str.rjust()`](https://docs.python.org/3/library/stdtypes.html#str.rjust).
490
474
 
491
475
  Args:
492
- s: String.
493
476
  width: Minimum width of resulting string.
494
477
  fillchar: Additional character for filling.
495
478
  """
496
- return s.rjust(width, fillchar)
479
+ return self.rjust(width, fillchar)
497
480
 
498
- @func.udf
499
- def rpartition(s: str, sep: str = ' ') -> list:
481
+ @func.udf(is_method=True)
482
+ def rpartition(self: str, sep: str = ' ') -> list:
500
483
  """
501
- This method splits `s` at the last occurrence of `sep`, and returns a list containing the part before the
484
+ This method splits string at the last occurrence of `sep`, and returns a list containing the part before the
502
485
  separator, the separator itself, and the part after the separator.
503
486
  """
504
- idx = s.rfind(sep)
487
+ idx = self.rfind(sep)
505
488
  if idx == -1:
506
- return [s, '', '']
489
+ return [self, '', '']
507
490
  from builtins import len
508
- return [s[:idx], sep, s[idx + len(sep):]]
491
+ return [self[:idx], sep, self[idx + len(sep):]]
509
492
 
510
- @func.udf
511
- def rstrip(s: str, chars: Optional[str] = None) -> str:
493
+ @func.udf(is_method=True)
494
+ def rstrip(self: str, chars: Optional[str] = None) -> str:
512
495
  """
513
- Return a copy of `s` with trailing characters removed.
496
+ Return a copy of string with trailing characters removed.
514
497
 
515
498
  Equivalent to [`str.rstrip()`](https://docs.python.org/3/library/stdtypes.html#str.rstrip).
516
499
 
517
500
  Args:
518
- s: String.
519
501
  chars: The set of characters to be removed. If omitted or `None`, whitespace characters are removed.
520
502
  """
521
- return s.rstrip(chars)
503
+ return self.rstrip(chars)
522
504
 
523
- @func.udf
524
- def slice(s: str, start: Optional[int] = None, stop: Optional[int] = None, step: Optional[int] = None) -> str:
505
+ @func.udf(is_method=True)
506
+ def slice(self: str, start: Optional[int] = None, stop: Optional[int] = None, step: Optional[int] = None) -> str:
525
507
  """
526
- Return a slice of `s`.
508
+ Return a slice.
527
509
 
528
510
  Args:
529
- s: String.
530
511
  start: slice start
531
512
  stop: slice end
532
513
  step: slice step
533
514
  """
534
- return s[start:stop:step]
515
+ return self[start:stop:step]
535
516
 
536
- @func.udf
537
- def slice_replace(s: str, start: Optional[int] = None, stop: Optional[int] = None, repl: Optional[str] = None) -> str:
517
+ @func.udf(is_method=True)
518
+ def slice_replace(self: str, start: Optional[int] = None, stop: Optional[int] = None, repl: Optional[str] = None) -> str:
538
519
  """
539
- Replace a positional slice of a string with another value.
520
+ Replace a positional slice with another value.
540
521
 
541
522
  Args:
542
- s: String.
543
523
  start: slice start
544
524
  stop: slice end
545
525
  repl: replacement value
546
526
  """
547
- return s[:start] + repl + s[stop:]
527
+ return self[:start] + repl + self[stop:]
548
528
 
549
- @func.udf
550
- def startswith(s: str, pattern: str) -> int:
529
+ @func.udf(is_method=True)
530
+ def startswith(self: str, pattern: str) -> int:
551
531
  """
552
- Return `True` if `s` starts with `pattern`, otherwise return `False`.
532
+ Return `True` if string starts with `pattern`, otherwise return `False`.
553
533
 
554
534
  Equivalent to [`str.startswith()`](https://docs.python.org/3/library/stdtypes.html#str.startswith).
555
535
 
556
536
  Args:
557
- s: String.
558
537
  pattern: string literal
559
538
  """
560
- return s.startswith(pattern)
539
+ return self.startswith(pattern)
561
540
 
562
- @func.udf
563
- def strip(s: str, chars: Optional[str] = None) -> str:
541
+ @func.udf(is_method=True)
542
+ def strip(self: str, chars: Optional[str] = None) -> str:
564
543
  """
565
- Return a copy of `s` with leading and trailing characters removed.
544
+ Return a copy of string with leading and trailing characters removed.
566
545
 
567
546
  Equivalent to [`str.strip()`](https://docs.python.org/3/library/stdtypes.html#str.strip).
568
547
 
569
548
  Args:
570
- s: String.
571
549
  chars: The set of characters to be removed. If omitted or `None`, whitespace characters are removed.
572
550
  """
573
- return s.strip(chars)
551
+ return self.strip(chars)
574
552
 
575
- @func.udf
576
- def swapcase(s: str) -> str:
553
+ @func.udf(is_method=True)
554
+ def swapcase(self: str) -> str:
577
555
  """
578
- Return a copy of `s` with uppercase characters converted to lowercase and vice versa.
556
+ Return a copy of string with uppercase characters converted to lowercase and vice versa.
579
557
 
580
558
  Equivalent to [`str.swapcase()`](https://docs.python.org/3/library/stdtypes.html#str.swapcase).
581
559
  """
582
- return s.swapcase()
560
+ return self.swapcase()
583
561
 
584
- @func.udf
585
- def title(s: str) -> str:
562
+ @func.udf(is_method=True)
563
+ def title(self: str) -> str:
586
564
  """
587
- Return a titlecased version of `s`, i.e. words start with uppercase characters, all remaining cased characters are
588
- lowercase.
565
+ Return a titlecased version of string, i.e. words start with uppercase characters, all remaining cased characters
566
+ are lowercase.
589
567
 
590
568
  Equivalent to [`str.title()`](https://docs.python.org/3/library/stdtypes.html#str.title).
591
569
  """
592
- return s.title()
570
+ return self.title()
593
571
 
594
- @func.udf
595
- def upper(s: str) -> str:
572
+ @func.udf(is_method=True)
573
+ def upper(self: str) -> str:
596
574
  """
597
- Return a copy of `s` converted to uppercase.
575
+ Return a copy of string converted to uppercase.
576
+
598
577
  Equivalent to [`str.upper()`](https://docs.python.org/3/library/stdtypes.html#str.upper).
599
578
  """
600
- return s.upper()
579
+ return self.upper()
601
580
 
602
- @func.udf
603
- def wrap(s: str, width: int, **kwargs: Any) -> dict:
581
+ @func.udf(is_method=True)
582
+ def wrap(self: str, width: int, **kwargs: Any) -> dict:
604
583
  """
605
- Wraps the single paragraph in `s` so every line is at most `width` characters long.
584
+ Wraps the single paragraph in string so every line is at most `width` characters long.
606
585
  Returns a list of output lines, without final newlines.
607
586
 
608
587
  Equivalent to [`textwrap.fill()`](https://docs.python.org/3/library/textwrap.html#textwrap.fill).
609
588
 
610
589
  Args:
611
- s: String.
612
590
  width: Maximum line width.
613
591
  kwargs: Additional keyword arguments to pass to `textwrap.fill()`.
614
592
  """
615
593
  import textwrap
616
- return textwrap.wrap(s, width, **kwargs)
594
+ return textwrap.wrap(self, width, **kwargs)
617
595
 
618
- @func.udf
619
- def zfill(s: str, width: int) -> str:
596
+ @func.udf(is_method=True)
597
+ def zfill(self: str, width: int) -> str:
620
598
  """
621
- Pad a numeric string `s` with ASCII `0` on the left to a total length of `width`.
599
+ Pad a numeric string with ASCII `0` on the left to a total length of `width`.
622
600
 
623
601
  Equivalent to [`str.zfill()`](https://docs.python.org/3/library/stdtypes.html#str.zfill).
624
602
 
625
603
  Args:
626
- s: String.
627
604
  width: Minimum width of resulting string.
628
605
  """
629
- return s.zfill(width)
606
+ return self.zfill(width)
630
607
 
631
608
 
632
609
  __all__ = local_public_names(__name__)