marty 0.5.40 → 0.5.41

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
  SHA1:
3
- metadata.gz: f166abb0b1bc5f9da59dc6c3879fbda45bfa1c2a
4
- data.tar.gz: 78a16a950bbc27e7f34f54e6d123bd1bd3a112e8
3
+ metadata.gz: 1cc0b3b8b64fe73e733f400846ff9e944b1dc113
4
+ data.tar.gz: 87db6321d7a7d2117e2b55bea1979bc0a8ac8e2d
5
5
  SHA512:
6
- metadata.gz: 19fc34d83a632f06a345f927dad2769d89310c3ff330abf34dd99f7bdd054799e29d5067e78dc3b167c669d5a0004ad6d293ba6fb63f24a053610f4bb090e1d6
7
- data.tar.gz: d08d671febf9c71fde42c01c37f61a62d861544a3c30f39de44f55eb69b421444b45565b01f1ac94c78d54b56934d2ee52fa7ee3c0fd03ee542bfc1d7b7d7033
6
+ metadata.gz: ec029611b74c122897ad1497d9ff9ab06b68198354ab942e542759b8bbbfb553c37527615749c3eb14d62e6420fa2bb64df28b41c7a1afb41758ba9ccc6fc07c
7
+ data.tar.gz: fabfcf96a6a52c4211d0fac59ff573844246ce08f4c752dbe70c339b1c4c041bf84e4354221302b0528a81ea7ff89211ba3840095af0a89fc93f4fb3feecaf94
@@ -148,7 +148,7 @@ class Marty::DataGrid < Marty::Base
148
148
  data_type.constantize rescue nil
149
149
  end
150
150
 
151
- def lookup_grid_distinct(pt, h, return_grid_data=false)
151
+ def lookup_grid_distinct(pt, h, return_grid_data=false, distinct=true)
152
152
  isets = {}
153
153
 
154
154
  (dir_infos("v") + dir_infos("h")).each do
@@ -221,7 +221,7 @@ class Marty::DataGrid < Marty::Base
221
221
  end
222
222
 
223
223
  raise "Grid #{name}, (#{isets[dir].count}) #{dir} matches > 1." if
224
- isets[dir] && isets[dir].count > 1
224
+ distinct && isets[dir] && isets[dir].count > 1
225
225
  end
226
226
 
227
227
  vi, hi = isets["v"].first, isets["h"].first if isets["v"] && isets["h"]
@@ -239,6 +239,18 @@ class Marty::DataGrid < Marty::Base
239
239
  }
240
240
  end
241
241
 
242
+ # FIXME: added for Apollo -- not sure where this belongs given that
243
+ # DGs were moved to marty. Should add documentation about callers
244
+ # keeping the hash small.
245
+ cached_delorean_fn :lookup_grid, sig: 4 do
246
+ |pt, dg, h, distinct|
247
+ raise "bad DataGrid #{dg}" unless Marty::DataGrid === dg
248
+ raise "non-hash arg #{h}" unless Hash === h
249
+
250
+ res = dg.lookup_grid_distinct(pt, h, false, distinct)
251
+ res["result"]
252
+ end
253
+
242
254
  # FIXME: using cached_delorean_fn just for the caching -- this is
243
255
  # not expected to be called from Delorean.
244
256
  cached_delorean_fn :find_class_instance, sig: 3 do
@@ -516,7 +528,7 @@ class Marty::DataGrid < Marty::Base
516
528
 
517
529
  c_data_type = Marty::DataGrid.convert_data_type(data_type)
518
530
 
519
- raise "bad data type" unless c_data_type
531
+ raise "bad data type #{data_type}" unless c_data_type
520
532
 
521
533
  # based on data type, decide to check using convert or instance
522
534
  # lookup. FIXME: DRY.
@@ -40,7 +40,7 @@ class Marty::DataExporter
40
40
 
41
41
  # if all array items are hashes, we merge them
42
42
  obj = hash_array_merge(obj, config["transpose"]) if
43
- obj.is_a?(Array) && obj.map {|x| x.is_a? Hash}.all?
43
+ obj.is_a?(Array) && obj.all? {|x| x.is_a? Hash}
44
44
 
45
45
  # symbolize config keys as expected by CSV.generate
46
46
  conf = config.each_with_object({}) { |(k,v), h|
data/lib/marty/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Marty
2
- VERSION = "0.5.40"
2
+ VERSION = "0.5.41"
3
3
  end
@@ -108,6 +108,13 @@ hb_indicator\tboolean\tv
108
108
 
109
109
  true\t456
110
110
  false\t123
111
+ EOS
112
+
113
+ Ge =<<EOS
114
+ ltv\tnumrange\th
115
+
116
+ >110\t>120
117
+ 1.1\t1.1
111
118
  EOS
112
119
 
113
120
  before(:each) do
@@ -216,11 +223,24 @@ EOS
216
223
  describe "lookup" do
217
224
  before(:each) do
218
225
  ["G1", "G2", "G3", "G4", "G5", "G6", "G7", "G8", "Ga", "Gb",
219
- "Gc", "Gd"].each { |g|
226
+ "Gc", "Gd", "Ge"].each { |g|
220
227
  dg_from_import(g, "Marty::DataGridSpec::#{g}".constantize)
221
228
  }
222
229
  end
223
230
 
231
+ it "should handle non-distinct lookups" do
232
+ pt = 'infinity'
233
+
234
+ dg = Marty::DataGrid.lookup(pt, "Ge")
235
+ res = Marty::DataGrid.lookup_grid(pt, dg, {"ltv"=>500}, false)
236
+
237
+ expect(res).to eq(1.1)
238
+
239
+ expect {
240
+ Marty::DataGrid.lookup_grid(pt, dg, {"ltv"=>500}, true)
241
+ }.to raise_error(RuntimeError)
242
+ end
243
+
224
244
  it "should handle boolean lookups" do
225
245
  res = [true, false].map { |hb_indicator|
226
246
  lookup_grid_helper('infinity',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.40
4
+ version: 0.5.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arman Bostani
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2016-06-03 00:00:00.000000000 Z
17
+ date: 2016-06-10 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: pg