From 493e762adc5c3f824dff612b700d5ae1f53b2f61 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 1 Apr 2015 20:40:46 +0300 Subject: [PATCH] PY-15296 Numpy: allow passing all sequence types for array and array-like parameters one can pass iterable instad of array and vice versa --- .../numpy/codeInsight/NumpyDocStringTypeProvider.java | 8 ++++---- .../com/jetbrains/numpy/documentation/NumPyDocString.java | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/python/src/com/jetbrains/numpy/codeInsight/NumpyDocStringTypeProvider.java b/python/src/com/jetbrains/numpy/codeInsight/NumpyDocStringTypeProvider.java index 8ad65b1633ae..75f5a2f42b52 100644 --- a/python/src/com/jetbrains/numpy/codeInsight/NumpyDocStringTypeProvider.java +++ b/python/src/com/jetbrains/numpy/codeInsight/NumpyDocStringTypeProvider.java @@ -43,10 +43,10 @@ public class NumpyDocStringTypeProvider extends PyTypeProviderBase { private static final Map NUMPY_ALIAS_TO_REAL_TYPE = new HashMap(); static { - NUMPY_ALIAS_TO_REAL_TYPE.put("ndarray", "numpy.core.multiarray.ndarray"); + NUMPY_ALIAS_TO_REAL_TYPE.put("ndarray", "numpy.core.multiarray.ndarray or collections.Iterable"); NUMPY_ALIAS_TO_REAL_TYPE.put("numpy.ndarray", "numpy.core.multiarray.ndarray"); // 184 occurrences - NUMPY_ALIAS_TO_REAL_TYPE.put("array_like", "collections.Iterable"); + NUMPY_ALIAS_TO_REAL_TYPE.put("array_like", "numpy.core.multiarray.ndarray or collections.Iterable"); // Parameters marked as 'data-type' actually get any Python type identifier such as 'bool' or // an instance of 'numpy.core.multiarray.dtype', however the type checker isn't able to check it. // 30 occurrences @@ -55,8 +55,8 @@ public class NumpyDocStringTypeProvider extends PyTypeProviderBase { // 16 occurrences NUMPY_ALIAS_TO_REAL_TYPE.put("scalar", "int or long or float or complex"); // 10 occurrences - NUMPY_ALIAS_TO_REAL_TYPE.put("array", "numpy.core.multiarray.ndarray"); - NUMPY_ALIAS_TO_REAL_TYPE.put("numpy.array", "numpy.core.multiarray.ndarray"); + NUMPY_ALIAS_TO_REAL_TYPE.put("array", "numpy.core.multiarray.ndarray or collections.Iterable"); + NUMPY_ALIAS_TO_REAL_TYPE.put("numpy.array", "numpy.core.multiarray.ndarray or collections.Iterable"); // 9 occurrences NUMPY_ALIAS_TO_REAL_TYPE.put("any", "object"); // 5 occurrences diff --git a/python/src/com/jetbrains/numpy/documentation/NumPyDocString.java b/python/src/com/jetbrains/numpy/documentation/NumPyDocString.java index 72ab80c195a0..42af2edf5bf4 100644 --- a/python/src/com/jetbrains/numpy/documentation/NumPyDocString.java +++ b/python/src/com/jetbrains/numpy/documentation/NumPyDocString.java @@ -283,10 +283,6 @@ public class NumPyDocString { if (index >= 0) { return typeString.substring(0, index); } - index = typeString.indexOf(" of "); // e.g. ndarray of dtype float - if (index >= 0) { - return typeString.substring(0, index); - } return typeString; }