stl-rb 0.3.0 → 0.4.0

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: c9618c6ec1b85dd66819a5d2ad583a7eea4f3477d00ec2294bfb11ead531c8a2
4
- data.tar.gz: 85bfe604d2baa36e592f5c10639301258152a0805bf6790e2926af6fbac0bbe5
3
+ metadata.gz: f14115c449f63656bd2e3ca2dc99d3ff7333f666624b6de9dbf85782da52c217
4
+ data.tar.gz: 020f4e169a0a594b6e4c650d2c5386fdca1e08887aa78ae2056e1cf923705aa7
5
5
  SHA512:
6
- metadata.gz: 32e4f5fee0ec21fa9676a25fea82609b7c1814c27ae26d6e45117d3e7c815827fc4ab6628feb4736b5c93bc93925483a1a6a510a3930a49e8e27e83f4690919b
7
- data.tar.gz: 86e8cd5354cca7c121c9e26a8b9a7dde4b3585095843fdc80b1eedcce25a0c8fb0aa8b8b0a6fa2e15a0a6a10f682e8ef71e5e4da186e3e7b17fe8de6b1506332
6
+ metadata.gz: ad513afa05023950ce775cd7d6e197a214b9fdf875720325304dfd2091131e90f5673b268b46af170f4162573088b4aa4154f6fed28afa35f8e88ce6b5f5221b
7
+ data.tar.gz: 1e6f96c7c3a456db12685c7f64e3c31e30b7bcc35eef1dba7f7bcba0d319bd08e00c1fc43edc34bdcc988e0f27ea8e4a64f368cb3ca81e4ddac31ed5466a0799
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.4.0 (2026-04-07)
2
+
3
+ - Updated STL C++ to 0.3.0
4
+ - Dropped support for Ruby < 3.3
5
+
6
+ ## 0.3.1 (2025-10-26)
7
+
8
+ - Fixed error with Rice 4.7
9
+
1
10
  ## 0.3.0 (2024-10-22)
2
11
 
3
12
  - Dropped support for Ruby < 3.1
data/README.md CHANGED
@@ -18,9 +18,9 @@ Decompose a time series
18
18
 
19
19
  ```ruby
20
20
  series = {
21
- Date.parse("2023-01-01") => 100,
22
- Date.parse("2023-01-02") => 150,
23
- Date.parse("2023-01-03") => 136,
21
+ Date.parse("2025-01-01") => 100,
22
+ Date.parse("2025-01-02") => 150,
23
+ Date.parse("2025-01-03") => 136,
24
24
  # ...
25
25
  }
26
26
 
data/ext/stl/ext.cpp CHANGED
@@ -1,45 +1,50 @@
1
+ #include <cstddef>
2
+ #include <vector>
3
+
1
4
  #include <rice/rice.hpp>
2
- #include <rice/stl.hpp>
3
5
 
4
6
  #include "stl.hpp"
5
7
 
6
- Rice::Array to_a(std::vector<float>& x) {
7
- auto a = Rice::Array();
8
- for (auto v : x) {
9
- a.push(v);
8
+ Rice::Array to_a(const std::vector<float>& x) {
9
+ Rice::Array a;
10
+ for (const auto v : x) {
11
+ a.push(v, false);
10
12
  }
11
13
  return a;
12
14
  }
13
15
 
14
16
  extern "C"
15
17
  void Init_ext() {
16
- auto rb_mStl = Rice::define_module("Stl");
18
+ Rice::Module rb_mStl = Rice::define_module("Stl");
17
19
 
18
20
  Rice::define_class_under<stl::StlParams>(rb_mStl, "StlParams")
19
21
  .define_constructor(Rice::Constructor<stl::StlParams>())
20
- .define_method("seasonal_length", &stl::StlParams::seasonal_length)
21
- .define_method("trend_length", &stl::StlParams::trend_length)
22
- .define_method("low_pass_length", &stl::StlParams::low_pass_length)
23
- .define_method("seasonal_degree", &stl::StlParams::seasonal_degree)
24
- .define_method("trend_degree", &stl::StlParams::trend_degree)
25
- .define_method("low_pass_degree", &stl::StlParams::low_pass_degree)
26
- .define_method("seasonal_jump", &stl::StlParams::seasonal_jump)
27
- .define_method("trend_jump", &stl::StlParams::trend_jump)
28
- .define_method("low_pass_jump", &stl::StlParams::low_pass_jump)
29
- .define_method("inner_loops", &stl::StlParams::inner_loops)
30
- .define_method("outer_loops", &stl::StlParams::outer_loops)
31
- .define_method("robust", &stl::StlParams::robust)
32
- .define_method(
33
- "fit",
34
- [](stl::StlParams& self, std::vector<float> series, size_t period, bool weights) {
35
- auto result = self.fit(series, period);
22
+ .define_attr("seasonal_length", &stl::StlParams::seasonal_length)
23
+ .define_attr("trend_length", &stl::StlParams::trend_length)
24
+ .define_attr("low_pass_length", &stl::StlParams::low_pass_length)
25
+ .define_attr("seasonal_degree", &stl::StlParams::seasonal_degree)
26
+ .define_attr("trend_degree", &stl::StlParams::trend_degree)
27
+ .define_attr("low_pass_degree", &stl::StlParams::low_pass_degree)
28
+ .define_attr("seasonal_jump", &stl::StlParams::seasonal_jump)
29
+ .define_attr("trend_jump", &stl::StlParams::trend_jump)
30
+ .define_attr("low_pass_jump", &stl::StlParams::low_pass_jump)
31
+ .define_attr("inner_loops", &stl::StlParams::inner_loops)
32
+ .define_attr("outer_loops", &stl::StlParams::outer_loops)
33
+ .define_attr("robust", &stl::StlParams::robust);
34
+
35
+ rb_mStl
36
+ .define_singleton_function(
37
+ "_decompose",
38
+ [](Rice::Array rb_series, size_t period, const stl::StlParams& params, bool weights) {
39
+ std::vector<float> series = rb_series.to_vector<float>();
40
+ stl::Stl fit{series, period, params};
36
41
 
37
- auto ret = Rice::Hash();
38
- ret[Rice::Symbol("seasonal")] = to_a(result.seasonal);
39
- ret[Rice::Symbol("trend")] = to_a(result.trend);
40
- ret[Rice::Symbol("remainder")] = to_a(result.remainder);
42
+ Rice::Hash ret;
43
+ ret[Rice::Symbol("seasonal")] = to_a(fit.seasonal());
44
+ ret[Rice::Symbol("trend")] = to_a(fit.trend());
45
+ ret[Rice::Symbol("remainder")] = to_a(fit.remainder());
41
46
  if (weights) {
42
- ret[Rice::Symbol("weights")] = to_a(result.weights);
47
+ ret[Rice::Symbol("weights")] = to_a(fit.weights());
43
48
  }
44
49
  return ret;
45
50
  });
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")