gnutemplate 0.1.3 → 0.1.5
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 +4 -4
- data/lib/gnutemplate/version.rb +1 -1
- data/lib/gnutemplate.rb +18 -15
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 938bfcdda59a01c5b28de1b23a331dc0c460a7463fb1d29e5015529d30c44b38
         | 
| 4 | 
            +
              data.tar.gz: 074f1acb7782fe8144a2ccdf080c1585926cbe80ac0168f2a342dc74ce10f22c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2e1fe6e09cce907cf658a4565ce6e66bbdc49737d777ce2be168ecf8cf24abc1917b66155f6a391076ed1071ef9c1f008d280648e0130b0cc6fe538e154fafeb
         | 
| 7 | 
            +
              data.tar.gz: c634c9fb872802587644288d539601380522eb28093af6f045b9d1b43fffc4fd7a62c7eca587ee9635a705b30bbb84677e3ba34f5c5c0c79a5248d79e82d587d
         | 
    
        data/lib/gnutemplate/version.rb
    CHANGED
    
    
    
        data/lib/gnutemplate.rb
    CHANGED
    
    | @@ -53,7 +53,7 @@ module Gnutemplate | |
| 53 53 | 
             
                    set :xtics, "rotate by 90"
         | 
| 54 54 | 
             
                  end
         | 
| 55 55 |  | 
| 56 | 
            -
                  xrange ||= (rows_min.flatten.compact.min)..(rows_max.flatten.compact.max)
         | 
| 56 | 
            +
                  xrange ||= (rows_min.to_a.flatten.compact.min)..(rows_max.to_a.flatten.compact.max)
         | 
| 57 57 | 
             
                  set xrange: xrange
         | 
| 58 58 | 
             
                  set :grid
         | 
| 59 59 | 
             
                  set style: :fill_solid
         | 
| @@ -65,7 +65,7 @@ module Gnutemplate | |
| 65 65 | 
             
                  # X軸はこの場合配列にしなきゃだめ(to_a) これは癖をつけたほうが安全
         | 
| 66 66 |  | 
| 67 67 | 
             
                  args = rows_min.zip(rows_max, titlenames).each.with_index.inject([]) do |result, ((mi, ma, t), i)|
         | 
| 68 | 
            -
                    result += [xrange.to_a, mi, mi, ma, ma, {with: "candlesticks", fc_rgb: colors[i % 4], title: t} ]
         | 
| 68 | 
            +
                    result += [xrange.to_a, mi.to_a, mi.to_a, ma.to_a, ma.to_a, {with: "candlesticks", fc_rgb: colors[i % 4], title: t} ]
         | 
| 69 69 | 
             
                  end
         | 
| 70 70 |  | 
| 71 71 | 
             
                  plot *args
         | 
| @@ -93,7 +93,7 @@ module Gnutemplate | |
| 93 93 | 
             
                    set :xtics, "rotate by 90"
         | 
| 94 94 | 
             
                  end
         | 
| 95 95 |  | 
| 96 | 
            -
                  xrange ||= (rows_min.flatten.compact.min)..(rows_max.flatten.compact.max)
         | 
| 96 | 
            +
                  xrange ||= (rows_min.to_a.flatten.compact.min)..(rows_max.to_a.flatten.compact.max)
         | 
| 97 97 | 
             
                  set xrange: xrange
         | 
| 98 98 | 
             
                  set :grid
         | 
| 99 99 | 
             
                  set style: :fill_solid
         | 
| @@ -105,7 +105,7 @@ module Gnutemplate | |
| 105 105 | 
             
                  # X軸はこの場合配列にしなきゃだめ(to_a) これは癖をつけたほうが安全
         | 
| 106 106 |  | 
| 107 107 | 
             
                  args = rows_min.zip(rows_max, titlenames).each.with_index.inject([]) do |result, ((mi, ma, t), i)|
         | 
| 108 | 
            -
                    result += [xrange.to_a, mi, mi, ma, ma, {with: "candlesticks", fc_rgb: colors[i % 4], title: t} ]
         | 
| 108 | 
            +
                    result += [xrange.to_a, mi.to_a, mi.to_a, ma.to_a, ma.to_a, {with: "candlesticks", fc_rgb: colors[i % 4], title: t} ]
         | 
| 109 109 | 
             
                  end
         | 
| 110 110 |  | 
| 111 111 | 
             
                  plot *args
         | 
| @@ -114,16 +114,18 @@ module Gnutemplate | |
| 114 114 |  | 
| 115 115 | 
             
              def note_histogram(data, labels: nil, pileup: true,
         | 
| 116 116 | 
             
                xmin: nil, xmax: nil, ymin: 0, ymax: nil, bins: 10,
         | 
| 117 | 
            -
                figsize: 1.0, rotate_xtics:  | 
| 117 | 
            +
                figsize: 1.0, rotate_xtics: 45,
         | 
| 118 118 | 
             
                fill: true, alpha: 33, background: nil,
         | 
| 119 119 | 
             
                file: nil, engine: :note)
         | 
| 120 120 |  | 
| 121 | 
            +
                data = [data] if data[0].kind_of?(Numeric) || data[0].nil?
         | 
| 122 | 
            +
             | 
| 121 123 | 
             
                alpha_hex = (alpha * 256 / 100).to_s(16).upcase
         | 
| 122 124 | 
             
                colors = ["##{alpha_hex}CC0000", "##{alpha_hex}00CC00", "##{alpha_hex}0000CC", "##{alpha_hex}888800"]
         | 
| 123 125 |  | 
| 124 | 
            -
                xmax ||= data.flatten.max
         | 
| 125 | 
            -
                xmin ||= data.flatten.min
         | 
| 126 | 
            -
                freqs = data.map {|d| d.histogram(bins, min: xmin, max: xmax) }
         | 
| 126 | 
            +
                xmax ||= data.to_a.flatten.max
         | 
| 127 | 
            +
                xmin ||= data.to_a.flatten.min
         | 
| 128 | 
            +
                freqs = data.map {|d| d.to_a.histogram(bins, min: xmin, max: xmax) }
         | 
| 127 129 | 
             
                ymax ||= freqs.map{ _1[1] }.flatten.max * 1.1
         | 
| 128 130 |  | 
| 129 131 | 
             
                Numo.noteplot do
         | 
| @@ -173,12 +175,11 @@ module Gnutemplate | |
| 173 175 | 
             
                    set :style, :histogram, :cluster, gap:1
         | 
| 174 176 | 
             
                    set :style, :fill_solid, border:-1
         | 
| 175 177 | 
             
                    set boxwidth:0.9
         | 
| 176 | 
            -
                    set :xtic, :rotate, by | 
| 178 | 
            +
                    set :xtic, :rotate, by: rotate_xtics, scale: 0
         | 
| 177 179 |  | 
| 178 180 | 
             
                    xticinterval = (xmax-xmin).to_f / bins
         | 
| 179 181 | 
             
                    set xrange: 0..((xmax-xmin) / xticinterval).to_i
         | 
| 180 182 |  | 
| 181 | 
            -
             | 
| 182 183 | 
             
                    xtics = freqs[0][0]
         | 
| 183 184 | 
             
                    .each.with_index
         | 
| 184 185 | 
             
                    .inject("(") { |result, (x, i)| result += "'#{x-xticinterval/2}-#{x+xticinterval/2}' #{i}," }
         | 
| @@ -195,16 +196,18 @@ module Gnutemplate | |
| 195 196 |  | 
| 196 197 | 
             
              def draw_histogram(data, labels: nil, pileup: true,
         | 
| 197 198 | 
             
                xmin: nil, xmax: nil, ymin: 0, ymax: nil, bins: 10,
         | 
| 198 | 
            -
                figsize: 1.0, rotate_xtics:  | 
| 199 | 
            +
                figsize: 1.0, rotate_xtics: 45,
         | 
| 199 200 | 
             
                fill: true, alpha: 33, background: nil,
         | 
| 200 201 | 
             
                file: nil, engine: :note)
         | 
| 201 202 |  | 
| 203 | 
            +
                data = [data] if data[0].kind_of?(Numeric) || data[0].nil?
         | 
| 204 | 
            +
             | 
| 202 205 | 
             
                alpha_hex = (alpha * 256 / 100).to_s(16).upcase
         | 
| 203 206 | 
             
                colors = ["##{alpha_hex}CC0000", "##{alpha_hex}00CC00", "##{alpha_hex}0000CC", "##{alpha_hex}888800"]
         | 
| 204 207 |  | 
| 205 | 
            -
                xmax ||= data.flatten.max
         | 
| 206 | 
            -
                xmin ||= data.flatten.min
         | 
| 207 | 
            -
                freqs = data.map {|d| d.histogram(bins, min: xmin, max: xmax) }
         | 
| 208 | 
            +
                xmax ||= data.to_a.flatten.max
         | 
| 209 | 
            +
                xmin ||= data.to_a.flatten.min
         | 
| 210 | 
            +
                freqs = data.map {|d| d.to_a.histogram(bins, min: xmin, max: xmax) }
         | 
| 208 211 | 
             
                ymax ||= freqs.map{ _1[1] }.flatten.max * 1.1
         | 
| 209 212 |  | 
| 210 213 | 
             
                Numo.gnuplot do
         | 
| @@ -253,7 +256,7 @@ module Gnutemplate | |
| 253 256 | 
             
                    set :style, :histogram, :cluster, gap:1
         | 
| 254 257 | 
             
                    set :style, :fill_solid, border:-1
         | 
| 255 258 | 
             
                    set boxwidth:0.9
         | 
| 256 | 
            -
                    set :xtic, :rotate, by | 
| 259 | 
            +
                    set :xtic, :rotate, by: rotate_xtics, scale: 0
         | 
| 257 260 |  | 
| 258 261 | 
             
                    xticinterval = (xmax-xmin).to_f / bins
         | 
| 259 262 | 
             
                    set xrange: 0..((xmax-xmin) / xticinterval).to_i
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: gnutemplate
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - showata
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023-10- | 
| 11 | 
            +
            date: 2023-10-09 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: numo-gnuplot
         |