Skip to content

Commit

Permalink
Add new dependences versions for develop (backport #914) (#958)
Browse files Browse the repository at this point in the history
* 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 <pavel.yakovlev@intel.com>
  • Loading branch information
mergify[bot] and Pahandrovich committed Feb 1, 2022
1 parent 5394f16 commit e0185a2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion generator/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def __init__(self, name, typ, const, dflt, inpt, algo, doc):
# they are passed as (ptr, dim1, dim2)
if typ_cy == 'data_or_file':
decl_c = "double* {0}_p, size_t {0}_nrows,"\
" size_t {0}_ncols, ssize_t {0}_layout".format(d4pname)
" size_t {0}_ncols, Py_ssize_t {0}_layout".format(d4pname)
arg_c = "data_or_file({0}_p, {0}_ncols,"\
" {0}_nrows, {0}_layout)".format(d4pname)
# default values (see above pydefaults)
Expand Down
8 changes: 5 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Cython==0.29.24
Jinja2==3.0.2
Cython==0.29.24 ; python_version <= '3.9'
Cython==0.29.25 ; python_version >= '3.10'
Jinja2==3.0.3
numpy==1.19.2 ; python_version <= '3.8'
numpy==1.19.3 ; python_version >= '3.9'
numpy==1.19.3 ; python_version == '3.9'
numpy==1.21.3 ; python_version >= '3.10'
pybind11==2.8.0
cmake==3.21.3
2 changes: 1 addition & 1 deletion src/daal4py.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ struct data_or_file
mutable daal::data_management::NumericTablePtr table;
std::string file;
template<typename T>
inline data_or_file(T * ptr, size_t ncols, size_t nrows, ssize_t layout)
inline data_or_file(T * ptr, size_t ncols, size_t nrows, Py_ssize_t layout)
: table(), file()
{
if(layout > 0) throw std::invalid_argument("Supporting only homogeneous, contiguous arrays.");
Expand Down
8 changes: 4 additions & 4 deletions src/gettree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ cdef extern from "daal4py.h":

cdef extern from "tree_visitor.h":
cdef struct skl_tree_node:
ssize_t left_child
ssize_t right_child
ssize_t feature
Py_ssize_t left_child
Py_ssize_t right_child
Py_ssize_t feature
double threshold
double impurity
ssize_t n_node_samples
Py_ssize_t n_node_samples
double weighted_n_node_samples

cdef struct TreeState:
Expand Down
16 changes: 8 additions & 8 deletions src/tree_visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
// cython will convert this struct into an numpy structured array
// This is the layout that sklearn expects for its tree traversal mechanics
struct skl_tree_node {
ssize_t left_child;
ssize_t right_child;
ssize_t feature;
Py_ssize_t left_child;
Py_ssize_t right_child;
Py_ssize_t feature;
double threshold;
double impurity;
ssize_t n_node_samples;
Py_ssize_t n_node_samples;
double weighted_n_node_samples;

skl_tree_node()
Expand Down Expand Up @@ -128,7 +128,7 @@ class toSKLearnTreeObjectVisitor : public TNVT<M>::visitor_type, public TreeStat

size_t node_id;
size_t max_n_classes;
std::vector<ssize_t> parents;
std::vector<Py_ssize_t> parents;
};

// This is the function for getting the tree state from a forest which we use in cython
Expand Down Expand Up @@ -199,7 +199,7 @@ bool NodeDepthCountNodeVisitor<M>::onSplitNode(const typename TNVT<M>::split_des
template<typename M>
toSKLearnTreeObjectVisitor<M>::toSKLearnTreeObjectVisitor(size_t _depth, size_t _n_nodes, size_t _n_leafs, size_t _max_n_classes)
: node_id(0),
parents(arange<ssize_t>(-1, _depth-1))
parents(arange<Py_ssize_t>(-1, _depth-1))
{
max_n_classes = _max_n_classes;
node_count = _n_nodes;
Expand All @@ -216,7 +216,7 @@ bool toSKLearnTreeObjectVisitor<M>::onSplitNode(const typename TNVT<M>::split_de
{
if(desc.level > 0) {
// has parents
ssize_t parent = parents[desc.level - 1];
Py_ssize_t parent = parents[desc.level - 1];
if(node_ar[parent].left_child > 0) {
assert(node_ar[node_id].right_child < 0);
node_ar[parent].right_child = node_id;
Expand Down Expand Up @@ -254,7 +254,7 @@ template<typename M>
bool toSKLearnTreeObjectVisitor<M>::_onLeafNode(const daal::algorithms::tree_utils::NodeDescriptor &desc)
{
if(desc.level) {
ssize_t parent = parents[desc.level - 1];
Py_ssize_t parent = parents[desc.level - 1];
if(node_ar[parent].left_child > 0) {
assert(node_ar[node_id].right_child < 0);
node_ar[parent].right_child = node_id;
Expand Down

0 comments on commit e0185a2

Please sign in to comment.