Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit ee80555

Browse files
Migrating to Numba 0.51.2 (#926)
1 parent 811e9f0 commit ee80555

9 files changed

Lines changed: 36 additions & 18 deletions

File tree

conda-recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set NUMBA_VERSION = "==0.50.1" %}
1+
{% set NUMBA_VERSION = "==0.51.2" %}
22
{% set PANDAS_VERSION = "==1.0.5" %}
33
{% set PYARROW_VERSION = "==0.17.0" %}
44

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
numpy>=1.16
22
pandas==0.25.3
33
pyarrow==0.17.0
4-
numba==0.50.1
4+
numba==0.51.2
55
tbb
66
tbb-devel

sdc/datatypes/hpat_pandas_dataframe_getitem_types.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from numba.extending import models, overload, register_model, make_attribute_wrapper, intrinsic
3333
from numba.core.datamodel import register_default, StructModel
3434
from numba.core.typing.templates import signature
35+
from sdc.hiframes.pd_dataframe_type import DataFrameType
3536

3637

3738
class DataFrameGetitemAccessorType(types.Type):
@@ -56,6 +57,11 @@ def __init__(self, dmm, fe_type):
5657

5758
@intrinsic
5859
def dataframe_getitem_accessor_init(typingctx, dataframe, accessor):
60+
61+
if not (isinstance(dataframe, DataFrameType)
62+
and isinstance(accessor, types.StringLiteral)):
63+
return None, None
64+
5965
def dataframe_getitem_accessor_init_codegen(context, builder, signature, args):
6066
dataframe_val, accessor_val = args
6167
getitem_accessor = cgutils.create_struct_proxy(

sdc/datatypes/hpat_pandas_getitem_types.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from numba.extending import (models, overload, register_model, make_attribute_wrapper, intrinsic)
3333
from numba.core.datamodel import (register_default, StructModel)
3434
from numba.core.typing.templates import signature
35+
from sdc.hiframes.pd_series_type import SeriesType
3536

3637

3738
class SeriesGetitemAccessorType(types.Type):
@@ -56,6 +57,11 @@ def __init__(self, dmm, fe_type):
5657

5758
@intrinsic
5859
def series_getitem_accessor_init(typingctx, series, accessor):
60+
61+
if not (isinstance(series, SeriesType)
62+
and isinstance(accessor, types.StringLiteral)):
63+
return None, None
64+
5965
def series_getitem_accessor_init_codegen(context, builder, signature, args):
6066
series_val, accessor_val = args
6167
getitem_accessor = cgutils.create_struct_proxy(

sdc/datatypes/hpat_pandas_series_functions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,7 @@ def hpat_pandas_series_len_impl(self):
18281828
return hpat_pandas_series_len_impl
18291829

18301830

1831-
@sdc_overload_method(SeriesType, 'astype', parallel=False)
1831+
@sdc_overload_method(SeriesType, 'astype')
18321832
def hpat_pandas_series_astype(self, dtype, copy=True, errors='raise'):
18331833
"""
18341834
Intel Scalable Dataframe Compiler User Guide
@@ -1885,6 +1885,9 @@ def hpat_pandas_series_astype(self, dtype, copy=True, errors='raise'):
18851885
if not isinstance(copy, (types.Omitted, bool, types.Boolean)):
18861886
ty_checker.raise_exc(copy, 'bool', 'copy')
18871887

1888+
if not (isinstance(dtype, (types.functions.NumberClass, types.Function, types.StringLiteral))):
1889+
return None
1890+
18881891
if (not isinstance(errors, (types.Omitted, str, types.UnicodeType, types.StringLiteral)) and
18891892
errors in ('raise', 'ignore')):
18901893
ty_checker.raise_exc(errors, 'str', 'errors')

sdc/functions/numpy_like.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,14 @@ def sdc_astype_overload(self, dtype):
123123
if not isinstance(self, (types.Array, StringArrayType, RangeIndexType)):
124124
return None
125125

126-
if not isinstance(dtype, (types.functions.NumberClass, types.Function, types.Literal)):
126+
accepted_dtype_types = (types.functions.NumberClass, types.Function, types.StringLiteral)
127+
if not isinstance(dtype, accepted_dtype_types):
127128
def impl(self, dtype):
128129
return literally(dtype)
129130

130131
return impl
131132

132-
if not isinstance(dtype, (types.StringLiteral, types.UnicodeType, types.Function, types.functions.NumberClass)):
133+
if not isinstance(dtype, accepted_dtype_types):
133134
ty_checker.raise_exc(dtype, 'string or type', 'dtype')
134135

135136
if (
@@ -533,13 +534,13 @@ def sdc_fillna_overload(self, inplace=False, value=None):
533534
if not isinstance(self, (types.Array, StringArrayType)):
534535
return None
535536

537+
if not isinstance(inplace, (types.Literal, types.Omitted) or inplace is False):
538+
return None
539+
536540
dtype = self.dtype
537541
isnan = get_isnan(dtype)
538542

539-
if (
540-
(isinstance(inplace, types.Literal) and inplace.literal_value == True) or # noqa
541-
(isinstance(inplace, bool) and inplace == True) # noqa
542-
):
543+
if (isinstance(inplace, types.Literal) and inplace.literal_value is True):
543544

544545
def sdc_fillna_inplace_noop(self, inplace=False, value=None):
545546
return None

sdc/tests/test_series.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,6 @@ def test_impl(A):
810810
S = pd.Series(['3.24', '1E+05', '-1', '-1.3E-01', 'nan', 'inf'])
811811
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
812812

813-
@skip_parallel
814813
@skip_inline
815814
def test_series_astype_str_index_str(self):
816815
"""Verifies Series.astype implementation with function 'str' as argument
@@ -824,7 +823,6 @@ def test_impl(S):
824823
S = pd.Series(['aa', 'bb', 'cc'], index=['a', 'b', 'c'])
825824
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
826825

827-
@skip_parallel
828826
@skip_inline
829827
def test_series_astype_str_index_int(self):
830828
"""Verifies Series.astype implementation with function 'str' as argument

sdc/utilities/utils.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,13 @@ def update_jit_options(jit_options, parallel, config_flag):
624624
return jit_options
625625

626626

627-
def sdc_overload(func, jit_options={}, parallel=None, strict=True, inline=None):
627+
def sdc_overload(func, jit_options={}, parallel=None, strict=True, inline=None, prefer_literal=True):
628628
jit_options = update_jit_options(jit_options, parallel, config_use_parallel_overloads)
629629

630630
if inline is None:
631631
inline = 'always' if config_inline_overloads else 'never'
632632

633-
return overload(func, jit_options=jit_options, strict=strict, inline=inline)
633+
return overload(func, jit_options=jit_options, strict=strict, inline=inline, prefer_literal=prefer_literal)
634634

635635

636636
def patched_register_jitable(*args, **kwargs):
@@ -666,19 +666,23 @@ def wrap(fn):
666666
return wrap(*args)
667667

668668

669-
def sdc_overload_method(typ, name, jit_options={}, parallel=None, strict=True, inline=None):
669+
def sdc_overload_method(typ, name, jit_options={}, parallel=None, strict=True, inline=None, prefer_literal=True):
670670
jit_options = update_jit_options(jit_options, parallel, config_use_parallel_overloads)
671671

672672
if inline is None:
673673
inline = 'always' if config_inline_overloads else 'never'
674674

675-
return overload_method(typ, name, jit_options=jit_options, strict=strict, inline=inline)
675+
return overload_method(
676+
typ, name, jit_options=jit_options, strict=strict, inline=inline, prefer_literal=prefer_literal
677+
)
676678

677679

678-
def sdc_overload_attribute(typ, name, jit_options={}, parallel=None, strict=True, inline=None):
680+
def sdc_overload_attribute(typ, name, jit_options={}, parallel=None, strict=True, inline=None, prefer_literal=True):
679681
jit_options = update_jit_options(jit_options, parallel, config_use_parallel_overloads)
680682

681683
if inline is None:
682684
inline = 'always' if config_inline_overloads else 'never'
683685

684-
return overload_attribute(typ, name, jit_options=jit_options, strict=strict, inline=inline)
686+
return overload_attribute(
687+
typ, name, jit_options=jit_options, strict=strict, inline=inline, prefer_literal=prefer_literal
688+
)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def run(self):
375375
'numpy>=1.16',
376376
'pandas>=1.0',
377377
'pyarrow==0.17.0',
378-
'numba>=0.50.1,<0.51',
378+
'numba>=0.51.2,<0.52',
379379
'tbb'
380380
],
381381
cmdclass=sdc_build_commands,

0 commit comments

Comments
 (0)