Repository: automl/random_forest_run (language: python)

Issue:
Expose more information to python functions
Additional RF components (trees, nodes, and splits) are now exposed to the python functions and thus more interactions are allowed


Discussion / hints:
I updated the PR with your comment, I'll later add some tests accordingly

Fix patch:
diff --git a/pyrfr/pyrfr/regression.i b/pyrfr/pyrfr/regression.i
index 0570778..30f15de 100644
--- a/pyrfr/pyrfr/regression.i
+++ b/pyrfr/pyrfr/regression.i
@@ -29,17 +29,19 @@ typedef rfr::nodes::k_ary_node_full<2, rfr::splits::binary_split_one_feature_rss
 typedef rfr::nodes::k_ary_mondrian_node_full<2, num_t, response_t, index_t, rng_t> binary_mondrian_node_t;
 
 typedef rfr::trees::k_ary_random_tree<2, binary_full_node_rss_t, num_t, response_t, index_t, rng_t> binary_full_tree_rss_t;
+typedef rfr::trees::k_ary_random_tree<2, binary_full_node_rss_t, num_t, response_t, index_t, rng_t> binary_full_tree_rss_t_;
 typedef rfr::trees::k_ary_mondrian_tree<2, binary_mondrian_node_t, num_t, response_t, index_t, rng_t> binary_mondrian_tree_t;
 typedef rfr::trees::binary_fANOVA_tree< binary_rss_split_t,num_t,response_t,index_t,rng_t > binary_fanova_tree_t;
 
 %}
 
 
+
 %include "docstrings.i"
 
 
 // vanilla exeption handling for everything
-%include "exception.i" 
+%include "exception.i"
 %exception {
   try {
     $action
@@ -48,7 +50,7 @@ typedef rfr::trees::binary_fANOVA_tree< binary_rss_split_t,num_t,response_t,inde
   } catch (const std::string& e) {
     SWIG_exception(SWIG_RuntimeError, e.c_str());
   }
-} 
+}
 
 
 class std::default_random_engine{
@@ -79,8 +81,6 @@ typedef std::default_random_engine rng_t;
 // put everything here that should be ignored globally
 %ignore rfr::*::serialize;
 
-
-
 // DATA CONTAINERS
 %include "rfr/data_containers/data_container.hpp";
 %include "rfr/data_containers/default_data_container.hpp";
@@ -128,6 +128,9 @@ typedef rfr::nodes::k_ary_mondrian_node_full<2, num_t, response_t, index_t, rng_
 %include "rfr/trees/k_ary_tree.hpp"
 %template(binary_full_tree_rss) rfr::trees::k_ary_random_tree<2, binary_full_node_rss_t, num_t, response_t, index_t, rng_t>;
 typedef rfr::trees::k_ary_random_tree<2,binary_full_node_rss_t, num_t, response_t, index_t, rng_t> binary_full_tree_rss_t;
+typedef rfr::trees::k_ary_random_tree<2,rfr::nodes::k_ary_node_full<2, binary_rss_split_t, num_t, response_t, index_t, rng_t>, num_t, response_t, index_t, rng_t> binary_full_tree_rss_t_;
+%template(binary_rss_vectors) std::vector<binary_full_tree_rss_t>;
+
 
 %include "rfr/trees/binary_fanova_tree.hpp"
 typedef rfr::trees::binary_fANOVA_tree< binary_rss_split_t,num_t,response_t,index_t,rng_t > binary_fanova_tree_t;
@@ -138,19 +141,23 @@ typedef rfr::trees::k_ary_mondrian_tree<2, binary_mondrian_node_t, num_t, respon
 // FOREST(S)
 %include "rfr/forests/forest_options.hpp"
 %template(forest_opts) rfr::forests::forest_options<num_t, response_t, index_t>;
+
 %include "rfr/forests/regression_forest.hpp"
 %template(binary_rss_forest) rfr::forests::regression_forest< binary_full_tree_rss_t, num_t, response_t, index_t, rng_t>;
-%template(binary_rss_vectors) std::vector<binary_full_tree_rss_t>;
+%ignore rfr::forests::regression_forest< binary_full_tree_rss_t_, num_t, response_t, index_t, rng_t>::get_all_trees;
+%template(qr_forest_prototype) rfr::forests::regression_forest< binary_full_tree_rss_t_, num_t, response_t, index_t, rng_t>;
 
 %include "rfr/forests/quantile_regression_forest.hpp"
-%template(qr_forest) rfr::forests::quantile_regression_forest< binary_full_tree_rss_t, num_t, response_t, index_t, rng_t>;
+%template(qr_forest) rfr::forests::quantile_regression_forest< binary_full_tree_rss_t_, num_t, response_t, index_t, rng_t>;
 
 %include "rfr/forests/fanova_forest.hpp"
+%ignore rfr::forests::regression_forest< binary_fanova_tree_t, num_t, response_t, index_t, rng_t>::get_all_trees;
 %template(fanova_forest_prototype) rfr::forests::regression_forest< binary_fanova_tree_t,num_t, response_t, index_t, rng_t >;
 %template(fanova_forest) rfr::forests::fANOVA_forest<binary_rss_split_t, num_t, response_t, index_t, rng_t>;
 
 
 %include "rfr/forests/mondrian_forest.hpp"
+%ignore rfr::forests::regression_forest< binary_mondrian_tree_t, num_t, response_t, index_t, rng_t>::get_all_trees;
 %template(binary_mondrian_forest) rfr::forests::mondrian_forest< binary_mondrian_tree_t, num_t, response_t, index_t, rng_t>;
 
 
@@ -166,7 +173,7 @@ typedef rfr::trees::k_ary_mondrian_tree<2, binary_mondrian_node_t, num_t, respon
 			d = {}
 			d['str_representation'] = self.ascii_string_representation()
 			return (d)
-		
+
 		def __setstate__(self, sState):
 			self.__init__()
 			self.load_from_ascii_string(sState['str_representation'])


Test patch:
diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml
index 7f98374..47ff9cd 100644
--- a/.github/workflows/pytest.yml
+++ b/.github/workflows/pytest.yml
@@ -1,11 +1,22 @@
 name: Tests
 
 on:
+  # Allow to manually trigger through github API
+  workflow_dispatch:
+
+  # Triggers with push to master
   push:
+    branches:
+      - master
+
+  # Triggers with push to a pr aimed at master
   pull_request:
+    branches:
+      - master
+
   schedule:
-    # Every Monday at 7AM UTC
-    - cron: '0 07 * * 5'
+    # Every day at 7AM UTC
+    - cron: '0 07 * * *'
 
 jobs:
   ubuntu:
diff --git a/tests/pyrfr_unit_test_binary_regression_forest.py b/tests/pyrfr_unit_test_binary_regression_forest.py
index df289fd..60a0001 100644
--- a/tests/pyrfr_unit_test_binary_regression_forest.py
+++ b/tests/pyrfr_unit_test_binary_regression_forest.py
@@ -79,8 +79,14 @@ def test_covariance(self):
 
 			kernel = self.forest.kernel(datum, datum)
 			self.assertEqual(kernel, 1)
-	
 
+	def test_contents(self):
+		self.forest.options.num_trees = 10
+		self.forest.fit(self.data, self.rng)
+		trees = self.forest.get_all_trees()
+		self.assertEqual(len(trees), self.forest.options.num_trees)
+		self.assertAlmostEqual(trees[0].get_node(0).get_num_split_value(), -0.20652545999380345)
+		self.assertAlmostEqual(trees[1].get_node(1).get_num_split_value(), -0.8857842741236657)
 
 	def test_pickling(self):