charty 0.2.11 → 0.2.13

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: eac796ba17aeb9a82a312d7099c898a2350abaf34c3fad80ea1afd1483de1797
4
- data.tar.gz: 8001339bd86377ab3693cc2eeb0a826c04c4ea4e08d58e3a10e99849a273cd58
3
+ metadata.gz: '06027692f65a7836ddd08d860a3801a0ec9f48d3b57d87ed6b0ed13df1921236'
4
+ data.tar.gz: 5d8bf785d75f7e7ce8f3c3f5139ee1da836132c0a044af1f80fa0ad63d144514
5
5
  SHA512:
6
- metadata.gz: 3679334bb56834f7fb1067878c60e7601375e05d6adf63e566eb2cd3847a7ce1423bb27d0104f666854c8343840706a8e14dcc12bc8420ae062b8144d3f6ebc2
7
- data.tar.gz: f4bbec96ae815cd758b67a993355fe5e42a10b91d7ef351e63570ec84fa618e65e4c2df4006f2d3431738c8b82b6a5dcf74d79a9b4ce005f89f18fd2ae88d31d
6
+ metadata.gz: 75ec27779ae41243a4fd31905cb0e5ad240dcccfff11be14ef30b32b2cd67147e3244f2ae1ee44035babbb13320d378eb2ce7f5260fb401c9d389198cb3f1228
7
+ data.tar.gz: 0b2dc4eb561c51f5fe3f300c0a051a7b7d31793fc7eb302bf5894c1522547fe28fd8faf570df2be9713189fe6ad3ea30c889be0e2b51a2731fb29c88a6016f8f
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
@@ -18,31 +18,34 @@ jobs:
18
18
  fail-fast: false
19
19
  matrix:
20
20
  os:
21
+ - ubuntu-latest
21
22
  - ubuntu-20.04
22
- - ubuntu-18.04
23
23
  ruby:
24
+ - 3.3
25
+ - 3.2
26
+ - 3.1
24
27
  - "3.0"
25
28
  - 2.7
26
29
  - 2.6
27
30
  include:
28
- - { os: ubuntu-20.04 , ruby: head }
31
+ - { os: ubuntu-latest , ruby: debug }
29
32
 
30
33
  steps:
31
- - uses: actions/checkout@v2
34
+ - uses: actions/checkout@v4
32
35
 
33
36
  - name: Set up Ruby
34
37
  uses: ruby/setup-ruby@v1
35
38
  with:
36
39
  ruby-version: ${{ matrix.ruby }}
37
40
 
38
- - uses: actions/cache@v2
41
+ - uses: actions/cache@v4
39
42
  if: runner.os == 'Linux'
40
43
  with:
41
44
  path: ~/.cache/red-datasets
42
45
  key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
43
46
  restore-keys: ${{ runner.os }}-
44
47
 
45
- - uses: actions/cache@v2
48
+ - uses: actions/cache@v4
46
49
  if: |
47
50
  runner.os == 'macOS'
48
51
  with:
@@ -51,7 +54,7 @@ jobs:
51
54
  key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
52
55
  restore-keys: ${{ runner.os }}-
53
56
 
54
- - uses: actions/cache@v2
57
+ - uses: actions/cache@v4
55
58
  if: |
56
59
  runner.os == 'Windows'
57
60
  with:
@@ -62,6 +65,9 @@ jobs:
62
65
 
63
66
  - run: sudo apt install build-essential libsqlite3-dev
64
67
 
68
+ - run: npm install playwright@latest
69
+ - run: ./node_modules/.bin/playwright install
70
+
65
71
  - run: bundle install --jobs 4 --retry 3 --without "nmatrix python"
66
72
 
67
73
  - run: bundle exec rake
@@ -24,21 +24,21 @@ jobs:
24
24
  - 2.6
25
25
 
26
26
  steps:
27
- - uses: actions/checkout@v2
27
+ - uses: actions/checkout@v4
28
28
 
29
29
  - name: Set up Ruby
30
30
  uses: ruby/setup-ruby@v1
31
31
  with:
32
32
  ruby-version: ${{ matrix.ruby }}
33
33
 
34
- - uses: actions/cache@v2
34
+ - uses: actions/cache@v4
35
35
  if: runner.os == 'Linux'
36
36
  with:
37
37
  path: ~/.cache/red-datasets
38
38
  key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
39
39
  restore-keys: ${{ runner.os }}-
40
40
 
41
- - uses: actions/cache@v2
41
+ - uses: actions/cache@v4
42
42
  if: |
43
43
  runner.os == 'macOS'
44
44
  with:
@@ -47,7 +47,7 @@ jobs:
47
47
  key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
48
48
  restore-keys: ${{ runner.os }}-
49
49
 
50
- - uses: actions/cache@v2
50
+ - uses: actions/cache@v4
51
51
  if: |
52
52
  runner.os == 'Windows'
53
53
  with:
@@ -58,6 +58,9 @@ jobs:
58
58
 
59
59
  - run: sudo apt install build-essential libsqlite3-dev
60
60
 
61
+ - run: npm install playwright@latest
62
+ - run: ./node_modules/.bin/playwright install
63
+
61
64
  - run: bundle install --jobs 4 --retry 3 --without "numo python"
62
65
 
63
66
  - run: bundle exec rake
@@ -19,22 +19,21 @@ jobs:
19
19
  fail-fast: false
20
20
  matrix:
21
21
  os:
22
+ - ubuntu-latest
22
23
  - ubuntu-20.04
23
- - ubuntu-18.04
24
24
  ruby:
25
- - "3.0"
26
- - 2.7
27
- - 2.6
25
+ - 3.3
26
+ - 3.2
27
+ - 3.1
28
28
  python:
29
29
  - 3.x
30
- - 2.x
31
30
  python_architecture:
32
31
  - x64
33
32
  include:
34
- - { os: ubuntu-20.04 , ruby: head , python: 3.x , python_architecture: x64 }
33
+ - { os: ubuntu-latest , ruby: debug , python: 3.x , python_architecture: x64 }
35
34
 
36
35
  steps:
37
- - uses: actions/checkout@v2
36
+ - uses: actions/checkout@v4
38
37
 
39
38
  - name: Setup Ruby
40
39
  uses: ruby/setup-ruby@v1
@@ -42,19 +41,19 @@ jobs:
42
41
  ruby-version: ${{ matrix.ruby }}
43
42
 
44
43
  - name: Setup Python
45
- uses: actions/setup-python@v2
44
+ uses: actions/setup-python@v5
46
45
  with:
47
46
  python-version: ${{ matrix.python }}
48
47
  architecture: ${{ matrix.python_architecture }}
49
48
 
50
- - uses: actions/cache@v2
49
+ - uses: actions/cache@v4
51
50
  if: runner.os == 'Linux'
52
51
  with:
53
52
  path: ~/.cache/red-datasets
54
53
  key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
55
54
  restore-keys: ${{ runner.os }}-
56
55
 
57
- - uses: actions/cache@v2
56
+ - uses: actions/cache@v4
58
57
  if: |
59
58
  runner.os == 'macOS'
60
59
  with:
@@ -63,7 +62,7 @@ jobs:
63
62
  key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
64
63
  restore-keys: ${{ runner.os }}-
65
64
 
66
- - uses: actions/cache@v2
65
+ - uses: actions/cache@v4
67
66
  if: |
68
67
  runner.os == 'Windows'
69
68
  with:
@@ -74,6 +73,9 @@ jobs:
74
73
 
75
74
  - run: sudo apt install build-essential libsqlite3-dev
76
75
 
76
+ - run: npm install playwright@latest
77
+ - run: ./node_modules/.bin/playwright install
78
+
77
79
  - run: pip install --user matplotlib pandas
78
80
 
79
81
  - run: bundle install --jobs 4 --retry 3 --without "nmatrix numo"
data/Gemfile CHANGED
@@ -5,6 +5,13 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5
5
  # Specify your gem's dependencies in charty.gemspec
6
6
  gemspec
7
7
 
8
+ group :activerecord do
9
+ gem "activerecord"
10
+ # This must be synchronized with `gem "sqlite", "..."` in
11
+ # lib/active_record/connection_adapters/sqlite3_adapter.rb.
12
+ gem "sqlite3", "~> 1.4"
13
+ end
14
+
8
15
  group :cruby do
9
16
  gem "enumerable-statistics"
10
17
  end
data/charty.gemspec CHANGED
@@ -39,8 +39,6 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency "test-unit"
40
40
  spec.add_development_dependency "daru"
41
41
  spec.add_development_dependency "matrix" # need for daru on Ruby > 3.0
42
- spec.add_development_dependency "activerecord"
43
- spec.add_development_dependency "sqlite3"
44
42
  spec.add_development_dependency "iruby", ">= 0.7.0"
45
43
  spec.add_development_dependency "csv"
46
44
  end
@@ -309,8 +309,8 @@ module Charty
309
309
 
310
310
  groups = (0 ... x.length).group_by do |i|
311
311
  key = {}
312
- key[:color] = color[i] unless color.nil?
313
- key[:style] = style[i] unless style.nil?
312
+ key[:color] = color.iloc(i) unless color.nil?
313
+ key[:style] = style.iloc(i) unless style.nil?
314
314
  key
315
315
  end
316
316
 
@@ -8,13 +8,17 @@ module Charty
8
8
  end
9
9
 
10
10
  def each(&block)
11
- step = (@range.end - @range.begin).to_r / (@num_step - 1)
12
- (@num_step - 1).times do |i|
13
- block.call(@range.begin + i * step)
14
- end
11
+ if @num_step == 1
12
+ block.call(@range.begin)
13
+ else
14
+ step = (@range.end - @range.begin).to_r / (@num_step - 1)
15
+ (@num_step - 1).times do |i|
16
+ block.call(@range.begin + i * step)
17
+ end
15
18
 
16
- unless @range.exclude_end?
17
- block.call(@range.end)
19
+ unless @range.exclude_end?
20
+ block.call(@range.end)
21
+ end
18
22
  end
19
23
  end
20
24
  end
@@ -185,7 +185,7 @@ module Charty
185
185
  elsif vector.categorical?
186
186
  :categorical
187
187
  else
188
- case vector[0]
188
+ case vector.iloc(0)
189
189
  when true, false
190
190
  boolean_type
191
191
  else
@@ -209,8 +209,11 @@ module Charty
209
209
  observations = sub_data[data_variable].drop_na.to_a
210
210
  params = {}
211
211
  params[:weights] = sub_data[:weights].to_a if sub_data.column?(:weights)
212
- params[:edges] = common_bin_edges if common_bin_edges
213
- hist = Statistics.histogram(observations, bins, **params)
212
+ hist = if common_bin_edges
213
+ Statistics.histogram(observations, edges: common_bin_edges, **params)
214
+ else
215
+ Statistics.histogram(observations, bins, **params)
216
+ end
214
217
 
215
218
  name = sub_vars[:color]
216
219
  backend.univariate_histogram(hist, name, data_variable, stat,
@@ -90,13 +90,14 @@ module Charty
90
90
  end
91
91
 
92
92
  def []=(key, values)
93
+ all_slice = PyCall::Slice.new(nil)
93
94
  case values
94
95
  when Charty::Vector
95
96
  case values.adapter
96
97
  when Charty::VectorAdapters::PandasSeriesAdapter
97
- @data[key] = values.adapter.data
98
+ @data.loc[all_slice, key] = values.adapter.data
98
99
  else
99
- @data[key] = values.to_a
100
+ @data.loc[all_slice, key] = values.to_a
100
101
  end
101
102
  else
102
103
  orig_values = values
@@ -104,7 +105,7 @@ module Charty
104
105
  if values.nil?
105
106
  raise ArgumentError, "`values` must be convertible to Array"
106
107
  end
107
- @data[key] = values
108
+ @data.loc[all_slice, key] = values
108
109
  end
109
110
  return values
110
111
  end
@@ -203,6 +204,17 @@ module Charty
203
204
  end
204
205
 
205
206
  def [](key)
207
+ key = case key
208
+ when PyCall::Tuple
209
+ key
210
+ else
211
+ key = Array(key)
212
+ if key.length == 1 && key[0].is_a?(Integer)
213
+ key[0]
214
+ else
215
+ PyCall::Tuple.new(*key)
216
+ end
217
+ end
206
218
  Charty::Table.new(@groupby.get_group(key))
207
219
  end
208
220
  end
data/lib/charty/vector.rb CHANGED
@@ -34,6 +34,7 @@ module Charty
34
34
 
35
35
  alias size length
36
36
 
37
+ def_delegators :adapter, :iloc
37
38
  def_delegators :adapter, :to_a
38
39
  def_delegators :adapter, :each
39
40
  def_delegators :adapter, :empty?
@@ -61,6 +61,10 @@ module Charty
61
61
  data.equals(Pandas::Series.new(other, index: data.index))
62
62
  end
63
63
 
64
+ def iloc(i)
65
+ data.iloc[i]
66
+ end
67
+
64
68
  def [](key)
65
69
  case key
66
70
  when Charty::Vector
@@ -34,7 +34,8 @@ module Charty
34
34
  :uniq,
35
35
  :unique_values,
36
36
  :values_at,
37
- :where
37
+ :where,
38
+ :iloc
38
39
 
39
40
  def compare_data_equality(other)
40
41
  if other.is_a?(self.class)
@@ -57,6 +57,8 @@ module Charty
57
57
  end
58
58
  end
59
59
 
60
+ def_delegator :data, :[], :iloc
61
+
60
62
  def_delegators :data, :[], :[]=
61
63
  def_delegators :data, :each, :to_a, :empty?
62
64
 
@@ -148,7 +150,7 @@ module Charty
148
150
  when Charty::Vector
149
151
  where(key)
150
152
  else
151
- super(key_to_loc(key))
153
+ iloc(key_to_loc(key))
152
154
  end
153
155
  end
154
156
 
@@ -1,5 +1,5 @@
1
1
  module Charty
2
- VERSION = "0.2.11"
2
+ VERSION = "0.2.13"
3
3
 
4
4
  module Version
5
5
  numbers, TAG = VERSION.split("-")
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: charty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - youchan
8
8
  - mrkn
9
9
  - 284km
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-09-10 00:00:00.000000000 Z
13
+ date: 2024-05-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: red-colors
@@ -166,34 +166,6 @@ dependencies:
166
166
  - - ">="
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
- - !ruby/object:Gem::Dependency
170
- name: activerecord
171
- requirement: !ruby/object:Gem::Requirement
172
- requirements:
173
- - - ">="
174
- - !ruby/object:Gem::Version
175
- version: '0'
176
- type: :development
177
- prerelease: false
178
- version_requirements: !ruby/object:Gem::Requirement
179
- requirements:
180
- - - ">="
181
- - !ruby/object:Gem::Version
182
- version: '0'
183
- - !ruby/object:Gem::Dependency
184
- name: sqlite3
185
- requirement: !ruby/object:Gem::Requirement
186
- requirements:
187
- - - ">="
188
- - !ruby/object:Gem::Version
189
- version: '0'
190
- type: :development
191
- prerelease: false
192
- version_requirements: !ruby/object:Gem::Requirement
193
- requirements:
194
- - - ">="
195
- - !ruby/object:Gem::Version
196
- version: '0'
197
169
  - !ruby/object:Gem::Dependency
198
170
  name: iruby
199
171
  requirement: !ruby/object:Gem::Requirement
@@ -231,6 +203,7 @@ executables: []
231
203
  extensions: []
232
204
  extra_rdoc_files: []
233
205
  files:
206
+ - ".github/dependabot.yml"
234
207
  - ".github/workflows/ci.yml"
235
208
  - ".github/workflows/nmatrix.yml"
236
209
  - ".github/workflows/pycall.yml"
@@ -360,7 +333,7 @@ homepage: https://github.com/red-data-tools/charty
360
333
  licenses:
361
334
  - MIT
362
335
  metadata: {}
363
- post_install_message:
336
+ post_install_message:
364
337
  rdoc_options: []
365
338
  require_paths:
366
339
  - lib
@@ -375,8 +348,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
375
348
  - !ruby/object:Gem::Version
376
349
  version: '0'
377
350
  requirements: []
378
- rubygems_version: 3.2.23
379
- signing_key:
351
+ rubygems_version: 3.5.10
352
+ signing_key:
380
353
  specification_version: 4
381
354
  summary: Visualizing your data in a simple way.
382
355
  test_files: []