chalkpy 2.96.2__py3-none-any.whl → 2.96.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.
- chalk/_version.py +1 -1
- chalk/functions/__init__.py +47 -0
- {chalkpy-2.96.2.dist-info → chalkpy-2.96.3.dist-info}/METADATA +1 -1
- {chalkpy-2.96.2.dist-info → chalkpy-2.96.3.dist-info}/RECORD +7 -7
- {chalkpy-2.96.2.dist-info → chalkpy-2.96.3.dist-info}/WHEEL +0 -0
- {chalkpy-2.96.2.dist-info → chalkpy-2.96.3.dist-info}/entry_points.txt +0 -0
- {chalkpy-2.96.2.dist-info → chalkpy-2.96.3.dist-info}/top_level.txt +0 -0
chalk/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.96.
|
|
1
|
+
__version__ = "2.96.3"
|
chalk/functions/__init__.py
CHANGED
|
@@ -4211,6 +4211,53 @@ def contains(arr: Underscore | list[Any] | set[Any], value: Any):
|
|
|
4211
4211
|
return UnderscoreFunction("contains", arr, value)
|
|
4212
4212
|
|
|
4213
4213
|
|
|
4214
|
+
def is_in(value: Underscore | Any, arr: Underscore | list[Any] | set[Any]):
|
|
4215
|
+
"""
|
|
4216
|
+
Returns whether the value is in the array.
|
|
4217
|
+
|
|
4218
|
+
Parameters
|
|
4219
|
+
----------
|
|
4220
|
+
value
|
|
4221
|
+
The value to check for in the array.
|
|
4222
|
+
arr
|
|
4223
|
+
The array to search for the value.
|
|
4224
|
+
|
|
4225
|
+
Returns
|
|
4226
|
+
-------
|
|
4227
|
+
Boolean indicating whether the value is present in the array.
|
|
4228
|
+
|
|
4229
|
+
Examples
|
|
4230
|
+
--------
|
|
4231
|
+
>>> import chalk.functions as F
|
|
4232
|
+
>>> from chalk.features import _, features
|
|
4233
|
+
>>> @features
|
|
4234
|
+
... class User:
|
|
4235
|
+
... id: str
|
|
4236
|
+
... role: str
|
|
4237
|
+
... is_admin: bool = F.is_in(_.role, ["admin", "superuser"])
|
|
4238
|
+
|
|
4239
|
+
>>> # With dynamic array
|
|
4240
|
+
>>> @features
|
|
4241
|
+
... class APIRequest:
|
|
4242
|
+
... id: str
|
|
4243
|
+
... user_id: str
|
|
4244
|
+
... allowed_users: list[str]
|
|
4245
|
+
... is_allowed: bool = F.is_in(_.user_id, _.allowed_users)
|
|
4246
|
+
"""
|
|
4247
|
+
if isinstance(arr, Underscore):
|
|
4248
|
+
return UnderscoreFunction("contains", arr, value)
|
|
4249
|
+
if len(arr) < 1:
|
|
4250
|
+
raise ValueError("Expected input array to have at least one element")
|
|
4251
|
+
try:
|
|
4252
|
+
map_const = pa.scalar(
|
|
4253
|
+
{elem: None for elem in arr},
|
|
4254
|
+
type=pa.map_(rich_to_pyarrow(type(next(iter(arr))), name="arr_type"), pa.null()),
|
|
4255
|
+
)
|
|
4256
|
+
except pa.ArrowInvalid as ai:
|
|
4257
|
+
raise ValueError("Expected constant input array to have entries all of the same type") from ai
|
|
4258
|
+
return UnderscoreFunction("map_key_exists", map_const, value)
|
|
4259
|
+
|
|
4260
|
+
|
|
4214
4261
|
def cardinality(arr: Underscore):
|
|
4215
4262
|
"""
|
|
4216
4263
|
Returns the number of elements in an array.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
chalk/__init__.py,sha256=vKsx9-cl5kImlVWGHVRYO6bweBm79NAzGs3l36u71wM,2657
|
|
2
|
-
chalk/_version.py,sha256=
|
|
2
|
+
chalk/_version.py,sha256=XJHkYZYgBkcwjlprd1G1-3H4jEGG2wU1InKh3ZqOgZo,23
|
|
3
3
|
chalk/cli.py,sha256=ckqqfOI-A2mT23-rnZzDMmblYj-2x1VBX8ebHlIEn9A,5873
|
|
4
4
|
chalk/importer.py,sha256=m4lMn1lSYj_euDq8CS7LYTBnek9JOcjGJf9-82dJHbA,64441
|
|
5
5
|
chalk/prompts.py,sha256=2H9UomLAamdfRTNUdKs9i3VTpiossuyRhntqsAXUhhg,16117
|
|
@@ -685,7 +685,7 @@ chalk/features/dataframe/__init__.py,sha256=h88XglttpuUBt0TDoltaxp-90jNtIVxZhKAp
|
|
|
685
685
|
chalk/features/dataframe/_filters.py,sha256=F9c5wExtmO21zhn4HEWcM9t4qSpfIO9Z7ysvoeZRV0I,20034
|
|
686
686
|
chalk/features/dataframe/_impl.py,sha256=6zrwip7jL4DjNDEzmXw3PdKzZ-RJZTFwafqBUdK_Toc,88131
|
|
687
687
|
chalk/features/dataframe/_validation.py,sha256=PsseXqoTgmgqaYtr-sTJP0CzlTo2v2PezkF0A8Za-oo,11037
|
|
688
|
-
chalk/functions/__init__.py,sha256=
|
|
688
|
+
chalk/functions/__init__.py,sha256=5Y2pFjCZjkPyfP8ygdknY5_HI9Yk-aob-4n2AgtSlyA,169215
|
|
689
689
|
chalk/functions/holidays.py,sha256=7yhLjH4E1nDNGA0cXnvRQl5_h_W6rFZfIGYEBa-WiM8,3444
|
|
690
690
|
chalk/functions/http.py,sha256=f3UpokWnjLyo0A_zZoSDgfGgRWmLu639FkREi6p82b4,6653
|
|
691
691
|
chalk/functions/proto.py,sha256=RpM4GIj0-hVTA8RcK_k_fQOz9hvidgFtAbtcmD5Y4K0,5749
|
|
@@ -823,8 +823,8 @@ chalk/utils/tracing.py,sha256=NiiM-9dbuJhSCv6R1npR1uYNKWlkqTR6Ygm0Voi2NrY,13078
|
|
|
823
823
|
chalk/utils/weak_set_by_identity.py,sha256=VmikA_laYwFeOphCwXJIuyOIkrdlQe0bSzaXq7onoQw,953
|
|
824
824
|
chalk/utils/pydanticutil/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
825
825
|
chalk/utils/pydanticutil/pydantic_compat.py,sha256=O575lLYJ5GvZC4HMzR9yATxf9XwjC6NrDUXbNwZidlE,3031
|
|
826
|
-
chalkpy-2.96.
|
|
827
|
-
chalkpy-2.96.
|
|
828
|
-
chalkpy-2.96.
|
|
829
|
-
chalkpy-2.96.
|
|
830
|
-
chalkpy-2.96.
|
|
826
|
+
chalkpy-2.96.3.dist-info/METADATA,sha256=f67CfiifytFHapQXl81lOur88VRBpbWj35VhMQDOnUc,27754
|
|
827
|
+
chalkpy-2.96.3.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
828
|
+
chalkpy-2.96.3.dist-info/entry_points.txt,sha256=Vg23sd8icwq-morJrljVFr-kQnMbm95rZfZj5wsZGis,42
|
|
829
|
+
chalkpy-2.96.3.dist-info/top_level.txt,sha256=1Q6_19IGYfNxSw50W8tYKEJ2t5HKQ3W9Wiw4ia5yg2c,6
|
|
830
|
+
chalkpy-2.96.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|