plusminus 0.0.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.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +33 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/a +0 -0
- data/lib/plusminus.rb +38 -0
- data/lib/plusminus/plusminus_float.rb +160 -0
- data/plusminus.gemspec +68 -0
- data/spec/plusminus_spec.rb +59 -0
- data/spec/spec_helper.rb +12 -0
- metadata +133 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
flt (1.3.0)
|
6
|
+
git (1.2.5)
|
7
|
+
jeweler (1.8.3)
|
8
|
+
bundler (~> 1.0)
|
9
|
+
git (>= 1.2.5)
|
10
|
+
rake
|
11
|
+
rdoc
|
12
|
+
json (1.6.5)
|
13
|
+
nio (0.2.5)
|
14
|
+
flt (>= 1.0.0)
|
15
|
+
rake (0.9.2.2)
|
16
|
+
rcov (1.0.0)
|
17
|
+
rdoc (3.12)
|
18
|
+
json (~> 1.4)
|
19
|
+
rspec (2.8.0)
|
20
|
+
rspec-core (~> 2.8.0)
|
21
|
+
rspec-expectations (~> 2.8.0)
|
22
|
+
rspec-mocks (~> 2.8.0)
|
23
|
+
rspec-core (2.8.0)
|
24
|
+
rspec-expectations (2.8.0)
|
25
|
+
diff-lcs (~> 1.1.2)
|
26
|
+
rspec-mocks (2.8.0)
|
27
|
+
|
28
|
+
PLATFORMS
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
bundler (~> 1.0.0)
|
33
|
+
jeweler (~> 1.8.3)
|
34
|
+
nio
|
35
|
+
rcov
|
36
|
+
rdoc (~> 3.12)
|
37
|
+
rspec (~> 2.8.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Bernát Kalló
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
= plusminus
|
2
|
+
|
3
|
+
This gem provides a way to calculate uncertainties of measurements.
|
4
|
+
|
5
|
+
5.129213.pm(0.01).to_s #=> "5.13"
|
6
|
+
|
7
|
+
You can access the +value+ and +delta+ fields:
|
8
|
+
|
9
|
+
5.129213.pm(0.01).value #=> 5.129213
|
10
|
+
5.129213.pm(0.01).delta #=> 0.01
|
11
|
+
|
12
|
+
Error propagation is handled for operations
|
13
|
+
|
14
|
+
3.2.pm(0.1) + 4.5.pm(0.1)
|
15
|
+
# => 7.7.pm(0.2)
|
16
|
+
3.2.pm(0.1) * 4.5.pm(0.1)
|
17
|
+
# => 14.4.pm(0.77)
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
== Contributing to plusminus
|
23
|
+
|
24
|
+
* Fork
|
25
|
+
* Branch
|
26
|
+
* Commit
|
27
|
+
* Pull request
|
28
|
+
|
29
|
+
== Copyright
|
30
|
+
|
31
|
+
Copyright (c) 2012 Bernát Kalló. See LICENSE.txt for
|
32
|
+
further details.
|
33
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "plusminus"
|
18
|
+
gem.homepage = "http://github.com/cie/plusminus"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A library that provides uncertainty and error propagation calculations for floats}
|
21
|
+
gem.description = %Q{A library that provides uncertainty and error propagation calculations for floats. It displays the appropriate number of digits when a number is outputted, can convert to latex using different formats.}
|
22
|
+
gem.email = "kallo.bernat@gmail.com"
|
23
|
+
gem.authors = ["Bernát Kalló"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "plusminus #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/a
ADDED
File without changes
|
data/lib/plusminus.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "nio"
|
2
|
+
|
3
|
+
module Plusminus
|
4
|
+
end
|
5
|
+
|
6
|
+
class Numeric
|
7
|
+
def pm delta
|
8
|
+
Plusminus::PlusminusFloat.new self, delta
|
9
|
+
end
|
10
|
+
|
11
|
+
def pm_rel rel
|
12
|
+
Plusminus::PlusminusFloat.new self, abs*rel
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_pm
|
16
|
+
Plusminus::PlusminusFloat.new self, 0
|
17
|
+
end
|
18
|
+
|
19
|
+
def delta
|
20
|
+
0
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
class Float
|
26
|
+
def to_pm
|
27
|
+
Plusminus::PlusminusFloat.new self, 10.0**-Float::DIG
|
28
|
+
end
|
29
|
+
|
30
|
+
def delta
|
31
|
+
10**-Float::DIG
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
require File.expand_path File.dirname(__FILE__) + "/plusminus/plusminus_float.rb"
|
38
|
+
|
@@ -0,0 +1,160 @@
|
|
1
|
+
class Plusminus::PlusminusFloat < Numeric
|
2
|
+
|
3
|
+
DEFAULT_FMT = Nio::Fmt.default.dup
|
4
|
+
|
5
|
+
def initialize value, delta
|
6
|
+
@value = value.to_f
|
7
|
+
@delta = delta.to_f.abs
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_reader :value, :delta
|
11
|
+
|
12
|
+
def to_pm
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_f
|
17
|
+
@value
|
18
|
+
end
|
19
|
+
|
20
|
+
def hash
|
21
|
+
@value.hash
|
22
|
+
end
|
23
|
+
|
24
|
+
def coerce other
|
25
|
+
case other
|
26
|
+
when Numeric
|
27
|
+
return other.to_pm, self
|
28
|
+
else
|
29
|
+
raise ArgumentError "#{other} cannot be coerced to #{self.class}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def + other
|
34
|
+
other = other.to_pm
|
35
|
+
(@value + other.value).pm(@delta + other.delta)
|
36
|
+
end
|
37
|
+
|
38
|
+
def - other
|
39
|
+
other = other.to_pm
|
40
|
+
(@value - other.value).pm(@delta + other.delta)
|
41
|
+
end
|
42
|
+
|
43
|
+
def * other
|
44
|
+
other = other.to_pm
|
45
|
+
(self.value * other.value).pm(other.value.abs * self.delta + self.value.abs * other.delta)
|
46
|
+
end
|
47
|
+
|
48
|
+
def / other
|
49
|
+
other = other.to_pm
|
50
|
+
(self.value / other.value).pm(self.delta / other.value.abs + other.delta * self.value.abs / other.value.abs**2)
|
51
|
+
end
|
52
|
+
|
53
|
+
def ** other
|
54
|
+
return 1 if other == 0
|
55
|
+
return 0 if self == 0
|
56
|
+
other = other.to_pm
|
57
|
+
res = self.value ** other.value
|
58
|
+
res.pm(
|
59
|
+
(Math.log(self.value.abs) * res).abs * other.delta +
|
60
|
+
(other.value * res / self.value).abs * self.delta
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
def -@
|
65
|
+
(-@value).pm @delta
|
66
|
+
end
|
67
|
+
|
68
|
+
def abs
|
69
|
+
@value.abs
|
70
|
+
end
|
71
|
+
|
72
|
+
def == other
|
73
|
+
@value == other
|
74
|
+
end
|
75
|
+
|
76
|
+
def eql? other
|
77
|
+
return false unless other.is_a? self.class
|
78
|
+
self.value == other.value and self.delta == other.delta
|
79
|
+
end
|
80
|
+
|
81
|
+
def <=> other
|
82
|
+
self.value <=> other.to_pm.value
|
83
|
+
end
|
84
|
+
|
85
|
+
def === other
|
86
|
+
other = other.to_pm.value
|
87
|
+
@value-@delta < other and other < @value+@delta
|
88
|
+
end
|
89
|
+
|
90
|
+
# returns the Nio::Fmt to be used with the number. The returned object can be
|
91
|
+
# modified with Nio::Fmt's bang methods
|
92
|
+
def fmt
|
93
|
+
unless defined? @fmt
|
94
|
+
@fmt = DEFAULT_FMT.dup
|
95
|
+
digits = sig_digits
|
96
|
+
case @value
|
97
|
+
when -0.01 ... 0.01 then
|
98
|
+
@fmt.mode!(:sci, sig_digits)
|
99
|
+
else
|
100
|
+
@fmt.mode!(:sig, sig_digits)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
@fmt
|
105
|
+
end
|
106
|
+
|
107
|
+
# returns the number of significant digits
|
108
|
+
def sig_digits
|
109
|
+
return 0 if @value == 0
|
110
|
+
return Float::DIG if @delta == 0
|
111
|
+
Math.log(@value.abs,10).floor + 1.9999 - Math.log(@delta*2,10)
|
112
|
+
end
|
113
|
+
|
114
|
+
# produces a string of the number with the appropriate number of decimal
|
115
|
+
# digits
|
116
|
+
def nio_write fmt=nil
|
117
|
+
@value.nio_write(fmt || self.fmt)
|
118
|
+
end
|
119
|
+
|
120
|
+
def to_s
|
121
|
+
@value.to_s
|
122
|
+
end
|
123
|
+
|
124
|
+
def inspect
|
125
|
+
"#{@value.inspect}.pm(#{delta.inspect})"
|
126
|
+
end
|
127
|
+
|
128
|
+
def to_latex fmt = nil
|
129
|
+
fmt ||= self.fmt
|
130
|
+
s = @value.nio_write(fmt || self.fmt)
|
131
|
+
percent = s =~ /%\z/
|
132
|
+
s.sub!(/%\z/, "")
|
133
|
+
mantissa, exponent = s.split(/e/i)
|
134
|
+
if exponent
|
135
|
+
exponent.sub!(/\A-0*/, "-").sub!(/\A0*/, "")
|
136
|
+
res = "#{mantissa}\\cdot 10^{#{exponent}}"
|
137
|
+
else
|
138
|
+
res = mantissa
|
139
|
+
end
|
140
|
+
res << "\\%" if percent
|
141
|
+
res.respond_to?(:latex!) ? res.latex! : res
|
142
|
+
end
|
143
|
+
|
144
|
+
def to_latex_pm
|
145
|
+
res = "#{to_latex} \\pm #{@delta.pm_rel(0.1).to_latex}"
|
146
|
+
res.respond_to?(:latex!) ? res.latex! : res
|
147
|
+
end
|
148
|
+
|
149
|
+
def to_latex_math_pm
|
150
|
+
res = "$#{to_latex_pm}$"
|
151
|
+
res.respond_to?(:latex!) ? res.latex! : res
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
# modified version of sqrt that uses **, to be able to coerce PlusminusFloat
|
157
|
+
#
|
158
|
+
def Math.sqrt x
|
159
|
+
x ** 0.5
|
160
|
+
end
|
data/plusminus.gemspec
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "plusminus"
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Bern\u{e1}t Kall\u{f3}"]
|
12
|
+
s.date = "2012-03-26"
|
13
|
+
s.description = "A library that provides uncertainty and error propagation calculations for floats. It displays the appropriate number of digits when a number is outputted, can convert to latex using different formats."
|
14
|
+
s.email = "kallo.bernat@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"a",
|
29
|
+
"lib/plusminus.rb",
|
30
|
+
"lib/plusminus/plusminus_float.rb",
|
31
|
+
"plusminus.gemspec",
|
32
|
+
"spec/plusminus_spec.rb",
|
33
|
+
"spec/spec_helper.rb"
|
34
|
+
]
|
35
|
+
s.homepage = "http://github.com/cie/plusminus"
|
36
|
+
s.licenses = ["MIT"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = "1.8.15"
|
39
|
+
s.summary = "A library that provides uncertainty and error propagation calculations for floats"
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<nio>, [">= 0"])
|
46
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
47
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
48
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
49
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
50
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<nio>, [">= 0"])
|
53
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
54
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
55
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
56
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
57
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
58
|
+
end
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<nio>, [">= 0"])
|
61
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
62
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
63
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
64
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
65
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Plusminus::PMFloat" do
|
4
|
+
specify "#nio_write" do
|
5
|
+
25.0. pm(1.0 /2).nio_write.should == "25"
|
6
|
+
25.5. pm(0.5 /2).nio_write.should == "25.5"
|
7
|
+
25.4. pm(0.2 /2).nio_write.should == "25.4"
|
8
|
+
25.4. pm(0.1 /2).nio_write.should == "25.4"
|
9
|
+
25.45.pm(0.05 /2).nio_write.should == "25.45"
|
10
|
+
25.44.pm(0.02 /2).nio_write.should == "25.44"
|
11
|
+
25.43.pm(0.01 /2).nio_write.should == "25.43"
|
12
|
+
25.435.pm(0.005 /2).nio_write.should == "25.435"
|
13
|
+
25.436.pm(0.002 /2).nio_write.should == "25.436"
|
14
|
+
25.435.pm(0.001 /2).nio_write.should == "25.435"
|
15
|
+
25.435.pm(0.0005/2).nio_write.should == "25.4350"
|
16
|
+
25.435.pm(0.0002/2).nio_write.should == "25.4350"
|
17
|
+
25.435.pm(0.0001/2).nio_write.should == "25.4350"
|
18
|
+
5.0. pm(1.0 /2).nio_write.should == "5"
|
19
|
+
5.5. pm(0.5 /2).nio_write.should == "5.5"
|
20
|
+
5.4. pm(0.2 /2).nio_write.should == "5.4"
|
21
|
+
5.4. pm(0.1 /2).nio_write.should == "5.4"
|
22
|
+
5.45.pm(0.05 /2).nio_write.should == "5.45"
|
23
|
+
5.44.pm(0.02 /2).nio_write.should == "5.44"
|
24
|
+
5.43.pm(0.01 /2).nio_write.should == "5.43"
|
25
|
+
5.435.pm(0.005 /2).nio_write.should == "5.435"
|
26
|
+
5.436.pm(0.002 /2).nio_write.should == "5.436"
|
27
|
+
5.435.pm(0.001 /2).nio_write.should == "5.435"
|
28
|
+
5.435.pm(0.0005 /2).nio_write.should == "5.4350"
|
29
|
+
5.435.pm(0.0002 /2).nio_write.should == "5.4350"
|
30
|
+
5.435.pm(0.0001 /2).nio_write.should == "5.4350"
|
31
|
+
0.5. pm(0.5 /2).nio_write.should == "0.5"
|
32
|
+
0.4. pm(0.2 /2).nio_write.should == "0.4"
|
33
|
+
0.4. pm(0.1 /2).nio_write.should == "0.4"
|
34
|
+
0.45.pm(0.05 /2).nio_write.should == "0.45"
|
35
|
+
0.44.pm(0.02 /2).nio_write.should == "0.44"
|
36
|
+
0.43.pm(0.01 /2).nio_write.should == "0.43"
|
37
|
+
0.435.pm(0.005 /2).nio_write.should =="0.435"
|
38
|
+
0.436.pm(0.002 /2).nio_write.should =="0.436"
|
39
|
+
0.435.pm(0.001 /2).nio_write.should =="0.435"
|
40
|
+
0.435.pm(0.0005 /2).nio_write.should =="0.4350"
|
41
|
+
0.435.pm(0.0002 /2).nio_write.should =="0.4350"
|
42
|
+
0.435.pm(0.0001 /2).nio_write.should =="0.4350"
|
43
|
+
0.05.pm(0.05 /2).nio_write.should == "0.05"
|
44
|
+
0.04.pm(0.02 /2).nio_write.should == "0.04"
|
45
|
+
0.03.pm(0.01 /2).nio_write.should == "0.03"
|
46
|
+
0.035.pm(0.005 /2).nio_write.should =="0.035"
|
47
|
+
0.036.pm(0.002 /2).nio_write.should =="0.036"
|
48
|
+
0.035.pm(0.001 /2).nio_write.should =="0.035"
|
49
|
+
0.035.pm(0.0005 /2).nio_write.should =="0.0350"
|
50
|
+
0.035.pm(0.0002 /2).nio_write.should =="0.0350"
|
51
|
+
0.035.pm(0.0001 /2).nio_write.should =="0.0350"
|
52
|
+
end
|
53
|
+
|
54
|
+
specify "#pm_rel" do
|
55
|
+
(5.43.pm_rel 0.1).delta.should == 0.543
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'plusminus'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: plusminus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Bernát Kalló
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-26 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nio
|
16
|
+
requirement: &82980140 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *82980140
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &82979800 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.8.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *82979800
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rdoc
|
38
|
+
requirement: &82979370 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.12'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *82979370
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: &82979050 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *82979050
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: jeweler
|
60
|
+
requirement: &82978510 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.8.3
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *82978510
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rcov
|
71
|
+
requirement: &82978150 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *82978150
|
80
|
+
description: A library that provides uncertainty and error propagation calculations
|
81
|
+
for floats. It displays the appropriate number of digits when a number is outputted,
|
82
|
+
can convert to latex using different formats.
|
83
|
+
email: kallo.bernat@gmail.com
|
84
|
+
executables: []
|
85
|
+
extensions: []
|
86
|
+
extra_rdoc_files:
|
87
|
+
- LICENSE.txt
|
88
|
+
- README.rdoc
|
89
|
+
files:
|
90
|
+
- .document
|
91
|
+
- .rspec
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.rdoc
|
96
|
+
- Rakefile
|
97
|
+
- VERSION
|
98
|
+
- a
|
99
|
+
- lib/plusminus.rb
|
100
|
+
- lib/plusminus/plusminus_float.rb
|
101
|
+
- plusminus.gemspec
|
102
|
+
- spec/plusminus_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: http://github.com/cie/plusminus
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
hash: -573010513
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 1.8.15
|
129
|
+
signing_key:
|
130
|
+
specification_version: 3
|
131
|
+
summary: A library that provides uncertainty and error propagation calculations for
|
132
|
+
floats
|
133
|
+
test_files: []
|