2525# *****************************************************************************
2626
2727from numba .core .imputils import lower_constant
28- from numba .core import cgutils
28+ from numba .core import cgutils , types
2929
3030from .types import SeriesType
31+ from sdc .datatypes .indexes .positional_index_type import PositionalIndexType
32+ from sdc .hiframes .boxing import _unbox_index_data
33+ from sdc .extensions .indexes .range_index_ext import unbox_range_index
34+ from sdc .datatypes .indexes .range_index_type import RangeIndexDataType
3135
3236
3337@lower_constant (SeriesType )
@@ -39,7 +43,21 @@ def constant_Series(context, builder, ty, pyval):
3943 """
4044 series = cgutils .create_struct_proxy (ty )(context , builder )
4145 series .data = _constant_Series_data (context , builder , ty , pyval )
42- # TODO: index and name
46+
47+ # TODO: index and name (this only handles PositionalIndexType(False)
48+ # and repeats unboxing, need to refactor to support all indexes)
49+ native_range_index = cgutils .create_struct_proxy (RangeIndexDataType )(context , builder )
50+ native_range_index .start = context .get_constant (types .int64 , pyval .index .start )
51+ native_range_index .stop = context .get_constant (types .int64 , pyval .index .stop )
52+ native_range_index .step = context .get_constant (types .int64 , pyval .index .step )
53+
54+ range_index = cgutils .create_struct_proxy (ty .index .data )(context , builder )
55+ range_index .data = native_range_index ._getvalue ()
56+
57+ positional_index = cgutils .create_struct_proxy (PositionalIndexType (False ))(context , builder )
58+ positional_index .data = range_index ._getvalue ()
59+
60+ series .index = positional_index ._getvalue ()
4361 return series ._getvalue ()
4462
4563
@@ -52,7 +70,11 @@ def _constant_Series_data(context, builder, ty, pyval):
5270
5371 from ..categorical .types import CategoricalDtypeType
5472
55- if isinstance (ty .dtype , CategoricalDtypeType ):
73+ # TO-DO: this requires lower_constant to be implemented for other types
74+ # like indices and so on, until that raise NotImplementedError
75+ if (isinstance (ty .dtype , CategoricalDtypeType )
76+ and ty .index is PositionalIndexType (False )
77+ and ty .is_named is False ):
5678 from ..categorical .boxing import constant_Categorical
5779 return constant_Categorical (context , builder , ty .data , pyval .array )
5880
0 commit comments