measurand 0.1.1 → 0.1.3

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: '0081d266d9ae51cbb07722737eef34f0d2bc4143ebd810e5c06f4d40e8cbd27d'
4
- data.tar.gz: eb2cd2d56c3e6cbf889156b7b5e91723e2781b6edb0e0126fb0a7f8ce131dea0
3
+ metadata.gz: 4ce22bdc4272ba3acaf6942f5cc8bed9c4db990d60388a00888d43fc9f41e849
4
+ data.tar.gz: bf087841c7706d4b3fa8acd98520cb3854d74adef675e41427b47dda85206746
5
5
  SHA512:
6
- metadata.gz: c39ff9c75669a213327efc1fd2be2acfcc55f20c458d05a027622121a007b0d2ee9f7337197e9a431f79943f320b08daf69ef9b0c3fd348000b71cdf4a760c25
7
- data.tar.gz: 8f7994034252a9d7890516b6478f5966a1a649aaa424df82b2fa5df024e909d805450115cf0de9e52abb20a28b81ebe5146756c33c7b5242f725623a694db1df
6
+ metadata.gz: d38a58eb8cf3036638d26ae407d98f90db2193d9f81bcf979eece1d0cc174d7ff6fa6a9104f2267fb20a7bcffc5131d3b9464e3e72c8baf6f3d18b7d52697ac6
7
+ data.tar.gz: 69a99b5df2dab398ecd1c33e02589de8885876f8749f43059b564d1ddfe34c49dc82de566430c65116bfb9a87fcf64d8844578aa7be44e0a17352ca02aea02a2
data/CHANGELOG CHANGED
@@ -1,7 +1,22 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 20260826
4
+
5
+ 0.1.3: + minitest and rake as development dependencies, the Gemfile having resolved nothing.
6
+
7
+ 1. ~ measurand.gemspec: + spec.development_dependencies, + Gem::Specification#development_dependencies= helper.
8
+ 2. ~ Measurand::VERSION: /0.1.2/0.1.3/
9
+
10
+
3
11
  ## 20260817
4
12
 
13
+ 0.1.2: Measurand#/ divided two integer values as integers.
14
+
15
+ 1. ~ Measurand#/: through Numeric#quo rather than #/, so that two Integer values divide exactly. A ratio of two integer counts came back as nothing at all — 9579583 over 10900458 gave 0 rather than 0.8788 — which is what a speedup or a rate is made of, and integer counts are what a clock reads in. A Float value stays a Float, and the partials were already in Float and are unaffected. duration.rb met the same defect at its 0.5.0 and took the same fix.
16
+ 2. + test/Measurand/Measurand_test.rb: that two integer values divide exactly, and that two exact ones keep a Rational.
17
+ 3. + test/Measurand/Measurand_test.rb: that Measurand#** carries no such defect, an integer raised to a negative exponent giving a Rational rather than truncating, in the value and in the derivative alike. Integer#** promotes where Integer#/ truncates, which is Ruby's inconsistency and not this gem's, and nothing here would have said so.
18
+ 4. ~ Measurand::VERSION: /0.1.1/0.1.2/
19
+
5
20
  0.1.1: Populate the .gitignore, which had been committed empty.
6
21
 
7
22
  1. ~ .gitignore: 47 lines, covering gem builds, bundler, RDoc and YARD output, .DS_Store, editor files, the Ruby version managers, test artefacts and .claude. The file was created empty by the root commit and nothing had since filled it in.
@@ -1,3 +1,3 @@
1
1
  class Measurand
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.3'
3
3
  end
data/lib/measurand.rb CHANGED
@@ -84,9 +84,13 @@ class Measurand
84
84
  self.class.derived(@value * other.value, combine(other.value, other, @value))
85
85
  end
86
86
 
87
+ # Through #quo rather than #/, so that two Integer values divide exactly:
88
+ # 1.quo(3) is (1/3) where 1 / 3 is 0, and a ratio of two integer counts would
89
+ # otherwise come back as nothing at all. A Float value stays a Float. The
90
+ # partials were already in Float and are unaffected.
87
91
  def /(other)
88
92
  other = wrap(other)
89
- self.class.derived(@value / other.value, combine(1.0 / other.value, other, -@value.to_f / (other.value ** 2)))
93
+ self.class.derived(@value.quo(other.value), combine(1.0 / other.value, other, -@value.to_f / (other.value ** 2)))
90
94
  end
91
95
 
92
96
  def **(other)
data/measurand.gemspec CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  require_relative './lib/Measurand/VERSION'
4
4
 
5
+ class Gem::Specification
6
+ def development_dependencies=(gems)
7
+ gems.each{|gem| add_development_dependency(*gem)}
8
+ end
9
+ end
10
+
5
11
  Gem::Specification.new do |spec|
6
12
  spec.name = 'measurand'
7
13
  spec.version = Measurand::VERSION
@@ -27,4 +33,9 @@ Gem::Specification.new do |spec|
27
33
  ].flatten
28
34
 
29
35
  spec.require_paths = ['lib']
36
+
37
+ spec.development_dependencies = %w{
38
+ minitest
39
+ rake
40
+ }
30
41
  end
@@ -203,4 +203,32 @@ describe Measurand do
203
203
  _(a.overlaps?(Measurand.new(5.3, 0.1))).must_equal false
204
204
  end
205
205
  end
206
+
207
+ describe "division of integer values" do
208
+ it "divides exactly rather than as integers" do
209
+ _((Measurand.new(9_579_583, 84) / Measurand.new(10_900_458, 84)).value.to_f) \
210
+ .must_be_close_to(0.878824, 0.000001)
211
+ end
212
+
213
+ it "keeps a Rational where both are exact" do
214
+ _((Measurand.new(1) / Measurand.new(3)).value).must_equal(Rational(1, 3))
215
+ end
216
+ end
217
+
218
+ # Integer#** promotes to Rational where Integer#/ truncates, so the defect
219
+ # fixed above has no counterpart here. Held under test all the same, since
220
+ # nothing in Measurand says so and the two operators read alike.
221
+ describe "exponentiation of integer values" do
222
+ it "stays exact under a negative exponent" do
223
+ _((Measurand.new(2, 0.1) ** -1).value).must_equal(Rational(1, 2))
224
+ _((Measurand.new(8, 0.1) ** -1).value).must_equal(Rational(1, 8))
225
+ end
226
+
227
+ it "propagates through a derivative which is exact for the same reason" do
228
+ _((Measurand.new(2, 0.1) ** -1).uncertainty).must_be_close_to(0.025, 1e-9)
229
+ _((Measurand.new(8, 0.1) ** -1).uncertainty).must_be_close_to(0.0015625, 1e-9)
230
+ _((Measurand.new(2, 0.1) ** 3).uncertainty).must_be_close_to(1.2, 1e-9)
231
+ end
232
+ end
233
+
206
234
  end
metadata CHANGED
@@ -1,14 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: measurand
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
- dependencies: []
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: minitest
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rake
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
12
40
  description: Measured values with uncertainty, propagated by first-order (GUM) error
13
41
  propagation over an automatic-differentiation graph, so that shared sources correlate
14
42
  correctly. Quadrature done right, not linear addition. Parsing, PDG-rounded presentation,
@@ -55,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
83
  - !ruby/object:Gem::Version
56
84
  version: '0'
57
85
  requirements: []
58
- rubygems_version: 4.0.18
86
+ rubygems_version: 4.0.19
59
87
  specification_version: 4
60
88
  summary: Measured values with uncertainty and GUM-conformant error propagation.
61
89
  test_files: []