Commit 65975169 authored by Pierre Augier's avatar Pierre Augier
Browse files

[][] -> [:, :] and ndim=0

parent 029e50eccef1
......@@ -8,6 +8,7 @@ N = NDim(1, 3)
A = Array[T, N]
A1 = Array[np.float32, N + 1]
A3d = Array[np.float32, "3d"]
N1 = NDim(4, 5)
N1 = NDim(4, 5)
......
......@@ -271,10 +271,10 @@ class ArrayMeta(type):
if dtype is None or ndim is None:
raise ValueError
base = f"{dtype.__name__}"
if ndim == 0:
raise NotImplementedError
return f"{dtype.__name__}[{', '.join([':']*ndim)}]"
return base
return base + f"[{', '.join([':']*ndim)}]"
class Array(metaclass=ArrayMeta):
......@@ -295,6 +295,20 @@ def compute_pythran_types_from_types(types, **kwargs):
pythran_type = type_.__name__
else:
pythran_type = str(type_)
types = pythran_type.split(" or ")
new_types = []
for _type in types:
if "][" in _type:
# C style: we try to rewrite it in Cython style
base, dims = _type.split("[", 1)
dims = ", ".join(
[_ or ":" for _ in dims[:-1].split("][")]
)
_type = base + "[" + dims + "]"
elif _type.endswith("[]"):
_type = _type[:-2] + "[:]"
new_types.append(_type)
pythran_type = " or ".join(new_types)
pythran_types.append(pythran_type)
......
......@@ -18,7 +18,7 @@ def func():
@cachedjit
def func1(a, l):
def func1(a: "int[][] or float[]", l: list):
tmp = np.exp(sum(l))
result = tmp * a * func0(a) + func()
return result
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment