rover-df 1.0.0 → 1.0.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: 1b269feff9f961b17f921d168f240e24cea8e02a75438cdfc3e0aff5398d78f4
4
- data.tar.gz: dcd83d0a8ebe2ed3b13c1fdfca8c1a078d3a2b12df66a1c59ebfecf7030ee443
3
+ metadata.gz: fc6b943b37b58eebf71e4a03cb289b2687fc0e0ae0975fddaede4c2ed1a6f33a
4
+ data.tar.gz: c430c0b73b54c17045fbd216b718c968f5b961c164617a89966253c249ad8935
5
5
  SHA512:
6
- metadata.gz: 74743dad81d9fd28a96818e909f165ec173241d04ef9daeb49b8fbc48ff02055d1946dddf33d052fe68f59c32ac678225c5eef9f1d03a035c35630fa798fda26
7
- data.tar.gz: d1b12368ae872abfff95cfffaf209e9ccb05b121aaf1f9b23b11785cc00fa9c3915ec15905275c1c69cbcbaefe1f1cae494af648d3ef3a2c9af58b6b931152d5
6
+ metadata.gz: fd49b878f232888a878700ec6a1eb0888c68318394bb3571d73019587fd4039fa15bc9eaef6a4b6f6a0d1184f5ef763648d17a28b9fdfb88fac917d973a5de45
7
+ data.tar.gz: a279d5b43ea48377a54b14e9dcded9a25d9912aeae1ac96bd517fdf42cff902f0f21f1db2ff933fff791f38c94b25d3bbb921d467cf45377fed52887e6b386de
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.1 (2026-04-15)
2
+
3
+ - Added support for positional argument to `any?` and `all?` methods
4
+
1
5
  ## 1.0.0 (2026-04-04)
2
6
 
3
7
  - Switched to `numo-narray-alt`
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Simple, powerful data frames for Ruby
4
4
 
5
- :mountain: Designed for data exploration and machine learning, and powered by [Numo](https://github.com/ruby-numo/numo-narray)
5
+ :mountain: Designed for data exploration and machine learning, and powered by [numo-narray-alt](https://github.com/yoshoku/numo-narray-alt)
6
6
 
7
7
  :evergreen_tree: Uses [Vega](https://github.com/ankane/vega) for visualization
8
8
 
@@ -27,7 +27,7 @@ module Rover
27
27
  end
28
28
  elsif data.is_a?(Array)
29
29
  vectors = {}
30
- raise ArgumentError, "Array elements must be hashes" unless data.all? { |d| d.is_a?(Hash) }
30
+ raise ArgumentError, "Array elements must be hashes" unless data.all?(Hash)
31
31
  keys = data.flat_map(&:keys).uniq
32
32
  keys.each do |k|
33
33
  vectors[k] = []
@@ -65,7 +65,7 @@ module Rover
65
65
  end
66
66
 
67
67
  def [](where)
68
- if (where.is_a?(Vector) && where.to_numo.is_a?(Numo::Bit)) || where.is_a?(Numeric) || where.is_a?(Range) || (where.is_a?(Array) && where.all? { |v| v.is_a?(Integer) })
68
+ if (where.is_a?(Vector) && where.to_numo.is_a?(Numo::Bit)) || where.is_a?(Numeric) || where.is_a?(Range) || (where.is_a?(Array) && where.all?(Integer))
69
69
  new_vectors = {}
70
70
  @vectors.each do |k, v|
71
71
  new_vectors[k] = v[where]
@@ -269,7 +269,7 @@ module Rover
269
269
  when :bool
270
270
  :boolean
271
271
  when :object
272
- if @vectors[name].all? { |v| v.is_a?(String) }
272
+ if @vectors[name].all?(String)
273
273
  :string
274
274
  else
275
275
  raise "Unknown type"
@@ -313,10 +313,10 @@ module Rover
313
313
 
314
314
  @vectors.each do |k, v|
315
315
  v = summarize ? v.first(5).to_a + ["..."] + v.last(5).to_a : v.to_a
316
- width = ([k] + v).map(&:to_s).map(&:size).max
316
+ width = ([k] + v).map { |v2| v2.to_s.size }.max
317
317
  width = 3 if width < 3
318
318
 
319
- if lines.empty? || lines[-2].map { |l| l.size + spaces }.sum + width > 120
319
+ if lines.empty? || lines[-2].sum { |l| l.size + spaces } + width > 120
320
320
  line_start = lines.size
321
321
  lines << []
322
322
  v.size.times do |i|
@@ -382,10 +382,10 @@ module Rover
382
382
 
383
383
  size = self.size
384
384
  vectors.each do |k, v|
385
- @vectors[k] = Vector.new(v.to_a + (other[k] ? other[k].to_a : [nil] * other.size))
385
+ @vectors[k] = Vector.new(v.to_a + (other[k] ? other[k].to_a : Array.new(other.size)))
386
386
  end
387
387
  (other.vector_names - vector_names).each do |k|
388
- @vectors[k] = Vector.new([nil] * size + other[k].to_a)
388
+ @vectors[k] = Vector.new(Array.new(size) + other[k].to_a)
389
389
  end
390
390
  self
391
391
  end
data/lib/rover/vector.rb CHANGED
@@ -305,12 +305,12 @@ module Rover
305
305
  @data.cast_to(Numo::DFloat).var
306
306
  end
307
307
 
308
- def all?(&block)
309
- to_a.all?(&block)
308
+ def all?(...)
309
+ to_a.all?(...)
310
310
  end
311
311
 
312
- def any?(&block)
313
- to_a.any?(&block)
312
+ def any?(...)
313
+ to_a.any?(...)
314
314
  end
315
315
 
316
316
  def empty?
@@ -374,7 +374,7 @@ module Rover
374
374
  end
375
375
 
376
376
  def one_hot(drop: false, prefix: nil)
377
- raise ArgumentError, "All elements must be strings" unless all? { |vi| vi.is_a?(String) }
377
+ raise ArgumentError, "All elements must be strings" unless all?(String)
378
378
 
379
379
  new_vectors = {}
380
380
  # maybe sort values first
@@ -459,7 +459,7 @@ module Rover
459
459
  data = numo_type.cast(data)
460
460
  else
461
461
  data =
462
- if data.all? { |v| v.is_a?(Integer) }
462
+ if data.all?(Integer)
463
463
  Numo::Int64.cast(data)
464
464
  elsif data.all? { |v| v.is_a?(Numeric) || v.nil? }
465
465
  Numo::DFloat.cast(data.map { |v| v || Float::NAN })
data/lib/rover/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rover
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rover-df
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane