ruby-gr 0.0.8 → 0.0.9

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: 898535fe254b0d6a4a457f6583e6d969cf10598f040bc64464f4e5458a151e57
4
- data.tar.gz: a8d0a53dee6d84f52f73c9e014a38ce9def381492abf55b88867a6fe1e6c639f
3
+ metadata.gz: 7feff4b6a6607304d914aa29fbd928eb8038373db422bb97ffc7f2f93e716eca
4
+ data.tar.gz: c1e8c535bcc1f7643654e355d08941aa3b063b08073ab633a271fdb91658250c
5
5
  SHA512:
6
- metadata.gz: f66234f7d19386f36d3106ec6f7e6e529ca5b0f85f6ea1e0bbd13686b3d5d41d2073f3530436dde1a89d1d0c11cfb6fa5f30839d0022e6e67670f33ea91a8aa4
7
- data.tar.gz: 36ca2dca1f723a51d066d063b12601574cf2fb643d4a2221a481642d20f8097982e0fc9500488a2e79b09a01aa8169de7b32237dee75ece63aef39000be5f7a3
6
+ metadata.gz: 7b11313f004e0e6fe8d8203be2aae5966f91404699179af1170af17fad1f4c0f48f8d8fc221813535bee6ae63fd26583520e18a15c26bac90bb79d2961090a91
7
+ data.tar.gz: c28961f5c97d923ff9b1ae713d3f04fa4f77538febbf1de2ef44fce2b2d35c639a80fb74f3bed40b8b158ad73110108795a9d5e6ac0f7790032c0274562964b0
data/README.md CHANGED
@@ -6,9 +6,15 @@
6
6
  [![Gitter Chat](https://badges.gitter.im/red-data-tools/en.svg)](https://gitter.im/red-data-tools/en)
7
7
  [![Docs Latest](https://img.shields.io/badge/docs-latest-blue.svg)](https://rubydoc.info/gems/ruby-gr)
8
8
 
9
+ <p align="center">
10
+ <img src="https://user-images.githubusercontent.com/5798442/70857099-13d57600-1f2c-11ea-8f3c-7d81065f13a5.png">
11
+ </p>
12
+
9
13
  :bar_chart: [GR framework](https://github.com/sciapp/gr) - the graphics library for visualisation - for Ruby
10
14
 
11
15
  ## Installation
16
+ GR.rb supports Ruby 2.4+.
17
+
12
18
  Install [GR](https://github.com/sciapp/gr/releases).
13
19
  Set environment variable GRDIR.
14
20
 
@@ -22,6 +28,8 @@ Add this line to your application's Gemfile:
22
28
  gem 'ruby-gr'
23
29
  ```
24
30
 
31
+ GR3 and GR::Plot require [numo-narray](https://github.com/ruby-numo/numo-narray).
32
+
25
33
  ## Quick Start
26
34
 
27
35
  <p align="center">
data/lib/gr.rb CHANGED
@@ -60,7 +60,7 @@ module GR
60
60
  @ffi_lib = File.expand_path('lib/libGR.so', ENV['GRDIR'])
61
61
  end
62
62
 
63
- require_relative 'gr_commons'
63
+ require_relative 'gr_commons/gr_commons'
64
64
  require_relative 'gr/version'
65
65
  require_relative 'gr/ffi'
66
66
  require_relative 'gr/grbase'
@@ -40,7 +40,7 @@ module GR
40
40
  xlog yflip ylabel ylim ylog zflip zlabel zlim zlog clim
41
41
  subplot].freeze
42
42
 
43
- @@last_plot
43
+ @@last_plot = nil
44
44
  def self.last_plot
45
45
  @@last_plot
46
46
  end
@@ -878,7 +878,8 @@ module GR
878
878
  args.each do |_x, _y, _z, _c, spec|
879
879
  if i < num_labels
880
880
  label = kvs[:labels][i]
881
- tbx, tby = inqtext(0, 0, label)
881
+ label = label.to_s
882
+ _tbx, tby = inqtext(0, 0, label)
882
883
  dy = [(tby[2] - tby[0]) - 0.03, 0].max
883
884
  py -= 0.5 * dy
884
885
  end
@@ -889,14 +890,14 @@ module GR
889
890
  GR.restorestate
890
891
  GR.settextalign(GR::TEXT_HALIGN_LEFT, GR::TEXT_VALIGN_HALF)
891
892
  if i < num_labels
892
- GR.text(px, py, label)
893
+ text(px, py, label)
893
894
  py -= 0.5 * dy
894
895
  i += 1
895
896
  end
896
897
  py -= 0.03
897
- GR.selntran(1)
898
- GR.restorestate
899
898
  end
899
+ GR.selntran(1)
900
+ GR.restorestate
900
901
  end
901
902
 
902
903
  def to_svg
@@ -945,9 +946,22 @@ module GR
945
946
  end
946
947
 
947
948
  def plot_args(args, _fmt = :xys)
948
- # :construction:
949
- x, y, z, c = args
950
- [[x, y, z, c]]
949
+ # FIXME
950
+ args = [args] unless args.all? { |i| i.is_a? Array }
951
+ args.map do |xyzc|
952
+ x, y, z, c = xyzc.map do |i|
953
+ if i.is_a?(Array) || narray?(i)
954
+ i
955
+ elsif i.respond_to?(:to_a)
956
+ # Convert an Array-like class such as Daru::Vector to an Array
957
+ i.to_a
958
+ else
959
+ # String
960
+ i
961
+ end
962
+ end
963
+ [x, y, z, c]
964
+ end
951
965
  end
952
966
 
953
967
  # Normalize a color c with the range [cmin, cmax]
@@ -1066,6 +1080,7 @@ module GR
1066
1080
  w = 0
1067
1081
  h = 0
1068
1082
  kvs[:labels].each do |label|
1083
+ label = label.to_s
1069
1084
  tbx, tby = inqtext(0, 0, label)
1070
1085
  w = [w, tbx[2]].max
1071
1086
  h += [tby[2] - tby[0], 0.03].max
data/lib/gr3.rb CHANGED
@@ -69,7 +69,7 @@ module GR3
69
69
  @ffi_lib = File.expand_path('lib/libGR3.so', ENV['GRDIR'])
70
70
  end
71
71
 
72
- require_relative 'gr_commons'
72
+ require_relative 'gr_commons/gr_commons'
73
73
  require_relative 'gr3/version'
74
74
  require_relative 'gr3/ffi'
75
75
  require_relative 'gr3/gr3base'
@@ -185,7 +185,7 @@ module GRCommons
185
185
 
186
186
  include Fiddley::Utils
187
187
 
188
- def initialize(type, num = 1, _clear = true)
188
+ def initialize(type, num = 1)
189
189
  if num.is_a?(Fiddle::Pointer)
190
190
  @ptr = num
191
191
  @size = @ptr.size
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Module with common code for GR, GR3
4
+ module GRCommons
5
+ end
6
+
7
+ require_relative 'extern'
8
+ require_relative 'define_methods'
9
+ require_relative 'gr_common_utils'
10
+ require_relative 'jupyter_support'
11
+ require_relative 'version'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GRCommons
4
- VERSION = '0.0.8'
4
+ VERSION = '0.0.9'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-gr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-13 00:00:00.000000000 Z
11
+ date: 2019-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -154,11 +154,11 @@ files:
154
154
  - lib/gr3/ffi.rb
155
155
  - lib/gr3/gr3base.rb
156
156
  - lib/gr3/version.rb
157
- - lib/gr_commons.rb
158
157
  - lib/gr_commons/define_methods.rb
159
158
  - lib/gr_commons/extern.rb
160
159
  - lib/gr_commons/fiddley.rb
161
160
  - lib/gr_commons/gr_common_utils.rb
161
+ - lib/gr_commons/gr_commons.rb
162
162
  - lib/gr_commons/jupyter_support.rb
163
163
  - lib/gr_commons/version.rb
164
164
  homepage: https://github.com/red-data-tools/GR.rb
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Module with common code for GR, GR3
4
- module GRCommons
5
- end
6
-
7
- require 'gr_commons/extern'
8
- require 'gr_commons/define_methods'
9
- require 'gr_commons/gr_common_utils'
10
- require 'gr_commons/jupyter_support'
11
- require 'gr_commons/version'