remi 0.2.4 → 0.2.5

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
  SHA1:
3
- metadata.gz: abf39cdc119469c021fcdda710733129e1731525
4
- data.tar.gz: dd3c3af30921359450fc2755ea384eeb2fa331e6
3
+ metadata.gz: a68e65a6146a37cea022e1f7cbf18574e16905f7
4
+ data.tar.gz: c944f32038d24deff54396591ca98a64b69ba296
5
5
  SHA512:
6
- metadata.gz: 849b2bd95c4b4c0de5898cc255b3eeb46b677898ee69732f314157231b81e7ec406d17555489c34f9f862679b33be01651779dad21aae52115d2656f2cc9d30b
7
- data.tar.gz: 298284e8eb1e7ce2b9b86b1925d9808eeaf73ccc79ef1c41316661cec61afdd49facddcab1addf8c682ebc24826b856a41ebbc77cfc1d760b734b8494d3f0c91
6
+ metadata.gz: c016ce1f58bb37da6214c29263ddee66c3b46c9557539210be25517c2676ffc0abd6a3c3fb5b6406290a350c280a277bce0a4aedb14856266d423169f650eeaf
7
+ data.tar.gz: 4dc14a6c9653c12dea6ffaaef74ab7d1acc116308ec99e181d6756ae63db8d5a740f6c72e3d8b258f52fce160f8c3c2892405f96c82ce3985a3f11753db690d5
@@ -18,6 +18,6 @@ Feature: Tests the aggregate refinement to the Daru library
18
18
  | a | 2017 | 4 |
19
19
  And the following example record called 'expected result':
20
20
  | Alpha | Year |
21
- | a | 2016 |
22
- | b | 2010 |
21
+ | a | Group a has a minimum value of 2016 |
22
+ | b | Group b has a minimum value of 2010 |
23
23
  Then the target should match the example 'expected result'
@@ -9,9 +9,9 @@ class AggregateJob
9
9
 
10
10
  define_transform :main, sources: :source_data, targets: :target_data do
11
11
 
12
- mymin = lambda do |field, df, indicies|
12
+ mymin = lambda do |field, df, group_key, indicies|
13
13
  values = indicies.map { |idx| df.row[idx][field] }
14
- values.min
14
+ "Group #{group_key} has a minimum value of #{values.min}"
15
15
  end
16
16
 
17
17
  target_data.df = source_data.df.aggregate(by: :alpha, func: mymin.curry.(:year)).detach_index
@@ -21,16 +21,17 @@ module Remi
21
21
  # Public: Allows the user to define an arbitrary aggregation function.
22
22
  #
23
23
  # by - The name of the DataFrame vector to use to group records.
24
- # func - A lambda function that accepts two arguments - the first argument
25
- # is the DataFrame and the second is the index of the elements belonging
26
- # to a group.
24
+ # func - A lambda function that accepts three arguments - the
25
+ # first argument is the DataFrame, the second is the
26
+ # key to the current group, and the third is the index
27
+ # of the elements belonging to a group.
27
28
  #
28
29
  # Example:
29
30
  # df = Daru::DataFrame.new( { a: ['a','a','a','b','b'], year: ['2018','2015','2019', '2014', '2013'] })
30
31
  #
31
- # mymin = lambda do |field, df, indicies|
32
+ # mymin = lambda do |field, df, group_key, indicies|
32
33
  # values = indicies.map { |idx| df.row[idx][field] }
33
- # values.min
34
+ # "Group #{group_key} has a minimum value of #{values.min}"
34
35
  # end
35
36
  #
36
37
  # df.aggregate(by: :a, func: mymin.curry.(:year))
@@ -41,7 +42,8 @@ module Remi
41
42
  grouped = self.group_by(by)
42
43
  ::Daru::Vector.new(
43
44
  grouped.groups.reduce({}) do |h, (key, indicies)|
44
- h[key.size == 1 ? key.first : key] = func.(self, indicies)
45
+ group_key = key.size == 1 ? key.first : key
46
+ h[group_key] = func.(self, group_key, indicies)
45
47
  h
46
48
  end
47
49
  )
data/lib/remi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Remi
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sterling Paramore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-22 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daru