def delistify(a, b=None):
if isinstance(b, (tuple, list, np.ndarray)):<EOL><INDENT>if isinstance(a, (tuple, list, np.ndarray)):<EOL><INDENT>return type(b)(a)<EOL><DEDENT>return type(b)([a])<EOL><DEDENT>else:<EOL><INDENT>if isinstance(a, (tuple, list, np.ndarray)) and len(a) == <NUM_LIT:1>:<EOL><INDENT>return a[<NUM_LIT:0>]<EOL><DEDENT>return a<EOL><DEDENT>return a<EOL>
If a single element list, extract the element as an object, otherwise
leave as it is.

Examples
--------
>>> delistify('string')
'string'

>>> delistify(['string'])
'string'

>>> delistify(['string', 'other'])
['string', 'other']

>>> delistify(np.array([1.0]))
1.0

>>> delistify([1, 2, 3])
[1, 2, 3]