namo 0.32.5 → 0.32.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fca34f0fc6464ae1bbb80a5df45f40b63c496369b7cfbc6b32090e26bf0938f3
4
- data.tar.gz: f156784556a7fcd2a28cef6f44178e0c4b115617cd5e64f173cfb42ca768fb53
3
+ metadata.gz: 43fba45fc148a057ec113497f43f689b027e68c76f323f49d4590de48e7942e5
4
+ data.tar.gz: '02397331f3d30d460b63a0e2e1441d5820f4ca3134b25a73ba54d86fc4eaa9a6'
5
5
  SHA512:
6
- metadata.gz: e47d75b0e5a23a4f131de7d8d3865dc27ad74ef91a2e87cb7c8d36a2c127784a11cf1b767978ec54b6fabf48c99f25f9a09839e229d3abd36f3851d801549257
7
- data.tar.gz: c1f4a2ae0e3946c4c02e1f4d643b18666214224b58602ffd9185410f7e66ea949d96a1521582f98b095b9cf7b703f665014e8e42f43ed7ef65a4647da3b8efc5
6
+ metadata.gz: a26014811ea6c61e0e25c746d5f77314971554292823ddbd1ed6bca43406de1754a477b336c68d9767f534eab04717b7fc22ea434efdaadd5f4f786e2aac1ca8
7
+ data.tar.gz: 234bacaeb9d7daa7fb05bf70036aa90ac6599270dc1d868966ceb06d75bfc1defd41ed6e21329e93e3236911075fe81424ee196c0c3e1aa662c252f1be390ea0
data/README.md CHANGED
@@ -1295,6 +1295,8 @@ prices.group_by(:value_score)
1295
1295
 
1296
1296
  This gives a single inversion law over the whole namespace — `namo.group_by(d).as_detail(d) == namo[*namo.data_dimensions, d]` for any `d`, with the exact-original round-trip being the data-dimension instance of it. A nil-valued group produces a nil-named member, holding its rows and round-tripping like any other.
1297
1297
 
1298
+ `group_by` takes a dimension and no block. The block form `Enumerable#group_by` teaches is not implemented — the groups a computed key makes would have no dimension to round-trip through on `as_detail` — and it says so when called; partitioning by a computed key drops to Ruby, where `prices.entries.group_by{|row| row[:symbol]}` returns the `{key => [Row]}` hash `Enumerable#group_by` always returned.
1299
+
1298
1300
  ## Name
1299
1301
 
1300
1302
  Namo: nam(ed) (dimensi)o(ns). A companion to Numo (numeric arrays for Ruby). And in Aussie culture 'o' gets added to the end of names.
@@ -69,7 +69,16 @@ class Namo
69
69
  ]
70
70
  end
71
71
 
72
- def group_by(dimension)
72
+ # The block form is the call Enumerable#group_by makes, and it is not
73
+ # implemented: the groups a computed key makes have no dimension to
74
+ # round-trip through on as_detail. The raise says so and names the way to
75
+ # partition by one, where Ruby's arity error said only that the count was
76
+ # wrong; a call with no dimension at all gets its own sentence.
77
+ def group_by(dimension = nil)
78
+ if block_given?
79
+ raise ArgumentError, 'the block form of group_by is not implemented; entries.group_by{|row| ...} partitions by a computed key'
80
+ end
81
+ raise ArgumentError, 'group_by needs a dimension' if dimension.nil?
73
82
  collection = Collection.new
74
83
  source = derived_dimensions.include?(dimension) ? self[*data_dimensions, dimension] : self
75
84
  members = (
data/lib/Namo/VERSION.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # Namo::VERSION
3
3
 
4
4
  class Namo
5
- VERSION = '0.32.5'
5
+ VERSION = '0.32.6'
6
6
  end
data/test/namo_test.rb CHANGED
@@ -3234,6 +3234,18 @@ describe Namo do
3234
3234
  end
3235
3235
  end
3236
3236
 
3237
+ context "the boundary of the call" do
3238
+ it "raises informatively on the block form, which is not implemented" do
3239
+ error = _(proc{prices.group_by{|row| row[:symbol]}}).must_raise ArgumentError
3240
+ _(error.message).must_match(/entries\.group_by/)
3241
+ end
3242
+
3243
+ it "raises informatively with no dimension at all" do
3244
+ error = _(proc{prices.group_by}).must_raise ArgumentError
3245
+ _(error.message).must_match(/dimension/)
3246
+ end
3247
+ end
3248
+
3237
3249
  context "single-pass assembly" do
3238
3250
  # Collection#<< rebuilds @data = detail.data over all members-so-far on every
3239
3251
  # append, so appending one member per group re-materialised the data g times
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.5
4
+ version: 0.32.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran