multimatrix 0.5 → 0.6
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 +4 -4
- data/lib/multimatrix.rb +2 -2
- data/test/test_multimatrix.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fb8ccc3d287e3b36e384bc84fa8192a10234df9
|
4
|
+
data.tar.gz: 60891a78a4c6ecc73a7194bad36e3e90cf5496e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c177bd75d9d841203015a70577a8ba20101ee238aa42e0bf38d63af81affde8d1d9d4d6259d85e567265378702cf308376ed00e242943c1c4f5fb8e8cdd0ce66
|
7
|
+
data.tar.gz: b161024a28384548863e8c5f7302459885b19ade5a3b9b3bfba4139490935a570cbb64fdb3223b9556c0799533616510daba8cf9e0783b56a5b3cee0e43381b9
|
data/lib/multimatrix.rb
CHANGED
@@ -78,7 +78,7 @@ class MultiMatrix
|
|
78
78
|
# use labels appropriate for Hash keys, because they will be stored as such internally.
|
79
79
|
# labels could be Symbols, Integers, even ActiveModel objects, the only requirement for it that it have to
|
80
80
|
# have a meaningful == method.
|
81
|
-
# @param
|
81
|
+
# @param labelskeys an [Array] of values to be used as dimension labels
|
82
82
|
def initialize(*labelskeys)
|
83
83
|
raise MultiMatrixException, "no dimensions" if labelskeys.length == 0
|
84
84
|
@labels = labelskeys
|
@@ -189,7 +189,7 @@ class MultiMatrix
|
|
189
189
|
tmp = MultiMatrix.new(*(@labels - labels.keys.find_all {|val| labels[val].class != Array}))
|
190
190
|
ids = find_ids(labels)
|
191
191
|
ids.each do |id|
|
192
|
-
hash = @labels_by_id[id]
|
192
|
+
hash = @labels_by_id[id].clone
|
193
193
|
labels.keys.find_all {|val| labels[val].class != Array}.each do |key|
|
194
194
|
hash.delete(key)
|
195
195
|
end
|
data/test/test_multimatrix.rb
CHANGED
@@ -139,4 +139,17 @@ class MultiMatrixTest < Test::Unit::TestCase
|
|
139
139
|
assert_equal x[:x => 1],y
|
140
140
|
end
|
141
141
|
|
142
|
+
def test_labels_disappearence_bug
|
143
|
+
|
144
|
+
x = MultiMatrix.new(:x, :y, :z)
|
145
|
+
x[:x => 1, :y => 1, :z => 1] = 1
|
146
|
+
x[:x => 2, :y => 1, :z => 1] = 1
|
147
|
+
|
148
|
+
assert_equal [1,2], x.values_for_label(:x)
|
149
|
+
|
150
|
+
assert_equal 2, x.sum()
|
151
|
+
x[{:x => 1}]
|
152
|
+
assert_equal [1,2], x.values_for_label(:x)
|
153
|
+
|
154
|
+
end
|
142
155
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multimatrix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gergely Dömsödi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An n-dim matrix data structure with fast loop, search and access
|
14
14
|
email: doome@uhusystems.com
|