daru_lite 0.3.0 → 0.3.1

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: 2ecfb59a965f8f05a20a331298549d00db4116e8a8f897dc5fdeb4c4b18dc98e
4
- data.tar.gz: fefeb73d29528353d75c291817932146ff283c3160182f755e275e1561882ee1
3
+ metadata.gz: 5fd692ae66f7d3b631fc1f2424f823ab3f9484bb8d7803db6ea1405b00bea456
4
+ data.tar.gz: 959220244151eddba5fd98abde252d54be976e80cc7e179d8cb3f61a90e3c38d
5
5
  SHA512:
6
- metadata.gz: 668c346ce88a77d215a322cd09adf8e9abe07db7d14233800e154119015d059fab6f64c5b6daccdf15844d61fbdde27d6ea99594aea4f683edba328222bedd58
7
- data.tar.gz: 1c6d4e68271787f6abc543806e6409cdbcd139dbcab69d2dc55f2f4c4b7a18a389e0b1ad813ec958670c48322da35903c306f8156ab9f08c9b22e03cae9210f1
6
+ metadata.gz: b4f13fe9ed18e21835c405d40d7241c5d4aea0fb391121c85a504243ac3d755a3b1c1b93f9a78befad060b59e070e234965aff233c3d68d2cac99de9f3280151
7
+ data.tar.gz: d084ec8cc01cb06577e686e8abbfe834d9477071342d025a9a8b3033dd43d82d39ec1d1b5d1561fcdf4508f27e3070ea5713604ffe2cb08e419f773792a34d2d
@@ -89,6 +89,7 @@ module DaruLite
89
89
  data = Hash.new do |h, col|
90
90
  h[col] = row_index.map { |r| [r, nil] }.to_h
91
91
  end
92
+ validate_no_duplicate_pairs(rows, columns)
92
93
  columns.zip(rows, values).each { |c, r, v| data[c][r] = v }
93
94
 
94
95
  # FIXME: in fact, WITHOUT this line you'll obtain more "right"
@@ -101,6 +102,13 @@ module DaruLite
101
102
 
102
103
  private
103
104
 
105
+ def validate_no_duplicate_pairs(rows, columns)
106
+ seen = Set.new
107
+ columns.to_a.zip(rows.to_a).each do |pair|
108
+ raise IndexError, "Duplicate (column, row) pair: #{pair.inspect}" unless seen.add?(pair)
109
+ end
110
+ end
111
+
104
112
  def guess_order(source)
105
113
  case source.first
106
114
  when Vector # assume that all are Vectors
@@ -1,3 +1,3 @@
1
1
  module DaruLite
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.3.1'.freeze
3
3
  end
@@ -1087,6 +1087,16 @@ describe DaruLite::DataFrame do
1087
1087
  expect(df['x'].to_a).to eq([1, 2])
1088
1088
  expect(df['y'].to_a).to eq([3, 4])
1089
1089
  end
1090
+
1091
+ it 'raises IndexError when given duplicate (row, column) pairs' do
1092
+ rows = DaruLite::Vector.new(%w[a a b])
1093
+ columns = DaruLite::Vector.new(%w[x x y])
1094
+ values = DaruLite::Vector.new([1, 2, 3])
1095
+
1096
+ expect {
1097
+ described_class.crosstab_by_assignation(rows, columns, values)
1098
+ }.to raise_error(IndexError, /Duplicate/)
1099
+ end
1090
1100
  end
1091
1101
 
1092
1102
  context '#inspect' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daru_lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Naude-Filonnière
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2026-04-14 00:00:00.000000000 Z
15
+ date: 2026-04-17 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord