Author: Ronan Lamy <ronan.l...@gmail.com> Branch: fix-result-types Changeset: r77471:2cddaf2f9154 Date: 2015-05-22 03:48 +0100 http://bitbucket.org/pypy/pypy/changeset/2cddaf2f9154/
Log: kill find_dtype_for_scalar() diff --git a/pypy/module/micronumpy/casting.py b/pypy/module/micronumpy/casting.py --- a/pypy/module/micronumpy/casting.py +++ b/pypy/module/micronumpy/casting.py @@ -322,7 +322,3 @@ elif space.isinstance_w(w_obj, space.w_str): return variable_dtype(space, 'S%d' % space.len_w(w_obj)) return object_dtype - -def find_dtype_for_scalar(space, w_obj, current_guess=None): - dtype = scalar2dtype(space, w_obj) - return find_binop_result_dtype(space, dtype, current_guess) diff --git a/pypy/module/micronumpy/strides.py b/pypy/module/micronumpy/strides.py --- a/pypy/module/micronumpy/strides.py +++ b/pypy/module/micronumpy/strides.py @@ -220,22 +220,22 @@ batch = new_batch +def _dtype_guess(space, dtype, w_elem): + from .casting import scalar2dtype, find_binop_result_dtype + if isinstance(w_elem, W_NDimArray) and w_elem.is_scalar(): + w_elem = w_elem.get_scalar_value() + elem_dtype = scalar2dtype(space, w_elem) + return find_binop_result_dtype(space, elem_dtype, dtype) + def find_dtype_for_seq(space, elems_w, dtype): - from pypy.module.micronumpy.casting import find_dtype_for_scalar if len(elems_w) == 1: w_elem = elems_w[0] - if isinstance(w_elem, W_NDimArray) and w_elem.is_scalar(): - w_elem = w_elem.get_scalar_value() - return find_dtype_for_scalar(space, w_elem, dtype) + return _dtype_guess(space, dtype, w_elem) return _find_dtype_for_seq(space, elems_w, dtype) - def _find_dtype_for_seq(space, elems_w, dtype): - from pypy.module.micronumpy.casting import find_dtype_for_scalar for w_elem in elems_w: - if isinstance(w_elem, W_NDimArray) and w_elem.is_scalar(): - w_elem = w_elem.get_scalar_value() - dtype = find_dtype_for_scalar(space, w_elem, dtype) + dtype = _dtype_guess(space, dtype, w_elem) return dtype _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit