stl-rb 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f27ba59a612d7502f6251944cf1f7f622ed9466b94351f888fd18ec04bb77faa
4
- data.tar.gz: c7c6127cdbb8832a3d5fe89a1577c0ae20e1f8eda505b046b5f7c1520e2ae830
3
+ metadata.gz: 8c2dd80347b3360994ebdefd94b6649d1c43d1e8b9d0bfae1a81df87b3ef6b27
4
+ data.tar.gz: 9bd7ddf6a35529a2365fe55e19e025d0c94a122d5eede5db0a8fbc1fcc53ba91
5
5
  SHA512:
6
- metadata.gz: e793bab429ba275161ef9d1d5566517a602d7a320a01edbe0e065e8ac21d90f6d7f70ea8e2708c583cff2e4cd848ff0955341f011cba102d2540730ecd09de10
7
- data.tar.gz: 67b59c7a814295f852b3f2e26537826ef4879d33439f8603ce0d20877f6ae1254fc4f0f7b6e85fc595ff3ef1be63eb08aa5e72121572743d31ee0a93b4aa54ae
6
+ metadata.gz: 4517e2450a79e93177c55623a34e6d9bc1f9a2e366cd92060fc08ef43a7f768a8c09df5b47eb21b7aa5fd41084526e325eb0d3b6064331193d1e1e583f46068d
7
+ data.tar.gz: 1a482b74b0f6bd586f4c58974f125a0484eca0c7f36cfe91d26ab52a0c75a1634ade87b1ce14416d3ada5f04e3623c1b8d7e507267ecdd40388e11418c922485
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.4.1 (2026-05-04)
2
+
3
+ - Fixed error with certain options
4
+
5
+ ## 0.4.0 (2026-04-07)
6
+
7
+ - Updated STL C++ to 0.3.0
8
+ - Dropped support for Ruby < 3.3
9
+
1
10
  ## 0.3.1 (2025-10-26)
2
11
 
3
12
  - Fixed error with Rice 4.7
data/ext/stl/ext.cpp CHANGED
@@ -1,3 +1,4 @@
1
+ #include <cstddef>
1
2
  #include <vector>
2
3
 
3
4
  #include <rice/rice.hpp>
@@ -5,9 +6,9 @@
5
6
 
6
7
  #include "stl.hpp"
7
8
 
8
- Rice::Array to_a(std::vector<float>& x) {
9
- auto a = Rice::Array();
10
- for (auto v : x) {
9
+ Rice::Array to_a(const std::vector<float>& x) {
10
+ Rice::Array a;
11
+ for (const auto v : x) {
11
12
  a.push(v, false);
12
13
  }
13
14
  return a;
@@ -15,33 +16,36 @@ Rice::Array to_a(std::vector<float>& x) {
15
16
 
16
17
  extern "C"
17
18
  void Init_ext() {
18
- auto rb_mStl = Rice::define_module("Stl");
19
+ Rice::Module rb_mStl = Rice::define_module("Stl");
19
20
 
20
21
  Rice::define_class_under<stl::StlParams>(rb_mStl, "StlParams")
21
22
  .define_constructor(Rice::Constructor<stl::StlParams>())
22
- .define_method("seasonal_length", &stl::StlParams::seasonal_length)
23
- .define_method("trend_length", &stl::StlParams::trend_length)
24
- .define_method("low_pass_length", &stl::StlParams::low_pass_length)
25
- .define_method("seasonal_degree", &stl::StlParams::seasonal_degree)
26
- .define_method("trend_degree", &stl::StlParams::trend_degree)
27
- .define_method("low_pass_degree", &stl::StlParams::low_pass_degree)
28
- .define_method("seasonal_jump", &stl::StlParams::seasonal_jump)
29
- .define_method("trend_jump", &stl::StlParams::trend_jump)
30
- .define_method("low_pass_jump", &stl::StlParams::low_pass_jump)
31
- .define_method("inner_loops", &stl::StlParams::inner_loops)
32
- .define_method("outer_loops", &stl::StlParams::outer_loops)
33
- .define_method("robust", &stl::StlParams::robust)
34
- .define_method(
35
- "fit",
36
- [](stl::StlParams& self, std::vector<float> series, size_t period, bool weights) {
37
- auto result = self.fit(series, period);
23
+ .define_attr("seasonal_length", &stl::StlParams::seasonal_length)
24
+ .define_attr("trend_length", &stl::StlParams::trend_length)
25
+ .define_attr("low_pass_length", &stl::StlParams::low_pass_length)
26
+ .define_attr("seasonal_degree", &stl::StlParams::seasonal_degree)
27
+ .define_attr("trend_degree", &stl::StlParams::trend_degree)
28
+ .define_attr("low_pass_degree", &stl::StlParams::low_pass_degree)
29
+ .define_attr("seasonal_jump", &stl::StlParams::seasonal_jump)
30
+ .define_attr("trend_jump", &stl::StlParams::trend_jump)
31
+ .define_attr("low_pass_jump", &stl::StlParams::low_pass_jump)
32
+ .define_attr("inner_loops", &stl::StlParams::inner_loops)
33
+ .define_attr("outer_loops", &stl::StlParams::outer_loops)
34
+ .define_attr("robust", &stl::StlParams::robust);
38
35
 
39
- auto ret = Rice::Hash();
40
- ret[Rice::Symbol("seasonal")] = to_a(result.seasonal);
41
- ret[Rice::Symbol("trend")] = to_a(result.trend);
42
- ret[Rice::Symbol("remainder")] = to_a(result.remainder);
36
+ rb_mStl
37
+ .define_singleton_function(
38
+ "_decompose",
39
+ [](Rice::Array rb_series, size_t period, const stl::StlParams& params, bool weights) {
40
+ std::vector<float> series = rb_series.to_vector<float>();
41
+ stl::Stl fit{series, period, params};
42
+
43
+ Rice::Hash ret;
44
+ ret[Rice::Symbol("seasonal")] = to_a(fit.seasonal());
45
+ ret[Rice::Symbol("trend")] = to_a(fit.trend());
46
+ ret[Rice::Symbol("remainder")] = to_a(fit.remainder());
43
47
  if (weights) {
44
- ret[Rice::Symbol("weights")] = to_a(result.weights);
48
+ ret[Rice::Symbol("weights")] = to_a(fit.weights());
45
49
  }
46
50
  return ret;
47
51
  });
data/ext/stl/extconf.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "mkmf-rice"
2
2
 
3
- $CXXFLAGS += " -std=c++17 $(optflags)"
3
+ $CXXFLAGS += " -std=c++20 $(optflags)"
4
4
 
5
5
  create_makefile("stl/ext")