isotree 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5974c65c4adc4fd79ee7770f324c906a2788534f3fe6f381d61711e7cdce78c
4
- data.tar.gz: d401e7c5aaabcd5dcffd5e4f54d93ea4d0966698854e70d3475fd79a92e1e241
3
+ metadata.gz: 95dc93ac1b84a5a37539b335da0457955ee8868997a34a9c249f7c54927f4b04
4
+ data.tar.gz: eff22a02afce64167248e967d384b0c9b2259f2f5248cfad5bd37acd8bc44e2a
5
5
  SHA512:
6
- metadata.gz: d00de0c3902b4f7fd3e13e08f0738ec4daf8be173f60cf46f49318e76f5be3c4ef3edd925f83074e03b4fe181aa6384d43c749f5f72247cf08d44f6811a6fe80
7
- data.tar.gz: 70195ae442c2e4762b2f900a82a891d8f991ace1e521d625f910a1b5e3482334a299674c255e1aebf855728ee169ab5886428baf6df9a5e436bc73f3aff6dda6
6
+ metadata.gz: 9f410b78af1ae72f4cd166511b6b676f3b71bc39ce92641c455879a3aa88172abb7d1c37ffc953d505fdd59db07d355c9ffba20c3577a1d9b2311c5959a4c87f
7
+ data.tar.gz: 4804ec4aa11997fb91bcd714a0569e0571970bf06d4ad9b491f0e450c33183c86d37a922577ec296765708e9599272863cfa7f775f7dca4d9d18346ed8a38d87
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.2.0 (2021-05-17)
2
+
3
+ - Updated to Rice 4
4
+ - Dropped support for Ruby < 2.6
5
+
1
6
  ## 0.1.5 (2021-03-14)
2
7
 
3
8
  - Updated Isotree to 0.1.25
data/ext/isotree/ext.cpp CHANGED
@@ -2,12 +2,7 @@
2
2
  #include <isotree.hpp>
3
3
 
4
4
  // rice
5
- #include <rice/Array.hpp>
6
- #include <rice/Hash.hpp>
7
- #include <rice/Module.hpp>
8
- #include <rice/Object.hpp>
9
- #include <rice/String.hpp>
10
- #include <rice/Symbol.hpp>
5
+ #include <rice/rice.hpp>
11
6
 
12
7
  using Rice::Array;
13
8
  using Rice::Hash;
@@ -18,62 +13,89 @@ using Rice::Symbol;
18
13
  using Rice::define_class_under;
19
14
  using Rice::define_module;
20
15
 
21
- template<>
22
- NewCategAction from_ruby<NewCategAction>(Object x)
16
+ namespace Rice::detail
23
17
  {
24
- auto value = x.to_s().str();
25
- if (value == "weighted") return Weighted;
26
- if (value == "smallest") return Smallest;
27
- if (value == "random") return Random;
28
- throw std::runtime_error("Unknown new categ action: " + value);
29
- }
18
+ template<>
19
+ class From_Ruby<NewCategAction>
20
+ {
21
+ public:
22
+ NewCategAction convert(VALUE x)
23
+ {
24
+ auto value = Object(x).to_s().str();
25
+ if (value == "weighted") return Weighted;
26
+ if (value == "smallest") return Smallest;
27
+ if (value == "random") return Random;
28
+ throw std::runtime_error("Unknown new categ action: " + value);
29
+ }
30
+ };
30
31
 
31
- template<>
32
- MissingAction from_ruby<MissingAction>(Object x)
33
- {
34
- auto value = x.to_s().str();
35
- if (value == "divide") return Divide;
36
- if (value == "impute") return Impute;
37
- if (value == "fail") return Fail;
38
- throw std::runtime_error("Unknown missing action: " + value);
39
- }
32
+ template<>
33
+ class From_Ruby<MissingAction>
34
+ {
35
+ public:
36
+ MissingAction convert(VALUE x)
37
+ {
38
+ auto value = Object(x).to_s().str();
39
+ if (value == "divide") return Divide;
40
+ if (value == "impute") return Impute;
41
+ if (value == "fail") return Fail;
42
+ throw std::runtime_error("Unknown missing action: " + value);
43
+ }
44
+ };
40
45
 
41
- template<>
42
- CategSplit from_ruby<CategSplit>(Object x)
43
- {
44
- auto value = x.to_s().str();
45
- if (value == "subset") return SubSet;
46
- if (value == "single_categ") return SingleCateg;
47
- throw std::runtime_error("Unknown categ split: " + value);
48
- }
46
+ template<>
47
+ class From_Ruby<CategSplit>
48
+ {
49
+ public:
50
+ CategSplit convert(VALUE x)
51
+ {
52
+ auto value = Object(x).to_s().str();
53
+ if (value == "subset") return SubSet;
54
+ if (value == "single_categ") return SingleCateg;
55
+ throw std::runtime_error("Unknown categ split: " + value);
56
+ }
57
+ };
49
58
 
50
- template<>
51
- CoefType from_ruby<CoefType>(Object x)
52
- {
53
- auto value = x.to_s().str();
54
- if (value == "uniform") return Uniform;
55
- if (value == "normal") return Normal;
56
- throw std::runtime_error("Unknown coef type: " + value);
57
- }
59
+ template<>
60
+ class From_Ruby<CoefType>
61
+ {
62
+ public:
63
+ CoefType convert(VALUE x)
64
+ {
65
+ auto value = Object(x).to_s().str();
66
+ if (value == "uniform") return Uniform;
67
+ if (value == "normal") return Normal;
68
+ throw std::runtime_error("Unknown coef type: " + value);
69
+ }
70
+ };
58
71
 
59
- template<>
60
- UseDepthImp from_ruby<UseDepthImp>(Object x)
61
- {
62
- auto value = x.to_s().str();
63
- if (value == "lower") return Lower;
64
- if (value == "higher") return Higher;
65
- if (value == "same") return Same;
66
- throw std::runtime_error("Unknown depth imp: " + value);
67
- }
72
+ template<>
73
+ class From_Ruby<UseDepthImp>
74
+ {
75
+ public:
76
+ UseDepthImp convert(VALUE x)
77
+ {
78
+ auto value = Object(x).to_s().str();
79
+ if (value == "lower") return Lower;
80
+ if (value == "higher") return Higher;
81
+ if (value == "same") return Same;
82
+ throw std::runtime_error("Unknown depth imp: " + value);
83
+ }
84
+ };
68
85
 
69
- template<>
70
- WeighImpRows from_ruby<WeighImpRows>(Object x)
71
- {
72
- auto value = x.to_s().str();
73
- if (value == "inverse") return Inverse;
74
- if (value == "prop") return Prop;
75
- if (value == "flat") return Flat;
76
- throw std::runtime_error("Unknown weight imp rows: " + value);
86
+ template<>
87
+ class From_Ruby<WeighImpRows>
88
+ {
89
+ public:
90
+ WeighImpRows convert(VALUE x)
91
+ {
92
+ auto value = Object(x).to_s().str();
93
+ if (value == "inverse") return Inverse;
94
+ if (value == "prop") return Prop;
95
+ if (value == "flat") return Flat;
96
+ throw std::runtime_error("Unknown weight imp rows: " + value);
97
+ }
98
+ };
77
99
  }
78
100
 
79
101
  extern "C"
@@ -85,9 +107,9 @@ void Init_ext()
85
107
  define_class_under<ExtIsoForest>(rb_mExt, "ExtIsoForest");
86
108
 
87
109
  rb_mExt
88
- .define_singleton_method(
110
+ .define_singleton_function(
89
111
  "fit_iforest",
90
- *[](Hash options) {
112
+ [](Hash options) {
91
113
  // model
92
114
  ExtIsoForest iso;
93
115
 
@@ -204,9 +226,9 @@ void Init_ext()
204
226
 
205
227
  return iso;
206
228
  })
207
- .define_singleton_method(
229
+ .define_singleton_function(
208
230
  "predict_iforest",
209
- *[](ExtIsoForest& iso, Hash options) {
231
+ [](ExtIsoForest& iso, Hash options) {
210
232
  // data
211
233
  size_t nrows = options.get<size_t, Symbol>("nrows");
212
234
  size_t ncols_numeric = options.get<size_t, Symbol>("ncols_numeric");
@@ -260,9 +282,9 @@ void Init_ext()
260
282
  }
261
283
  return ret;
262
284
  })
263
- .define_singleton_method(
285
+ .define_singleton_function(
264
286
  "serialize_ext_isoforest",
265
- *[](ExtIsoForest& iso, String path) {
287
+ [](ExtIsoForest& iso, String path) {
266
288
  #ifdef _MSC_VER
267
289
  // TODO convert to wchar_t
268
290
  throw std::runtime_error("Not supported on Windows yet");
@@ -270,9 +292,9 @@ void Init_ext()
270
292
  serialize_ext_isoforest(iso, path.c_str());
271
293
  #endif
272
294
  })
273
- .define_singleton_method(
295
+ .define_singleton_function(
274
296
  "deserialize_ext_isoforest",
275
- *[](String path) {
297
+ [](String path) {
276
298
  ExtIsoForest iso;
277
299
 
278
300
  #ifdef _MSC_VER
@@ -1,6 +1,6 @@
1
1
  require "mkmf-rice"
2
2
 
3
- $CXXFLAGS += " -std=c++11 -D_USE_MERSENNE_TWISTER -D_ENABLE_CEREAL"
3
+ $CXXFLAGS += " -std=c++17 -D_USE_MERSENNE_TWISTER -D_ENABLE_CEREAL"
4
4
 
5
5
  apple_clang = RbConfig::CONFIG["CC_VERSION_MESSAGE"] =~ /apple clang/i
6
6
 
@@ -1,3 +1,3 @@
1
1
  module IsoTree
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isotree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rice
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.2'
19
+ version: 4.0.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '2.2'
26
+ version: 4.0.2
27
27
  description:
28
28
  email: andrew@ankane.org
29
29
  executables: []
@@ -161,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - ">="
163
163
  - !ruby/object:Gem::Version
164
- version: '2.5'
164
+ version: '2.6'
165
165
  required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - ">="