numo-gnuplot 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/numo/gnuplot.rb +26 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d5e544ba0f4909259490066ff280df9562cbc44
4
- data.tar.gz: e640abea3b8753a94265fe4c9a1c9bce8eb6b0f5
3
+ metadata.gz: e5064afaa692cccf4077c9492ab467cefa3ef796
4
+ data.tar.gz: 5ffb4ca3e9186be9f407d78574c6d3a1c28f9967
5
5
  SHA512:
6
- metadata.gz: 8d16164e9871ee7a6b5f8749ed8b06ce83e07992a5ab450dd30350f0b2ca9d4b245ef6c843bdd5eb5582c73f9113cbfd752530e55f7eac025646535b0aaa09a9
7
- data.tar.gz: d0bc21a42e7187fb5c1ba79a9cb1f3f1d7dbe8bfba42d4b4d8d26ffba5e503146de3179555778439a64eba34c155090db27ed4622a88e4d833fe907fa5b08e8b
6
+ metadata.gz: 270d969fb495edcbcbaef29c48e4047e1d9b9e501ed027203109534ee89fcde62fcef8eb945fa7b92a4c8d29d47a7a01bb2ef142edb3422e4ab7e87867ec14ec
7
+ data.tar.gz: 0f88298db5e01193da0fc5aa848c56f3b98b365b798192d9bd5d8fcf091b644bd18ae0888a91f5b2ec52a9831d9dd94da77daa813eee726786a2f4536f136500
data/lib/numo/gnuplot.rb CHANGED
@@ -11,9 +11,9 @@ module Numo
11
11
 
12
12
  class Gnuplot
13
13
 
14
- VERSION = "0.1.4"
14
+ VERSION = "0.1.5"
15
15
  POOL = []
16
- DATA_FORMAT = "%.5g"
16
+ DATA_FORMAT = "%.7g"
17
17
 
18
18
  class GnuplotError < StandardError; end
19
19
 
@@ -419,7 +419,7 @@ class Gnuplot
419
419
  elsif defined?(::NArray)
420
420
  return true if a.kind_of?(::NArray)
421
421
  elsif defined?(::NMatrix)
422
- return true if a.kind_of?(::NMatix)
422
+ return true if a.kind_of?(::NMatrix)
423
423
  end
424
424
  false
425
425
  end
@@ -514,7 +514,7 @@ class Gnuplot
514
514
  def initialize(*data)
515
515
  @data = data.map{|a| a.flatten}
516
516
  @n = @data.map{|a| a.size}.min
517
- @text = false
517
+ @text = true
518
518
  end
519
519
 
520
520
  def cmd_str
@@ -527,10 +527,9 @@ class Gnuplot
527
527
 
528
528
  def data_str
529
529
  if @text
530
- f = ([data_format]*@data.size).join(" ")+"\n"
531
530
  s = ""
532
- @n.times{|i| s << f % @data.map{|a| a[i]}}
533
- s+"\ne"
531
+ @n.times{|i| s << line_str(i)+"\n"}
532
+ s + "e"
534
533
  elsif defined? Numo::NArray
535
534
  m = @data.size
536
535
  x = Numo::DFloat.zeros(@n,m)
@@ -543,6 +542,26 @@ class Gnuplot
543
542
  end
544
543
  end
545
544
 
545
+ def line_str(i)
546
+ @data.map do |a|
547
+ v = a[i]
548
+ case v
549
+ when Float,Rational
550
+ s = data_format % v
551
+ when Numeric
552
+ s = v.to_s
553
+ else
554
+ s = v.to_s
555
+ if /"/ =~ s
556
+ kernel_raise GnuplotError,"should not include double quotation in data"
557
+ elsif / / =~ s
558
+ s = '"'+s+'"'
559
+ end
560
+ end
561
+ s
562
+ end.join(" ")
563
+ end
564
+
546
565
  def self.array_shape(a)
547
566
  if a.kind_of?(Array)
548
567
  is_2d = true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numo-gnuplot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-19 00:00:00.000000000 Z
11
+ date: 2016-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler