spliner 1.0.6 → 1.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 89acfd040767f4ec8454074bf05af816d222218e5f64a6045cee9edf1b11d926
4
+ data.tar.gz: fe8c8212c6230bf61a768eaf399f509487b60211a3bddb0405180ad9df93b81e
5
+ SHA512:
6
+ metadata.gz: 7d7a5dee2684e3b17c870832e68e2ba71b05e6b724298aaf679dc9ae313dc254cad3631dc7a462ec8785f991501302703a375db6f192907c7aad55f259237427
7
+ data.tar.gz: 1b44da03e4022c8fd11de4015709b0195aac38626767a95742bb826b38dbd78c2400f6efbc30352dc63562781b7ee981ff402499855facb87ead35413e0ced05
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Tallak Tveide
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to
7
+ deal in the Software without restriction, including without limitation the
8
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9
+ sell copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
+ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://secure.travis-ci.org/tallakt/spliner.png?branch=master)](http://travis-ci.org/tallakt/spliner)
1
+ [![CI](https://github.com/tallakt/spliner/actions/workflows/ci.yml/badge.svg)](https://github.com/tallakt/spliner/actions/workflows/ci.yml)
2
2
 
3
3
  Spliner
4
4
  =======
@@ -12,7 +12,7 @@ values.
12
12
  Installation
13
13
  ------------
14
14
 
15
- Spliner requires Ruby 1.9 or later. Install with rubygems:
15
+ Spliner requires Ruby 3.0 or later. Install with rubygems:
16
16
 
17
17
  gem install spliner
18
18
 
@@ -63,9 +63,9 @@ try to have each feature separated in commits.
63
63
  Home page
64
64
  ---------
65
65
 
66
- http://www.github.com/tallakt/spliner
66
+ https://github.com/tallakt/spliner
67
67
 
68
- http://rubygems.org/gems/spliner
68
+ https://rubygems.org/gems/spliner
69
69
 
70
70
  License
71
71
  -------
@@ -0,0 +1,3 @@
1
+ module Spliner
2
+ VERSION = '1.1.0'
3
+ end
data/lib/spliner.rb CHANGED
@@ -1,5 +1,2 @@
1
+ require 'spliner/version'
1
2
  require 'spliner/spliner'
2
-
3
- module Spliner
4
- VERSION = '1.0.6'
5
- end
metadata CHANGED
@@ -1,48 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spliner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tallak Tveide
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-19 00:00:00.000000000 Z
11
+ date: 2026-10-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: rspec
14
+ name: matrix
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '2.11'
22
- type: :development
19
+ version: '0'
20
+ type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '2.11'
30
- - !ruby/object:Gem::Dependency
31
- name: rake
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '0.9'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '0.9'
26
+ version: '0'
46
27
  description: Simple library to perform cubic spline interpolation based on key X,Y
47
28
  values
48
29
  email:
@@ -51,39 +32,34 @@ executables: []
51
32
  extensions: []
52
33
  extra_rdoc_files: []
53
34
  files:
54
- - .gitignore
55
- - .travis.yml
56
- - Gemfile
35
+ - LICENSE.txt
57
36
  - README.markdown
58
- - Rakefile
59
37
  - lib/spliner.rb
60
38
  - lib/spliner/spliner.rb
61
39
  - lib/spliner/spliner_section.rb
62
- - spec/spliner_spec.rb
63
- - spliner.gemspec
64
- homepage: http://www.github.com/tallakt/spliner
65
- licenses: []
66
- post_install_message:
40
+ - lib/spliner/version.rb
41
+ homepage: https://github.com/tallakt/spliner
42
+ licenses:
43
+ - MIT
44
+ metadata:
45
+ rubygems_mfa_required: 'true'
46
+ post_install_message:
67
47
  rdoc_options: []
68
48
  require_paths:
69
49
  - lib
70
50
  required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
51
  requirements:
73
- - - ! '>='
52
+ - - ">="
74
53
  - !ruby/object:Gem::Version
75
- version: 1.9.1
54
+ version: '3.0'
76
55
  required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
56
  requirements:
79
- - - ! '>='
57
+ - - ">="
80
58
  - !ruby/object:Gem::Version
81
59
  version: '0'
82
60
  requirements: []
83
- rubyforge_project: spliner
84
- rubygems_version: 1.8.23
85
- signing_key:
86
- specification_version: 3
61
+ rubygems_version: 3.4.20
62
+ signing_key:
63
+ specification_version: 4
87
64
  summary: Cubic spline interpolation library
88
- test_files:
89
- - spec/spliner_spec.rb
65
+ test_files: []
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- *.gem
2
- Gemfile.lock
3
- .idea
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- rvm:
2
- - 2.0.0
3
- - 1.9.2
4
- - 1.9.3
5
- - jruby
6
- - rbx-19mode
7
- - ruby-head
8
-
9
-
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
- gemspec
3
-
4
-
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require 'rspec/core/rake_task'
2
-
3
- RSpec::Core::RakeTask.new(:spec)
4
-
5
- task :default => :spec
6
-
data/spec/spliner_spec.rb DELETED
@@ -1,159 +0,0 @@
1
- require 'spliner'
2
-
3
- describe Spliner::Spliner do
4
- DATASET = {0.0 => 0.0, 1.0 => 1.0, 2.0 => 0.5}
5
- DATASET_X = [0.0, 1.0, 2.0]
6
- DATASET_Y = [0.0, 1.0, 0.5]
7
- KEYS_0_100 = {0.0 => 0.0, 100.0 => 100.0}
8
-
9
- before(:all) do
10
- epsilon = nil
11
- e = 1
12
- while e + 1 > 1
13
- epsilon = e
14
- e *= 0.5
15
- end
16
-
17
- @two_epsilon = 2 * epsilon
18
- end
19
-
20
-
21
- it 'should not accept x values that are not increasing' do
22
- expect(lambda { Spliner::Spliner.new [0.0, -1.0], [0.0, 1.0] }).to raise_exception
23
- end
24
-
25
- it 'should support key points with a single value' do
26
- s1 = Spliner::Spliner.new Hash[0.0, 0.0]
27
- expect(s1.get 0.0).to be_within(@two_epsilon).of(0.0)
28
- expect(s1.get 1.5).to be_nil
29
-
30
- s2 = Spliner::Spliner.new Hash[0.0, 0.0], :extrapolate => -1..1
31
- expect(s2.get 0.0).to be_within(@two_epsilon).of(0.0)
32
- expect(s2.get 0.5).to be_within(@two_epsilon).of(0.0)
33
- end
34
-
35
- it 'supports the Hash initializer' do
36
- s1 = Spliner::Spliner.new Hash[0.0, 0.0, 1.0, 1.0]
37
- expect(s1[0.5]).to be_within(@two_epsilon).of(0.5)
38
-
39
- s2 = Spliner::Spliner.new Hash[0.0, 0.0, 1.0, 1.0], :extrapolate => '100%'
40
- expect(s2[0.5]).to be_within(@two_epsilon).of(0.5)
41
- expect(s2.range.first).to be_within(@two_epsilon).of(-1.0)
42
- end
43
-
44
- it 'supports the x-y array/vector initializer' do
45
- s1 = Spliner::Spliner.new [0.0, 1.0], [0.0, 1.0]
46
- expect(s1[0.5]).to be_within(@two_epsilon).of(0.5)
47
-
48
- s2= Spliner::Spliner.new [0.0, 1.0], [0.0, 1.0], :extrapolate => '100%'
49
- expect(s2[0.5]).to be_within(@two_epsilon).of(0.5)
50
- expect(s2.range.first).to be_within(@two_epsilon).of(-1.0)
51
-
52
- s3 = Spliner::Spliner.new Vector[0.0, 1.0], Vector[0.0, 1.0]
53
- expect(s3[0.5]).to be_within(@two_epsilon).of(0.5)
54
- end
55
-
56
- it 'should return the data points themselves' do
57
- s = Spliner::Spliner.new DATASET
58
- DATASET.each do |k,v|
59
- expect(s.get(k)).to be_within(0.00001).of(v)
60
- end
61
- end
62
-
63
- it 'should return nil outside the data area' do
64
- s = Spliner::Spliner.new DATASET
65
- expect(s.get(-1.0)).to be_nil
66
- expect(s.get(3.0)).to be_nil
67
- end
68
-
69
- it 'should generate a smooth curve (predefined points)' do
70
- s = Spliner::Spliner.new DATASET
71
- expect(s.get(0.4)).to be_within(@two_epsilon).of(0.5260)
72
- expect(s.get(0.8)).to be_within(@two_epsilon).of(0.9080)
73
- expect(s.get(1.2)).to be_within(@two_epsilon).of(1.0080)
74
- expect(s.get(1.6)).to be_within(@two_epsilon).of(0.8260)
75
- end
76
-
77
- it 'should perform linear interpolation in the case of two data points' do
78
- s = Spliner::Spliner.new({0 => 0, 10.0 => 100.0})
79
- expect(s.get(3.0)).to be_within(@two_epsilon).of(30.0)
80
- end
81
-
82
- it 'supports the [] operator (indexing like)' do
83
- s = Spliner::Spliner.new DATASET
84
- expect(s[-1]).to be_nil
85
- expect(s[0]).to be_within(@two_epsilon).of(0.0)
86
- end
87
-
88
- it 'performs :linear extrapolation outside the data range when such is given' do
89
- s = Spliner::Spliner.new KEYS_0_100, :extrapolate => -200..200
90
- expect(s.get -110).not_to be_nil
91
- expect(s.get -150).to be_within(1e-13).of(-150)
92
- expect(s.get 150).to be_within(1e-13).of(150)
93
- end
94
-
95
- it 'performs :hold extrapolation' do
96
- s = Spliner::Spliner.new KEYS_0_100, :extrapolate => -200..200, :emethod => :hold
97
- expect(s.get -150).to be_within(@two_epsilon).of(0)
98
- expect(s.get 150).to be_within(@two_epsilon).of(100)
99
- end
100
-
101
- it 'supports data ranges given as a string like "10%"' do
102
- s1 = Spliner::Spliner.new KEYS_0_100, :extrapolate => '10%'
103
- expect(s1.range.first).to be_within(@two_epsilon).of(-10.0)
104
- expect(s1.range.last).to be_within(@two_epsilon).of(110.0)
105
-
106
- s2 = Spliner::Spliner.new KEYS_0_100, :extrapolate => '10.0%'
107
- expect(s2.range.first).to be_within(@two_epsilon).of(-10.0)
108
- expect(s2.range.last).to be_within(@two_epsilon).of(110.0)
109
-
110
- s3 = Spliner::Spliner.new KEYS_0_100, :extrapolate => '10 %'
111
- expect(s3.range.first).to be_within(@two_epsilon).of(-10.0)
112
- expect(s3.range.last).to be_within(@two_epsilon).of(110.0)
113
-
114
- s4 = Spliner::Spliner.new KEYS_0_100, :extrapolate => 0.1
115
- expect(s3.range.first).to be_within(@two_epsilon).of(-10.0)
116
- expect(s3.range.last).to be_within(@two_epsilon).of(110.0)
117
- end
118
-
119
- it 'splits data points with duplicate X values into separate sections' do
120
- s = Spliner::Spliner.new [0.0, 1.0, 1.0, 2.0, 2.0, 3.0], [0.0, 0.0, 1.0, 1.0, 2.0, 2.0], :extrapolate => 3.0..4.0
121
- expect(s.sections).to eq(3)
122
- expect(s[-1.0]).to be_nil
123
- expect(s[0.5]).to be_within(@two_epsilon).of(0.0)
124
- expect(s[1.5]).to be_within(@two_epsilon).of(1.0)
125
- expect(s[2.5]).to be_within(@two_epsilon).of(2.0)
126
- expect(s[3.5]).to be_within(@two_epsilon).of(2.0)
127
- expect(s[5.0]).to be_nil
128
- end
129
-
130
- it 'should accept an array or vector as index' do
131
- s = Spliner::Spliner.new DATASET
132
- expect(s[*DATASET.keys]).to eq(DATASET.values)
133
- expect(s[DATASET.keys]).to eq(DATASET.values)
134
- expect(s[Vector[*DATASET.keys]]).to eq(Vector[*DATASET.values])
135
- end
136
-
137
- it 'should accept an range/enumerator as index' do
138
- s = Spliner::Spliner.new DATASET
139
- expect(s[0..2]).to eq(DATASET.values)
140
- expect(s[(0.0..2.0).step(1.0)]).to eq(DATASET.values)
141
- end
142
-
143
- it 'supports the class shortcut method' do
144
- expect(Spliner::Spliner[DATASET_X, DATASET_Y, 0..2]).to eq(DATASET.values)
145
- expect(Spliner::Spliner::interpolate(DATASET, 0..2, :extrapolate => '5%')).to eq(DATASET.values)
146
- end
147
-
148
- it 'has the option :fix_invalid_x to delete invalid x values (not increasing)' do
149
- s = Spliner::Spliner.new [0.0, -1.0, -1.1, 0.5, 0.4, 1.0], [0.0, 1.0, 1.0, 0.5, 1.0, 1.0], :extrapolate => '100%', :fix_invalid_x => true
150
- expect(s[0.5]).to be_within(0.001).of(0.5)
151
- expect(s[-0.5]).to be_within(0.001).of(-0.5)
152
-
153
- # not sure why this one is more difficult
154
- x = [ -0.2006675899028778, -0.15321242064237595, -0.1328744888305664, -0.09355448558926582, -0.055590344592928886, -0.01355862058699131, 0.0, -0.008135172538459301, 0.0, -0.005423448514193296 ]
155
- y = [ -60.06944274902344, -53.81944274902344, -51.46846008300781, -46.78096008300781, -41.30497741699219, -35.9664306640625, -33.99884033203125, -32.79803466796875, -31.980606079101562, -31.163192749023438 ]
156
- s2 = Spliner::Spliner.new x, y, :fix_invalid_x => true
157
- end
158
-
159
- end
data/spliner.gemspec DELETED
@@ -1,25 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "spliner"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "spliner"
7
- s.version = Spliner::VERSION
8
- s.authors = ["Tallak Tveide"]
9
- s.email = ["tallak@tveide.net"]
10
- s.homepage = "http://www.github.com/tallakt/spliner"
11
- s.summary = %q{Cubic spline interpolation library}
12
- s.description = %q{Simple library to perform cubic spline interpolation based on key X,Y values}
13
- s.required_ruby_version = '>= 1.9.1'
14
-
15
- s.rubyforge_project = "spliner"
16
-
17
- s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
- s.require_paths = ["lib"]
21
-
22
- # s.add_runtime_dependency "clamp", '~> 0.3'
23
- s.add_development_dependency "rspec", '~> 2.11'
24
- s.add_development_dependency "rake", '~> 0.9'
25
- end