plain#

scikitplot.agent.plain(value, *, what='value')[source]#

Return value as a plain JSON value, or raise.

Parameters:
valueobject

None, bool, int, float, str, or a list, tuple, or dict of them (dict keys must be str).

whatstr, default=”value”

Names the value in an error message.

Returns:
object

A new value of plain JSON types: tuples become lists, dict subclasses become dict. Scalars are returned as they are.

Raises:
TypeError

If the value, or anything inside it, is of another type, or a key is not a string.

ValueError

If a float is not finite, a string holds a lone surrogate, an integer has more than MAX_INT_DIGITS digits, or the nesting is deeper than MAX_DEPTH.

Parameters:
Return type:

Any

Examples

>>> from scikitplot.agent._canonical import plain
>>> plain({"a": (1, 2.5, None)})
{'a': [1, 2.5, None]}