Skip to content

Commit e0185a2

Browse files
Add new dependences versions for develop (backport #914) (#958)
* Add new dependences versions for develop (support python 3.10) (#914) (cherry picked from commit 7ab09b6) # Conflicts: # requirements-dev.txt * resolve conflicts Co-authored-by: Pavel Yakovlev <[email protected]>
1 parent 5394f16 commit e0185a2

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

generator/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def __init__(self, name, typ, const, dflt, inpt, algo, doc):
163163
# they are passed as (ptr, dim1, dim2)
164164
if typ_cy == 'data_or_file':
165165
decl_c = "double* {0}_p, size_t {0}_nrows,"\
166-
" size_t {0}_ncols, ssize_t {0}_layout".format(d4pname)
166+
" size_t {0}_ncols, Py_ssize_t {0}_layout".format(d4pname)
167167
arg_c = "data_or_file({0}_p, {0}_ncols,"\
168168
" {0}_nrows, {0}_layout)".format(d4pname)
169169
# default values (see above pydefaults)

requirements-dev.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
Cython==0.29.24
2-
Jinja2==3.0.2
1+
Cython==0.29.24 ; python_version <= '3.9'
2+
Cython==0.29.25 ; python_version >= '3.10'
3+
Jinja2==3.0.3
34
numpy==1.19.2 ; python_version <= '3.8'
4-
numpy==1.19.3 ; python_version >= '3.9'
5+
numpy==1.19.3 ; python_version == '3.9'
6+
numpy==1.21.3 ; python_version >= '3.10'
57
pybind11==2.8.0
68
cmake==3.21.3

src/daal4py.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ struct data_or_file
171171
mutable daal::data_management::NumericTablePtr table;
172172
std::string file;
173173
template<typename T>
174-
inline data_or_file(T * ptr, size_t ncols, size_t nrows, ssize_t layout)
174+
inline data_or_file(T * ptr, size_t ncols, size_t nrows, Py_ssize_t layout)
175175
: table(), file()
176176
{
177177
if(layout > 0) throw std::invalid_argument("Supporting only homogeneous, contiguous arrays.");

src/gettree.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ cdef extern from "daal4py.h":
3131

3232
cdef extern from "tree_visitor.h":
3333
cdef struct skl_tree_node:
34-
ssize_t left_child
35-
ssize_t right_child
36-
ssize_t feature
34+
Py_ssize_t left_child
35+
Py_ssize_t right_child
36+
Py_ssize_t feature
3737
double threshold
3838
double impurity
39-
ssize_t n_node_samples
39+
Py_ssize_t n_node_samples
4040
double weighted_n_node_samples
4141

4242
cdef struct TreeState:

src/tree_visitor.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
// cython will convert this struct into an numpy structured array
3030
// This is the layout that sklearn expects for its tree traversal mechanics
3131
struct skl_tree_node {
32-
ssize_t left_child;
33-
ssize_t right_child;
34-
ssize_t feature;
32+
Py_ssize_t left_child;
33+
Py_ssize_t right_child;
34+
Py_ssize_t feature;
3535
double threshold;
3636
double impurity;
37-
ssize_t n_node_samples;
37+
Py_ssize_t n_node_samples;
3838
double weighted_n_node_samples;
3939

4040
skl_tree_node()
@@ -128,7 +128,7 @@ class toSKLearnTreeObjectVisitor : public TNVT<M>::visitor_type, public TreeStat
128128

129129
size_t node_id;
130130
size_t max_n_classes;
131-
std::vector<ssize_t> parents;
131+
std::vector<Py_ssize_t> parents;
132132
};
133133

134134
// This is the function for getting the tree state from a forest which we use in cython
@@ -199,7 +199,7 @@ bool NodeDepthCountNodeVisitor<M>::onSplitNode(const typename TNVT<M>::split_des
199199
template<typename M>
200200
toSKLearnTreeObjectVisitor<M>::toSKLearnTreeObjectVisitor(size_t _depth, size_t _n_nodes, size_t _n_leafs, size_t _max_n_classes)
201201
: node_id(0),
202-
parents(arange<ssize_t>(-1, _depth-1))
202+
parents(arange<Py_ssize_t>(-1, _depth-1))
203203
{
204204
max_n_classes = _max_n_classes;
205205
node_count = _n_nodes;
@@ -216,7 +216,7 @@ bool toSKLearnTreeObjectVisitor<M>::onSplitNode(const typename TNVT<M>::split_de
216216
{
217217
if(desc.level > 0) {
218218
// has parents
219-
ssize_t parent = parents[desc.level - 1];
219+
Py_ssize_t parent = parents[desc.level - 1];
220220
if(node_ar[parent].left_child > 0) {
221221
assert(node_ar[node_id].right_child < 0);
222222
node_ar[parent].right_child = node_id;
@@ -254,7 +254,7 @@ template<typename M>
254254
bool toSKLearnTreeObjectVisitor<M>::_onLeafNode(const daal::algorithms::tree_utils::NodeDescriptor &desc)
255255
{
256256
if(desc.level) {
257-
ssize_t parent = parents[desc.level - 1];
257+
Py_ssize_t parent = parents[desc.level - 1];
258258
if(node_ar[parent].left_child > 0) {
259259
assert(node_ar[node_id].right_child < 0);
260260
node_ar[parent].right_child = node_id;

0 commit comments

Comments
 (0)