This repository was archived by the owner on Feb 2, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2838,8 +2838,8 @@ def hpat_pandas_series_sum_impl(
28382838 _skipna = skipna
28392839
28402840 if _skipna :
2841- return numpy .nansum (self ._data )
2842- return numpy .sum (self ._data )
2841+ return numpy_like .nansum (self ._data )
2842+ return numpy_like .sum (self ._data )
28432843
28442844 return hpat_pandas_series_sum_impl
28452845
Original file line number Diff line number Diff line change @@ -201,6 +201,19 @@ def sdc_isnan_float_impl(self):
201201 ty_checker .raise_exc (dtype , 'int or float' , 'self.dtype' )
202202
203203
204+ def gen_sum_bool_impl ():
205+ """Generate sum bool implementation."""
206+ def _sum_bool_impl (self ):
207+ length = len (self )
208+ result = 0
209+ for i in prange (length ):
210+ result += self [i ]
211+
212+ return result
213+
214+ return _sum_bool_impl
215+
216+
204217@sdc_overload (sum )
205218def sdc_sum_overload (self ):
206219 """
@@ -230,9 +243,12 @@ def sdc_sum_number_impl(self):
230243
231244 return sdc_sum_number_impl
232245
246+ if isinstance (dtype , (types .Boolean , bool )):
247+ return gen_sum_bool_impl ()
248+
233249
234250@sdc_overload (nansum )
235- def sdc_sum_overload (self ):
251+ def sdc_nansum_overload (self ):
236252 """
237253 Intel Scalable Dataframe Compiler Developer Guide
238254 *************************************************
@@ -258,6 +274,9 @@ def sdc_nansum_number_impl(self):
258274
259275 return sdc_nansum_number_impl
260276
277+ if isinstance (dtype , (types .Boolean , bool )):
278+ return gen_sum_bool_impl ()
279+
261280
262281def nanmin (a ):
263282 pass
Original file line number Diff line number Diff line change @@ -2319,6 +2319,14 @@ def test_impl(S):
23192319 S = pd .Series ([1. , 2. , 3. ])
23202320 self .assertEqual (hpat_func (S ), test_impl (S ))
23212321
2322+ def test_series_sum_bool (self ):
2323+ def test_impl (S ):
2324+ return S .sum ()
2325+ hpat_func = self .jit (test_impl )
2326+
2327+ S = pd .Series ([True , True , False ])
2328+ self .assertEqual (hpat_func (S ), test_impl (S ))
2329+
23222330 def test_series_sum_nan (self ):
23232331 def test_impl (S ):
23242332 return S .sum ()
You can’t perform that action at this time.
0 commit comments