Skip to content

Commit 311467c

Browse files
committed
Literal: fix Cython + better names for fused types
1 parent bf659f1 commit 311467c

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

data_tests/saved__backend__/cython/default_params.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import cython
33
import numpy as np
44
cimport numpy as np
55

6-
ctypedef fused __func__Unionstr_None:
6+
ctypedef fused __func__Union_str_None:
77
cython.str
88

9-
cpdef func(cython.int a=*, __func__Unionstr_None b=*, cython.float c=*)
9+
cpdef func(cython.int a=*, __func__Union_str_None b=*, cython.float c=*)

data_tests/saved__backend__/cython/literal_with_types.pxd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,10 @@ import cython
33
import numpy as np
44
cimport numpy as np
55

6-
cpdef gen_seq(Literal dtype, Literal seq_type, cython.int n)
6+
ctypedef fused __gen_seq__Literal_int_float:
7+
object
8+
9+
ctypedef fused __gen_seq__Literal_list_set:
10+
object
11+
12+
cpdef gen_seq(__gen_seq__Literal_int_float dtype, __gen_seq__Literal_list_set seq_type, cython.int n)

data_tests/saved__backend__/cython/type_hint_notemplate.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ ctypedef fused __compute__TypeIint_complex128I:
1313
cython.int
1414
np.complex128_t
1515

16-
ctypedef fused __compute__UnionArray_TypeIint_complex128I_NDimI1_3I_Array_float32_NDimI1_3Ip1:
16+
ctypedef fused __compute__Union_Array_TypeIint_complex128I_NDimI1_3I_Array_float32_NDimI1_3Ip1:
1717
np.ndarray[np.complex128_t, ndim=1]
1818
np.ndarray[np.complex128_t, ndim=3]
1919
np.ndarray[np.float32_t, ndim=2]
2020
np.ndarray[np.float32_t, ndim=4]
2121
np.ndarray[np.int32_t, ndim=1]
2222
np.ndarray[np.int32_t, ndim=3]
2323

24-
cpdef compute(__compute__Array_TypeIint_complex128I_NDimI1_3I a, __compute__Array_TypeIint_complex128I_NDimI1_3I b, __compute__TypeIint_complex128I c, __compute__UnionArray_TypeIint_complex128I_NDimI1_3I_Array_float32_NDimI1_3Ip1 d, cython.str e)
24+
cpdef compute(__compute__Array_TypeIint_complex128I_NDimI1_3I a, __compute__Array_TypeIint_complex128I_NDimI1_3I b, __compute__TypeIint_complex128I c, __compute__Union_Array_TypeIint_complex128I_NDimI1_3I_Array_float32_NDimI1_3Ip1 d, cython.str e)

src/transonic/backends/cython.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ def make_tuple_code(self, types, **kwargs):
7979
def make_const_code(self, code):
8080
return "const " + code
8181

82+
def make_literal_type_code(self, type_, **kwargs):
83+
return "object"
84+
8285

8386
def memoryview_type(dtype, ndim, mem_layout) -> str:
8487
ndim_F = 0

src/transonic/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ def __getitem__(self, types):
622622
self._name_target_class = target_class.__name__
623623

624624
return type(
625-
self._name_target_class + "_".join(short_repr),
625+
self._name_target_class + "_" + "_".join(short_repr),
626626
(target_class,),
627627
{"types": types, "template_var": template_var},
628628
)

0 commit comments

Comments
 (0)