rover-df 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7acc7d0f290ab905594bac7ab1641572e717346f1d0546b3d8b783bcd1e5aca
4
- data.tar.gz: 2569b64c237ef836884be2077e8bb8107512d6946631fdb217fb276439412419
3
+ metadata.gz: 44146e3081c968813848026d2a7f785527a0bb55af0a1978a8087d0dcc7a568a
4
+ data.tar.gz: db64041059937e131d27799739506ad27a78d19be3bdd90d299bcee855b54755
5
5
  SHA512:
6
- metadata.gz: dc46c174fced1c55a96fff28a5c69dfe5a508de527432dac3801cf65375093e290860112191444ceaa23023456452f9331406cdf360a7e689f0db27c289c157c
7
- data.tar.gz: 770174c6fb1cc8a52cd47ef77eae871cb5a346d752e9c1c13b8cb44fdc5d791b60fea3d5480bcaa4453b3bca1e83e32af57a57ff0c2a319308d7206d620fa75b
6
+ metadata.gz: f66190d43258016bc54da2ee42078087784e2c245095fceced4f617b4343130c8e324fd07a4fb0a08b6e23f512268d517e330087959dd7a78187228383189ea8
7
+ data.tar.gz: a1d3a80ff866d72dc32a0067240c32f7a24c602a736d932dba394af8b760566591ff0d2942a61243230016182a3a5fad2e635fa1095f809caf477146d0810868
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.3.2 (2022-07-10)
2
+
3
+ - Added `sqrt` method to vectors
4
+ - Improved numeric operations between scalars and vectors
5
+ - Improved performance of `tally`
6
+
1
7
  ## 0.3.1 (2022-05-18)
2
8
 
3
9
  - Added `to!` to vectors
data/README.md CHANGED
@@ -456,7 +456,7 @@ df[:a].type
456
456
  Change the type of a column
457
457
 
458
458
  ```ruby
459
- df[:a] = df[:a].to(:int32)
459
+ df[:a].to!(:int32)
460
460
  ```
461
461
 
462
462
  ## History
data/lib/rover/vector.rb CHANGED
@@ -184,13 +184,9 @@ module Rover
184
184
  Vector.new(@data.to_a.reject(&block))
185
185
  end
186
186
 
187
+ # use Ruby tally for performance
187
188
  def tally
188
- result = Hash.new(0)
189
- @data.each do |v|
190
- result[v] += 1
191
- end
192
- result.default = nil
193
- result
189
+ @data.to_a.tally
194
190
  end
195
191
 
196
192
  def sort
@@ -201,6 +197,16 @@ module Rover
201
197
  Vector.new(@data.abs)
202
198
  end
203
199
 
200
+ def sqrt
201
+ data =
202
+ if @data.is_a?(Numo::SFloat)
203
+ Numo::SFloat::Math.sqrt(@data)
204
+ else
205
+ Numo::DFloat::Math.sqrt(@data)
206
+ end
207
+ Vector.new(data)
208
+ end
209
+
204
210
  def each(&block)
205
211
  @data.each(&block)
206
212
  end
@@ -350,6 +356,14 @@ module Rover
350
356
  super
351
357
  end
352
358
 
359
+ def coerce(other)
360
+ if other.is_a?(Numeric)
361
+ [Vector.new([other]), self]
362
+ else
363
+ raise TypeError, "#{self.class} can't be coerced into #{other.class}"
364
+ end
365
+ end
366
+
353
367
  def cast_data(data, type: nil)
354
368
  numo_type = numo_type(type) if type
355
369
 
data/lib/rover/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rover
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rover-df
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-18 00:00:00.000000000 Z
11
+ date: 2022-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray