When `value` is a plain Python sequence, return it as a NumPy array.
321828
def _to_array(value):
    """"""
    if hasattr(value, 'shape'):
        return value
    elif hasattr(value, '__len__'):
        return array(value)
    else:
        return float_(value)
446545
def tuplewrap(value):
    
    if is_many(value):
        return tuple(tuplewrap(v) if is_sequence(v) else v for v in value)
    return unwrap(value),
693735
def to_0d_object_array(value: Any) -> np.ndarray:
    
    result = np.empty((), dtype=object)
    result[()] = value
    return result
1063611
def to_python(self, value):
        """"""
        if not value:
            return []
        return map(super(CommaSepFloatField, self).to_python, value.split(','))
1124959
def _get_array(val, shape, default=None, dtype=np.float64):
    """"""
    assert val is not None or default is not None
    if hasattr(val, '__len__') and len(val) == 0:  # pragma: no cover
        val = None
    # Do nothing if the array is already correct.
    if (isinstance(val, np.ndarray) and
            val.shape == shape and
            val.dtype == dtype):
        return val
    out = np.zeros(shape, dtype=dtype)
    # This solves `ValueError: could not broadcast input array from shape (n)
    # into shape (n, 1)`.
    if val is not None and isinstance(val, np.ndarray):
        if val.size == out.size:
            val = val.reshape(out.shape)
    out.flat[:] = val if val is not None else default
    assert out.shape == shape
    return out
790971
def fn_float(self, value):
        

        if is_ndarray(value) or isinstance(value, (list, tuple)):
            return self._to_ndarray(value).astype('float')
        else:
            return float(value)
79231
def to_python(self, value):
        """"""
        if value in self.empty_values:
            return ""
        value = force_text(value).strip()
        return value
921114
def _convert_to_array(array_like, dtype):
        
        if isinstance(array_like, bytes):
            return np.frombuffer(array_like, dtype=dtype)
        return np.asarray(array_like, dtype=dtype)
295003
def to_python(self, value):
        """"""
        if not value:
            return None

        if isinstance(value, list):
            for index, position_val in enumerate(value):
                val = super(MultipleDecimalField, self).to_python(position_val)
                value[index] = val

        return value
136780
def _value(obj):
    
    # TODO: this is ugly and makes everything ugly
    # can we handle this with a clean decorator or just requiring that only floats be passed??
    if hasattr(obj, 'value'):
        return obj.value
    elif isinstance(obj, np.ndarray):
        return np.array([o.value for o in obj])
    elif hasattr(obj, '__iter__'):
        return [_value(o) for o in obj]
    return obj
908516
def to_python(self, value):
        
        if not value:
            return {}
        elif isinstance(value, six.string_types):
            res = loads(value)
            assert isinstance(res, dict)
            return JSONDict(**res)
        else:
            return value
1098619
def native(self, value, context=None):
		""""""
		
		separator = self.separator.strip() if self.strip and hasattr(self.separator, 'strip') else self.separator
		value = super().native(value, context)
		
		if value is None:
			return self.cast()
		
		if hasattr(value, 'split'):
			value = value.split(separator)
		
		value = self._clean(value)
		
		try:
			return self.cast(value) if self.cast else value
		except Exception as e:
			raise Concern("{0} caught, failed to perform array transform: {1}", e.__class__.__name__, str(e))
1266090
def _as_array(self, fmt):
        ''''''
        assert self.dimensions, \
            '{}: cannot get value as {} array!'.format(self.name, fmt)
        elems = array.array(fmt)
        elems.fromstring(self.bytes)
        return np.array(elems).reshape(self.dimensions)
870753
def value_to_python(self, value):
        
        if not isinstance(value, bytes):
            raise tldap.exceptions.ValidationError("should be a bytes")
        value = value.decode("utf_8")
        return value
655524
def to_python(self, value=None):
        

        if value is None:
            return self.default

        if self.resolve:
            return self.resolve(value)
        return value
575373
def _array(group_idx, a, size, fill_value, dtype=None):
    """"""
    if fill_value is not None and not (np.isscalar(fill_value) or
                                       len(fill_value) == 0):
        raise ValueError("fill_value must be None, a scalar or an empty "
                         "sequence")
    order_group_idx = np.argsort(group_idx, kind='mergesort')
    counts = np.bincount(group_idx, minlength=size)
    ret = np.split(a[order_group_idx], np.cumsum(counts)[:-1])
    ret = np.asanyarray(ret)
    if fill_value is None or np.isscalar(fill_value):
        _fill_untouched(group_idx, ret, fill_value)
    return ret
1250686
def to_python(self, value):
        
        if isinstance(value, type(re.compile(''))):
            return value
        else:
            if value is None and self.null:
                return None
            else:
                try:
                    return self.get_compiled_regex(value)
                except:
                    raise ValidationError('Invalid regex {0}'.format(value))