charty 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/charty/util.rb CHANGED
@@ -16,5 +16,13 @@ module Charty
16
16
  end
17
17
  end
18
18
  end
19
+
20
+ module_function def missing?(val)
21
+ val.nil? || nan?(val)
22
+ end
23
+
24
+ module_function def nan?(val)
25
+ val.respond_to?(:nan?) && val.nan?
26
+ end
19
27
  end
20
28
  end
@@ -22,7 +22,6 @@ module Charty
22
22
  class BaseAdapter
23
23
  extend Forwardable
24
24
  include Enumerable
25
- include MissingValueSupport
26
25
 
27
26
  def self.adapter_name
28
27
  name[/:?(\w+)Adapter\z/, 1]
@@ -61,6 +60,11 @@ module Charty
61
60
  def_delegators :data, :[], :[]=
62
61
  def_delegators :data, :each, :to_a, :empty?
63
62
 
63
+ # Take values at the given positional indices (without indexing)
64
+ def values_at(*indices)
65
+ indices.map {|i| data[i] }
66
+ end
67
+
64
68
  def where_in_array(mask)
65
69
  mask = check_mask_vector(mask)
66
70
  masked_data = []
@@ -30,7 +30,6 @@ module Charty
30
30
  include NameSupport
31
31
  include IndexSupport
32
32
 
33
- # TODO: Reconsider the return value type of values_at
34
33
  def_delegators :data, :values_at
35
34
 
36
35
  def where(mask)
@@ -80,14 +79,7 @@ module Charty
80
79
 
81
80
  def drop_na
82
81
  if numeric?
83
- Charty::Vector.new(data.reject { |x|
84
- case x
85
- when Float
86
- x.nan?
87
- else
88
- x.nil?
89
- end
90
- })
82
+ Charty::Vector.new(data.reject { |x| Util.missing?(x) })
91
83
  else
92
84
  Charty::Vector.new(data.compact)
93
85
  end
@@ -100,7 +92,7 @@ module Charty
100
92
  end
101
93
 
102
94
  def notnull
103
- Charty::Vector.new(data.map {|x| ! missing_value?(x) },
95
+ Charty::Vector.new(data.map {|x| ! Util.missing?(x) },
104
96
  index: index,
105
97
  name: name)
106
98
  end
@@ -55,7 +55,7 @@ module Charty
55
55
  def_delegators :data, :[]=, :to_a
56
56
 
57
57
  def values_at(*indices)
58
- indices.map {|i| data[i] }
58
+ indices.map {|i| data.at(i) }
59
59
  end
60
60
 
61
61
  def where(mask)
@@ -130,15 +130,7 @@ module Charty
130
130
  end
131
131
 
132
132
  def drop_na
133
- values = data.reject do |x|
134
- case
135
- when x.nil?,
136
- x.respond_to?(:nan?) && x.nan?
137
- true
138
- else
139
- false
140
- end
141
- end
133
+ values = data.reject {|x| Util.missing?(x) }
142
134
  Charty::Vector.new(Daru::Vector.new(values))
143
135
  end
144
136
 
@@ -149,7 +141,7 @@ module Charty
149
141
  end
150
142
 
151
143
  def notnull
152
- notnull_data = data.map {|x| ! missing_value?(x) }
144
+ notnull_data = data.map {|x| ! Util.missing?(x) }
153
145
  Charty::Vector.new(notnull_data, index: data.index.to_a, name: name)
154
146
  end
155
147
 
@@ -29,11 +29,6 @@ module Charty
29
29
  include NameSupport
30
30
  include IndexSupport
31
31
 
32
- # TODO: Reconsider the return value type of values_at
33
- def values_at(*indices)
34
- data[indices].to_a
35
- end
36
-
37
32
  def where(mask)
38
33
  mask = check_mask_vector(mask)
39
34
  case mask.data
@@ -157,7 +152,7 @@ module Charty
157
152
  i, n = 0, length
158
153
  notnull_data = Numo::Bit.zeros(n)
159
154
  while i < n
160
- notnull_data[i] = ! missing_value?(data[i])
155
+ notnull_data[i] = ! Util.missing?(data[i])
161
156
  i += 1
162
157
  end
163
158
  when ->(x) { x.respond_to?(:isnan) }
@@ -147,7 +147,7 @@ module Charty
147
147
  i, n = 0, length
148
148
  notnull_data = Numpy::NDArray.new(n, dtype: :bool)
149
149
  while i < n
150
- notnull_data[i] = ! missing_value?(data[i])
150
+ notnull_data[i] = ! Util.missing?(data[i])
151
151
  i += 1
152
152
  end
153
153
  else
@@ -86,7 +86,6 @@ module Charty
86
86
  data.size == 0
87
87
  end
88
88
 
89
- # TODO: Reconsider the return value type of values_at
90
89
  def values_at(*indices)
91
90
  data.take(indices).to_a
92
91
  end
@@ -1,5 +1,5 @@
1
1
  module Charty
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
 
4
4
  module Version
5
5
  numbers, TAG = VERSION.split("-")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: charty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - youchan
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-05-28 00:00:00.000000000 Z
13
+ date: 2021-06-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: red-colors
@@ -18,28 +18,70 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 0.3.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '0'
28
+ version: 0.3.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: red-palette
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: 0.2.0
35
+ version: 0.5.0
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.5.0
43
+ - !ruby/object:Gem::Dependency
44
+ name: matplotlib
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 1.2.0
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.2.0
57
+ - !ruby/object:Gem::Dependency
58
+ name: pandas
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 0.3.5
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 0.3.5
71
+ - !ruby/object:Gem::Dependency
72
+ name: playwright-ruby-client
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
36
78
  type: :runtime
37
79
  prerelease: false
38
80
  version_requirements: !ruby/object:Gem::Requirement
39
81
  requirements:
40
82
  - - ">="
41
83
  - !ruby/object:Gem::Version
42
- version: 0.2.0
84
+ version: '0'
43
85
  - !ruby/object:Gem::Dependency
44
86
  name: bundler
45
87
  requirement: !ruby/object:Gem::Requirement
@@ -88,14 +130,14 @@ dependencies:
88
130
  requirements:
89
131
  - - ">="
90
132
  - !ruby/object:Gem::Version
91
- version: 0.0.9
133
+ version: 0.1.2
92
134
  type: :development
93
135
  prerelease: false
94
136
  version_requirements: !ruby/object:Gem::Requirement
95
137
  requirements:
96
138
  - - ">="
97
139
  - !ruby/object:Gem::Version
98
- version: 0.0.9
140
+ version: 0.1.2
99
141
  - !ruby/object:Gem::Dependency
100
142
  name: daru
101
143
  requirement: !ruby/object:Gem::Requirement
@@ -152,34 +194,20 @@ dependencies:
152
194
  - - ">="
153
195
  - !ruby/object:Gem::Version
154
196
  version: '0'
155
- - !ruby/object:Gem::Dependency
156
- name: playwright-ruby-client
157
- requirement: !ruby/object:Gem::Requirement
158
- requirements:
159
- - - ">="
160
- - !ruby/object:Gem::Version
161
- version: '0'
162
- type: :development
163
- prerelease: false
164
- version_requirements: !ruby/object:Gem::Requirement
165
- requirements:
166
- - - ">="
167
- - !ruby/object:Gem::Version
168
- version: '0'
169
197
  - !ruby/object:Gem::Dependency
170
198
  name: iruby
171
199
  requirement: !ruby/object:Gem::Requirement
172
200
  requirements:
173
201
  - - ">="
174
202
  - !ruby/object:Gem::Version
175
- version: '0'
203
+ version: 0.7.0
176
204
  type: :development
177
205
  prerelease: false
178
206
  version_requirements: !ruby/object:Gem::Requirement
179
207
  requirements:
180
208
  - - ">="
181
209
  - !ruby/object:Gem::Version
182
- version: '0'
210
+ version: 0.7.0
183
211
  description: Visualizing your data in a simple way.
184
212
  email:
185
213
  - youchan01@gmail.com
@@ -262,10 +290,10 @@ files:
262
290
  - lib/charty/backends/pyplot.rb
263
291
  - lib/charty/backends/rubyplot.rb
264
292
  - lib/charty/backends/unicode_plot.rb
293
+ - lib/charty/dash_pattern_generator.rb
265
294
  - lib/charty/index.rb
266
295
  - lib/charty/layout.rb
267
296
  - lib/charty/linspace.rb
268
- - lib/charty/missing_value_support.rb
269
297
  - lib/charty/plot_methods.rb
270
298
  - lib/charty/plotter.rb
271
299
  - lib/charty/plotters.rb
@@ -275,6 +303,7 @@ files:
275
303
  - lib/charty/plotters/categorical_plotter.rb
276
304
  - lib/charty/plotters/count_plotter.rb
277
305
  - lib/charty/plotters/estimation_support.rb
306
+ - lib/charty/plotters/line_plotter.rb
278
307
  - lib/charty/plotters/random_support.rb
279
308
  - lib/charty/plotters/relational_plotter.rb
280
309
  - lib/charty/plotters/scatter_plotter.rb
@@ -1,14 +0,0 @@
1
- module Charty
2
- module MissingValueSupport
3
- def missing_value?(val)
4
- case
5
- when val.nil?
6
- true
7
- when val.respond_to?(:nan?) && val.nan?
8
- true
9
- else
10
- false
11
- end
12
- end
13
- end
14
- end