Utils
Utilities.
generic_id_generator(id_func)
Parameterized ID generator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_func
|
callable
|
function to generate a single ID |
required |
Returns:
Type | Description |
---|---|
generator
|
ID generator. |
Source code in src/snailz/utils.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
json_dump(obj, indent=2)
Dump as JSON with appropriate settings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
any
|
The object to serialize |
required |
indent
|
int | None
|
Indentation (None for none) |
2
|
Returns:
Type | Description |
---|---|
str
|
JSON representation of object. |
Source code in src/snailz/utils.py
30 31 32 33 34 35 36 37 38 39 40 41 |
|
max_grid_value(grids)
Find maximum value across a list of grids.
Source code in src/snailz/utils.py
44 45 46 47 48 49 50 51 52 |
|
_serialize_json(obj)
Custom JSON serializer for JSON conversion.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
any
|
The object to serialize |
required |
Returns:
Type | Description |
---|---|
str | None
|
string representation or None. |
Raises:
Type | Description |
---|---|
TypeError
|
If the object type is not supported for serialization |
Source code in src/snailz/utils.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|