@@ -11,13 +11,8 @@ WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in
11
11
12
12
{{py:
13
13
14
- # by_dtype, table_type, init_table, s1, s2, s3, g1, g2
15
- by_dtypes = [('int64_t', 'Int64HashTable', 'Int64HashTable(right_size)',
16
- '.set_item(', ', ', ')',
17
- '.get_item(', ')'),
18
- ('object', 'dict', '{}',
19
- '[', '] = ', '',
20
- '[', ']')]
14
+ # table_type, by_dtype
15
+ by_dtypes = [('PyObjectHashTable', 'object'), ('Int64HashTable', 'int64_t')]
21
16
22
17
# on_dtype
23
18
on_dtypes = ['uint8_t', 'uint16_t', 'uint32_t', 'uint64_t',
@@ -29,7 +24,7 @@ on_dtypes = ['uint8_t', 'uint16_t', 'uint32_t', 'uint64_t',
29
24
30
25
from hashtable cimport *
31
26
32
- {{for by_dtype, table_type, init_table, s1, s2, s3, g1, g2 in by_dtypes}}
27
+ {{for table_type, by_dtype in by_dtypes}}
33
28
{{for on_dtype in on_dtypes}}
34
29
35
30
@@ -59,7 +54,7 @@ def asof_join_{{on_dtype}}_by_{{by_dtype}}(ndarray[{{on_dtype}}] left_values,
59
54
left_indexer = np.empty(left_size, dtype=np.int64)
60
55
right_indexer = np.empty(left_size, dtype=np.int64)
61
56
62
- hash_table = {{init_table}}
57
+ hash_table = {{table_type}}(right_size)
63
58
64
59
right_pos = 0
65
60
for left_pos in range(left_size):
@@ -71,18 +66,18 @@ def asof_join_{{on_dtype}}_by_{{by_dtype}}(ndarray[{{on_dtype}}] left_values,
71
66
if allow_exact_matches:
72
67
while right_pos < right_size and\
73
68
right_values[right_pos] <= left_values[left_pos]:
74
- hash_table{{s1}} right_by_values[right_pos]{{s2}} right_pos{{s3}}
69
+ hash_table.set_item( right_by_values[right_pos], right_pos)
75
70
right_pos += 1
76
71
else:
77
72
while right_pos < right_size and\
78
73
right_values[right_pos] < left_values[left_pos]:
79
- hash_table{{s1}} right_by_values[right_pos]{{s2}} right_pos{{s3}}
74
+ hash_table.set_item( right_by_values[right_pos], right_pos)
80
75
right_pos += 1
81
76
right_pos -= 1
82
77
83
78
# save positions as the desired index
84
79
by_value = left_by_values[left_pos]
85
- found_right_pos = hash_table{{g1}} by_value{{g2}} \
80
+ found_right_pos = hash_table.get_item( by_value) \
86
81
if by_value in hash_table else -1
87
82
left_indexer[left_pos] = left_pos
88
83
right_indexer[left_pos] = found_right_pos
0 commit comments