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

Commit 213eccc

Browse files
author
Ivan Butygin
committed
style
1 parent 1847336 commit 213eccc

File tree

3 files changed

+86
-40
lines changed

3 files changed

+86
-40
lines changed

sdc/concurrent_hash.py

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
# *****************************************************************************
2+
# Copyright (c) 2020, Intel Corporation All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# Redistributions of source code must retain the above copyright notice,
8+
# this list of conditions and the following disclaimer.
9+
#
10+
# Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
18+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23+
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
# *****************************************************************************
26+
127
import numba
228
import sdc
329

@@ -10,15 +36,15 @@
1036
from . import hconcurrent_hash
1137
ll.add_symbol('create_int_hashmap', hconcurrent_hash.create_int_hashmap)
1238
ll.add_symbol('delete_int_hashmap', hconcurrent_hash.delete_int_hashmap)
13-
ll.add_symbol('addelem_int_hashmap',hconcurrent_hash.addelem_int_hashmap)
39+
ll.add_symbol('addelem_int_hashmap', hconcurrent_hash.addelem_int_hashmap)
1440

15-
ll.add_symbol('createiter_int_hashmap',hconcurrent_hash.createiter_int_hashmap)
16-
ll.add_symbol('enditer_int_hashmap',hconcurrent_hash.enditer_int_hashmap)
17-
ll.add_symbol('nextiter_int_hashmap',hconcurrent_hash.nextiter_int_hashmap)
18-
ll.add_symbol('iterkey_int_hashmap',hconcurrent_hash.iterkey_int_hashmap)
19-
ll.add_symbol('itersize_int_hashmap',hconcurrent_hash.itersize_int_hashmap)
20-
ll.add_symbol('iterelem_int_hashmap',hconcurrent_hash.iterelem_int_hashmap)
21-
ll.add_symbol('deleteiter_int_hashmap',hconcurrent_hash.deleteiter_int_hashmap)
41+
ll.add_symbol('createiter_int_hashmap', hconcurrent_hash.createiter_int_hashmap)
42+
ll.add_symbol('enditer_int_hashmap', hconcurrent_hash.enditer_int_hashmap)
43+
ll.add_symbol('nextiter_int_hashmap', hconcurrent_hash.nextiter_int_hashmap)
44+
ll.add_symbol('iterkey_int_hashmap', hconcurrent_hash.iterkey_int_hashmap)
45+
ll.add_symbol('itersize_int_hashmap', hconcurrent_hash.itersize_int_hashmap)
46+
ll.add_symbol('iterelem_int_hashmap', hconcurrent_hash.iterelem_int_hashmap)
47+
ll.add_symbol('deleteiter_int_hashmap', hconcurrent_hash.deleteiter_int_hashmap)
2248

2349
_create_int_hashmap = types.ExternalFunction("create_int_hashmap",
2450
types.voidptr())
@@ -46,42 +72,53 @@
4672
def create_int_hashmap():
4773
pass
4874

75+
4976
def delete_int_hashmap():
5077
pass
5178

79+
5280
def addelem_int_hashmap():
5381
pass
5482

5583

5684
def createiter_int_hashmap():
5785
pass
5886

87+
5988
def enditer_int_hashmap():
6089
pass
6190

91+
6292
def nextiter_int_hashmap():
6393
pass
6494

95+
6596
def iterkey_int_hashmap():
6697
pass
6798

99+
68100
def itersize_int_hashmap():
69101
pass
70102

103+
71104
def iterelem_int_hashmap():
72105
pass
73106

107+
74108
def deleteiter_int_hashmap():
75109
pass
76110

111+
77112
@overload(create_int_hashmap)
78113
def create_int_hashmap_overload():
79114
return lambda: _create_int_hashmap()
80115

116+
81117
@overload(delete_int_hashmap)
82118
def delete_int_hashmap_overload(h):
83119
return lambda h: _delete_int_hashmap(h)
84120

121+
85122
@overload(addelem_int_hashmap)
86123
def addelem_int_hashmap_overload(h, key, val):
87124
return lambda h, key, val: _addelem_int_hashmap(h, key, val)
@@ -91,26 +128,32 @@ def addelem_int_hashmap_overload(h, key, val):
91128
def createiter_int_hashmap_overload(h):
92129
return lambda h: _createiter_int_hashmap(h)
93130

131+
94132
@overload(enditer_int_hashmap)
95133
def enditer_int_hashmap_overload(h):
96134
return lambda h: _enditer_int_hashmap(h)
97135

136+
98137
@overload(nextiter_int_hashmap)
99138
def nextiter_int_hashmap_overload(h):
100139
return lambda h: _nextiter_int_hashmap(h)
101140

141+
102142
@overload(iterkey_int_hashmap)
103143
def iterkey_int_hashmap_overload(h):
104144
return lambda h: _iterkey_int_hashmap(h)
105145

146+
106147
@overload(itersize_int_hashmap)
107148
def itersize_int_hashmap_overload(h):
108149
return lambda h: _itersize_int_hashmap(h)
109150

151+
110152
@overload(iterelem_int_hashmap)
111153
def iterelem_int_hashmap_overload(h, i):
112154
return lambda h, i: _iterelem_int_hashmap(h, i)
113155

156+
114157
@overload(deleteiter_int_hashmap)
115158
def deleteiter_int_hashmap_overload(h):
116159
return lambda h: _deleteiter_int_hashmap(h)

sdc/tests/test_dataframe.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,14 +1793,15 @@ def test_impl():
17931793

17941794
def test_tbb(self):
17951795
import sdc.concurrent_hash
1796+
17961797
def test_impl():
17971798
h = sdc.concurrent_hash.create_int_hashmap()
17981799

1799-
sdc.concurrent_hash.addelem_int_hashmap(h,1,2)
1800-
sdc.concurrent_hash.addelem_int_hashmap(h,1,3)
1801-
sdc.concurrent_hash.addelem_int_hashmap(h,1,4)
1802-
sdc.concurrent_hash.addelem_int_hashmap(h,1,5)
1803-
sdc.concurrent_hash.addelem_int_hashmap(h,2,6)
1800+
sdc.concurrent_hash.addelem_int_hashmap(h, 1, 2)
1801+
sdc.concurrent_hash.addelem_int_hashmap(h, 1, 3)
1802+
sdc.concurrent_hash.addelem_int_hashmap(h, 1, 4)
1803+
sdc.concurrent_hash.addelem_int_hashmap(h, 1, 5)
1804+
sdc.concurrent_hash.addelem_int_hashmap(h, 2, 6)
18041805

18051806
it = sdc.concurrent_hash.createiter_int_hashmap(h)
18061807
while 0 == sdc.concurrent_hash.enditer_int_hashmap(it):

setup.py

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -198,35 +198,37 @@ def readme():
198198
if _has_opencv:
199199
_ext_mods.append(ext_cv_wrapper)
200200

201+
201202
# Copypaste from numba
202203
def check_file_at_path(path2file):
203-
"""
204-
Takes a list as a path, a single glob (*) is permitted as an entry which
205-
indicates that expansion at this location is required (i.e. version
206-
might not be known).
207-
"""
208-
found = None
209-
path2check = [os.path.split(os.path.split(sys.executable)[0])[0]]
210-
path2check += [os.getenv(n, '') for n in ['CONDA_PREFIX', 'PREFIX']]
211-
if sys.platform.startswith('win'):
212-
path2check += [os.path.join(p, 'Library') for p in path2check]
213-
for p in path2check:
214-
if p:
215-
if '*' in path2file:
216-
globloc = path2file.index('*')
217-
searchroot = os.path.join(*path2file[:globloc])
218-
try:
219-
potential_locs = os.listdir(os.path.join(p, searchroot))
220-
except BaseException:
221-
continue
222-
searchfor = path2file[globloc + 1:]
223-
for x in potential_locs:
224-
potpath = os.path.join(p, searchroot, x, *searchfor)
225-
if os.path.isfile(potpath):
226-
found = p # the latest is used
227-
elif os.path.isfile(os.path.join(p, *path2file)):
228-
found = p # the latest is used
229-
return found
204+
"""
205+
Takes a list as a path, a single glob (*) is permitted as an entry which
206+
indicates that expansion at this location is required (i.e. version
207+
might not be known).
208+
"""
209+
found = None
210+
path2check = [os.path.split(os.path.split(sys.executable)[0])[0]]
211+
path2check += [os.getenv(n, '') for n in ['CONDA_PREFIX', 'PREFIX']]
212+
if sys.platform.startswith('win'):
213+
path2check += [os.path.join(p, 'Library') for p in path2check]
214+
for p in path2check:
215+
if p:
216+
if '*' in path2file:
217+
globloc = path2file.index('*')
218+
searchroot = os.path.join(*path2file[:globloc])
219+
try:
220+
potential_locs = os.listdir(os.path.join(p, searchroot))
221+
except BaseException:
222+
continue
223+
searchfor = path2file[globloc + 1:]
224+
for x in potential_locs:
225+
potpath = os.path.join(p, searchroot, x, *searchfor)
226+
if os.path.isfile(potpath):
227+
found = p # the latest is used
228+
elif os.path.isfile(os.path.join(p, *path2file)):
229+
found = p # the latest is used
230+
return found
231+
230232

231233
# Search for Intel TBB, first check env var TBBROOT then conda locations
232234
tbb_root = os.getenv('TBBROOT')

0 commit comments

Comments
 (0)