MCPcopy Index your code
hub / github.com/ScrapeGraphAI/toonify / _encode_array

Function _encode_array

toon/encoder.py:165–180  ·  view source on GitHub ↗

Encode an array.

(arr: list, level: int, opts: EncoderOptions)

Source from the content-addressed store, hash-verified

163
164
165def _encode_array(arr: list, level: int, opts: EncoderOptions) -> str:
166 """Encode an array."""
167 if not arr:
168 return '[]'
169
170 # Check if it's a uniform array of objects (tabular format)
171 fields = is_uniform_array_of_objects(arr)
172 if fields:
173 return _encode_tabular_array(arr, fields, level, opts, key=None)
174
175 # Check if all elements are primitives (inline format)
176 if all(is_primitive(item) for item in arr):
177 return _encode_primitive_array(arr, opts)
178
179 # Mixed array (list format)
180 return _encode_list_array(arr, level, opts, key=None)
181
182def _encode_tuple(value: tuple) -> str:
183 """Encode a tuple."""

Callers 1

_encode_valueFunction · 0.85

Calls 5

_encode_tabular_arrayFunction · 0.85
is_primitiveFunction · 0.85
_encode_primitive_arrayFunction · 0.85
_encode_list_arrayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…