ctioga2 0.13.1 → 0.14
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/Changelog +26 -0
 - data/bin/ct2-make-movie +4 -1
 - data/bin/ctioga2 +1 -1
 - data/lib/ctioga2/commands/commands.rb +2 -0
 - data/lib/ctioga2/commands/doc/doc.rb +1 -1
 - data/lib/ctioga2/commands/doc/documentation-commands.rb +38 -0
 - data/lib/ctioga2/commands/doc/html.rb +84 -0
 - data/lib/ctioga2/commands/general-commands.rb +20 -1
 - data/lib/ctioga2/commands/general-functions.rb +26 -0
 - data/lib/ctioga2/commands/general-types.rb +1 -0
 - data/lib/ctioga2/commands/instruction.rb +61 -0
 - data/lib/ctioga2/commands/interpreter.rb +12 -2
 - data/lib/ctioga2/data/datacolumn.rb +38 -0
 - data/lib/ctioga2/data/dataset.rb +6 -5
 - data/lib/ctioga2/data/filters.rb +12 -5
 - data/lib/ctioga2/data/stack.rb +105 -22
 - data/lib/ctioga2/graphics/elements.rb +1 -1
 - data/lib/ctioga2/graphics/elements/curve2d.rb +1 -1
 - data/lib/ctioga2/graphics/elements/element.rb +29 -10
 - data/lib/ctioga2/graphics/elements/primitive.rb +26 -2
 - data/lib/ctioga2/graphics/elements/subplot.rb +7 -1
 - data/lib/ctioga2/graphics/generator.rb +1 -2
 - data/lib/ctioga2/graphics/legends/area.rb +3 -0
 - data/lib/ctioga2/graphics/root.rb +18 -2
 - data/lib/ctioga2/graphics/styles/curve.rb +6 -0
 - data/lib/ctioga2/graphics/styles/drawable.rb +4 -0
 - data/lib/ctioga2/graphics/styles/factory.rb +4 -5
 - data/lib/ctioga2/graphics/styles/plot-types.rb +22 -7
 - data/lib/ctioga2/graphics/subplot-commands.rb +2 -4
 - data/lib/ctioga2/graphics/types.rb +17 -0
 - data/lib/ctioga2/graphics/types/boundaries.rb +10 -0
 - data/lib/ctioga2/graphics/types/boxes.rb +18 -0
 - data/lib/ctioga2/graphics/types/dimensions.rb +4 -0
 - data/lib/ctioga2/graphics/types/grid.rb +98 -4
 - data/lib/ctioga2/graphics/types/point.rb +9 -0
 - data/lib/ctioga2/metabuilder/types/lists.rb +1 -1
 - data/lib/ctioga2/metabuilder/types/styles.rb +5 -3
 - data/lib/ctioga2/plotmaker.rb +28 -5
 - data/lib/ctioga2/postprocess.rb +28 -0
 - data/lib/ctioga2/ruby.rb +7 -0
 - data/lib/ctioga2/utils.rb +45 -0
 - data/lib/ctioga2/version.rb +2 -2
 - metadata +4 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6bef5792441b163c872287441af1c3875eb51ae2
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: dc7ffd6240a7309e651aba7bb7f45cf4e8f204f4
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 87f0530a92f0cd9f5328d1d399325b35108bfafce596e12315181d430307eedcb36771e21fb6f68445c2ba6e5aa233d5faaafdba6aeabac7388a6662908e33e5
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a521da3bd85d7a7c71e3e982f2d524501cd31c4ceee773f8256c2a3620619e923a632e399a84134b851d01a44044c30334a7fdaf1e6de1046f8471f1d1103b87
         
     | 
    
        data/Changelog
    CHANGED
    
    | 
         @@ -1,3 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ctioga2 (0.14)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              * A --bin command to bin data columns
         
     | 
| 
      
 4 
     | 
    
         
            +
              * A --hide command
         
     | 
| 
      
 5 
     | 
    
         
            +
              * A --append command to load a dataset and append it to the previous one
         
     | 
| 
      
 6 
     | 
    
         
            +
              * a --draw-legend-pictogram to draw the legend pictogram of a curve
         
     | 
| 
      
 7 
     | 
    
         
            +
              * Selection of plot elements by class for commands that take several
         
     | 
| 
      
 8 
     | 
    
         
            +
                elements (such as --hide)
         
     | 
| 
      
 9 
     | 
    
         
            +
              * A series of command-file functions like $(xmax), $(yrange) and so on
         
     | 
| 
      
 10 
     | 
    
         
            +
                to gather informations about datasets on the stack
         
     | 
| 
      
 11 
     | 
    
         
            +
              * Can now select the line cap using the /line-cap option (or the 
         
     | 
| 
      
 12 
     | 
    
         
            +
                --line-cap command), especially useful for /path-style=impulses
         
     | 
| 
      
 13 
     | 
    
         
            +
              * Can now select a dataset using its plot #id
         
     | 
| 
      
 14 
     | 
    
         
            +
              * A grid:next specification to automatically switch to the next grid 
         
     | 
| 
      
 15 
     | 
    
         
            +
                element
         
     | 
| 
      
 16 
     | 
    
         
            +
              * More informative error messages when encountering weird data such as
         
     | 
| 
      
 17 
     | 
    
         
            +
                infinite numbers, see http://sourceforge.net/p/ctioga2/tickets/2/
         
     | 
| 
      
 18 
     | 
    
         
            +
              * Automatic styles for even/odd rows/columns of grids
         
     | 
| 
      
 19 
     | 
    
         
            +
              * Switch to YAML for debug output, greatly speeds up writing out debug 
         
     | 
| 
      
 20 
     | 
    
         
            +
                information
         
     | 
| 
      
 21 
     | 
    
         
            +
              * Now, color mixing between sets occur with !! and not ! as before, not to
         
     | 
| 
      
 22 
     | 
    
         
            +
                confuse with plain color mixing
         
     | 
| 
      
 23 
     | 
    
         
            +
              * Quite a few minor improvements/bug fixes
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
             -- Vincent Fourmond <vincent.fourmond@9online.fr>  Thu 18 Feb 20:48:58 CET 2016
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       1 
27 
     | 
    
         
             
            ctioga2 (0.13.1)
         
     | 
| 
       2 
28 
     | 
    
         | 
| 
       3 
29 
     | 
    
         
             
              * Fix installation problems with recent ruby versions
         
     | 
    
        data/bin/ct2-make-movie
    CHANGED
    
    | 
         @@ -281,7 +281,10 @@ for f in args 
     | 
|
| 
       281 
281 
     | 
    
         
             
                             "--set", "index", "#{index}", 
         
     | 
| 
       282 
282 
     | 
    
         
             
                            "-f", file, "--name", name, "-r", ct2_page_size]
         
     | 
| 
       283 
283 
     | 
    
         
             
              puts "Running: #{ct2_cmdline.join(" ")}"
         
     | 
| 
       284 
     | 
    
         
            -
              system(*ct2_cmdline)
         
     | 
| 
      
 284 
     | 
    
         
            +
              if ! system(*ct2_cmdline)
         
     | 
| 
      
 285 
     | 
    
         
            +
                puts " -> failed with error code #$?, aborting"
         
     | 
| 
      
 286 
     | 
    
         
            +
                exit 1
         
     | 
| 
      
 287 
     | 
    
         
            +
              end
         
     | 
| 
       285 
288 
     | 
    
         | 
| 
       286 
289 
     | 
    
         
             
              b = nil
         
     | 
| 
       287 
290 
     | 
    
         | 
    
        data/bin/ctioga2
    CHANGED
    
    
| 
         @@ -293,6 +293,8 @@ module CTioga2 
     | 
|
| 
       293 
293 
     | 
    
         
             
                    if compulsory_args.size != @arguments.size
         
     | 
| 
       294 
294 
     | 
    
         
             
                      raise ArgumentNumberMismatch, "Command #{@name} was called with #{args.size} arguments, but it takes #{@arguments.size}"
         
     | 
| 
       295 
295 
     | 
    
         
             
                    end
         
     | 
| 
      
 296 
     | 
    
         
            +
                    plotmaker_target.interpreter.
         
     | 
| 
      
 297 
     | 
    
         
            +
                      add_instruction(Instruction.new(self, compulsory_args, optional_args))
         
     | 
| 
       296 
298 
     | 
    
         
             
                    args += compulsory_args
         
     | 
| 
       297 
299 
     | 
    
         
             
                    if has_options?
         
     | 
| 
       298 
300 
     | 
    
         
             
                      if optional_args
         
     | 
| 
         @@ -113,7 +113,7 @@ module CTioga2 
     | 
|
| 
       113 
113 
     | 
    
         | 
| 
       114 
114 
     | 
    
         
             
                      os = ""
         
     | 
| 
       115 
115 
     | 
    
         
             
                      for k,v in cmd.optional_arguments
         
     | 
| 
       116 
     | 
    
         
            -
                        os << " /#{k}=#{v.type.name}"
         
     | 
| 
      
 116 
     | 
    
         
            +
                        os << " /#{k.gsub(/_/,'-')}=#{v.type.name}"
         
     | 
| 
       117 
117 
     | 
    
         
             
                      end
         
     | 
| 
       118 
118 
     | 
    
         
             
                      s2 = WordWrapper.wrap(os, size-4) # 4 for the spaces
         
     | 
| 
       119 
119 
     | 
    
         
             
                      str << "\nOptions: #{s2.join("\n    ")}"
         
     | 
| 
         @@ -102,6 +102,44 @@ EOH 
     | 
|
| 
       102 
102 
     | 
    
         
             
            Prints the HTML documentation for all styles.
         
     | 
| 
       103 
103 
     | 
    
         
             
            EOH
         
     | 
| 
       104 
104 
     | 
    
         | 
| 
      
 105 
     | 
    
         
            +
                  HTMLColorsOptions = {
         
     | 
| 
      
 106 
     | 
    
         
            +
                    'columns' => CmdArg.new('integer'),
         
     | 
| 
      
 107 
     | 
    
         
            +
                    'class' => CmdArg.new('text'),
         
     | 
| 
      
 108 
     | 
    
         
            +
                    'div-class' => CmdArg.new('text'),
         
     | 
| 
      
 109 
     | 
    
         
            +
                    'rect-width' => CmdArg.new('integer'),
         
     | 
| 
      
 110 
     | 
    
         
            +
                    'rect-height' => CmdArg.new('integer')
         
     | 
| 
      
 111 
     | 
    
         
            +
                  }
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                  
         
     | 
| 
      
 114 
     | 
    
         
            +
                  WriteHTMLColors = 
         
     | 
| 
      
 115 
     | 
    
         
            +
                    Cmd.new("write-html-colors", nil, "--write-html-colors", 
         
     | 
| 
      
 116 
     | 
    
         
            +
                            [], HTMLColorsOptions) do |plotmaker, opts|
         
     | 
| 
      
 117 
     | 
    
         
            +
                    html = HTML.new(plotmaker.interpreter.doc)
         
     | 
| 
      
 118 
     | 
    
         
            +
                    html.write_colors(opts)
         
     | 
| 
      
 119 
     | 
    
         
            +
                  end
         
     | 
| 
      
 120 
     | 
    
         
            +
                  
         
     | 
| 
      
 121 
     | 
    
         
            +
                  WriteHTMLColors.describe("HTML documentation for colors",
         
     | 
| 
      
 122 
     | 
    
         
            +
                                           <<EOH, DocumentationGenerationGroup)
         
     | 
| 
      
 123 
     | 
    
         
            +
            Prints the HTML documentation for the colors, i.e. a color list.
         
     | 
| 
      
 124 
     | 
    
         
            +
            EOH
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
                  WriteHTMLColorSets = 
         
     | 
| 
      
 127 
     | 
    
         
            +
                    Cmd.new("write-html-color-sets", nil, "--write-html-color-sets", 
         
     | 
| 
      
 128 
     | 
    
         
            +
                            [], HTMLColorsOptions.
         
     | 
| 
      
 129 
     | 
    
         
            +
                                merge({
         
     | 
| 
      
 130 
     | 
    
         
            +
                                        'include' => CmdArg.new('regexp'),
         
     | 
| 
      
 131 
     | 
    
         
            +
                                        'exclude' => CmdArg.new('regexp')
         
     | 
| 
      
 132 
     | 
    
         
            +
                                      })) do |plotmaker, opts|
         
     | 
| 
      
 133 
     | 
    
         
            +
                    html = HTML.new(plotmaker.interpreter.doc)
         
     | 
| 
      
 134 
     | 
    
         
            +
                    html.write_color_sets(opts)
         
     | 
| 
      
 135 
     | 
    
         
            +
                  end
         
     | 
| 
      
 136 
     | 
    
         
            +
                  
         
     | 
| 
      
 137 
     | 
    
         
            +
                  WriteHTMLColorSets.describe("HTML documentation for color sets",
         
     | 
| 
      
 138 
     | 
    
         
            +
                                          <<EOH, DocumentationGenerationGroup)
         
     | 
| 
      
 139 
     | 
    
         
            +
            Prints the HTML documentation for the color sets, i.e. the list of
         
     | 
| 
      
 140 
     | 
    
         
            +
            all the sets together with the corresponding colors
         
     | 
| 
      
 141 
     | 
    
         
            +
            EOH
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
       105 
143 
     | 
    
         | 
| 
       106 
144 
     | 
    
         
             
                  WriteHTMLBackends = 
         
     | 
| 
       107 
145 
     | 
    
         
             
                    Cmd.new("write-html-backends", nil, "--write-html-backends", 
         
     | 
| 
         @@ -279,7 +279,91 @@ module CTioga2 
     | 
|
| 
       279 
279 
     | 
    
         
             
                          end
         
     | 
| 
       280 
280 
     | 
    
         
             
                        end
         
     | 
| 
       281 
281 
     | 
    
         
             
                      end
         
     | 
| 
      
 282 
     | 
    
         
            +
                    end
         
     | 
| 
      
 283 
     | 
    
         
            +
             
     | 
| 
      
 284 
     | 
    
         
            +
                    def write_color_list(colors, opts, out = STDOUT, color_names = nil)
         
     | 
| 
      
 285 
     | 
    
         
            +
                      columns = opts["columns"] || 5
         
     | 
| 
      
 286 
     | 
    
         
            +
                      cls = opts["class"] || "color-list"
         
     | 
| 
      
 287 
     | 
    
         
            +
                      div_cls = opts["div-class"] 
         
     | 
| 
      
 288 
     | 
    
         
            +
                      rw = opts["rect-width"] || 80
         
     | 
| 
      
 289 
     | 
    
         
            +
                      rh = opts["rect-height"] || 40
         
     | 
| 
      
 290 
     | 
    
         
            +
             
     | 
| 
      
 291 
     | 
    
         
            +
                      div_common = (div_cls ? "class='#{div_cls}' style='" :
         
     | 
| 
      
 292 
     | 
    
         
            +
                                      "style='width:#{rw};height:#{rh};")
         
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
      
 294 
     | 
    
         
            +
                                out.puts "<table class='#{cls}'>"
         
     | 
| 
      
 295 
     | 
    
         
            +
             
     | 
| 
      
 296 
     | 
    
         
            +
                      idx = 0
         
     | 
| 
      
 297 
     | 
    
         
            +
                      for color in colors
         
     | 
| 
      
 298 
     | 
    
         
            +
                        if idx % columns == 0
         
     | 
| 
      
 299 
     | 
    
         
            +
                          if idx > 0
         
     | 
| 
      
 300 
     | 
    
         
            +
                            out.puts "</tr>"
         
     | 
| 
      
 301 
     | 
    
         
            +
                          end
         
     | 
| 
      
 302 
     | 
    
         
            +
                          out.puts "<tr>"
         
     | 
| 
      
 303 
     | 
    
         
            +
                        end
         
     | 
| 
      
 304 
     | 
    
         
            +
                        if color
         
     | 
| 
      
 305 
     | 
    
         
            +
                          
         
     | 
| 
      
 306 
     | 
    
         
            +
                          cls = "##{Utils::color_to_html(color)}"
         
     | 
| 
       282 
307 
     | 
    
         | 
| 
      
 308 
     | 
    
         
            +
                          if color_names
         
     | 
| 
      
 309 
     | 
    
         
            +
                            c = color_names[idx]
         
     | 
| 
      
 310 
     | 
    
         
            +
                          else
         
     | 
| 
      
 311 
     | 
    
         
            +
                            c = Utils::color_name_by_value(color)
         
     | 
| 
      
 312 
     | 
    
         
            +
                          end
         
     | 
| 
      
 313 
     | 
    
         
            +
                          cb = if c
         
     | 
| 
      
 314 
     | 
    
         
            +
                                 "#{c}<br/>"
         
     | 
| 
      
 315 
     | 
    
         
            +
                               else
         
     | 
| 
      
 316 
     | 
    
         
            +
                                 ""
         
     | 
| 
      
 317 
     | 
    
         
            +
                               end
         
     | 
| 
      
 318 
     | 
    
         
            +
                          
         
     | 
| 
      
 319 
     | 
    
         
            +
                          out.puts "<td><div #{div_common}background-color: #{cls};color: #{cls};'>#{cb}</div>#{cb}#{cls}</td>"
         
     | 
| 
      
 320 
     | 
    
         
            +
                        else
         
     | 
| 
      
 321 
     | 
    
         
            +
                          out.puts "<td>no color</td>"
         
     | 
| 
      
 322 
     | 
    
         
            +
                        end
         
     | 
| 
      
 323 
     | 
    
         
            +
                        idx += 1
         
     | 
| 
      
 324 
     | 
    
         
            +
                      end
         
     | 
| 
      
 325 
     | 
    
         
            +
                      
         
     | 
| 
      
 326 
     | 
    
         
            +
                      out.puts "</tr></table>"
         
     | 
| 
      
 327 
     | 
    
         
            +
                      
         
     | 
| 
      
 328 
     | 
    
         
            +
                    end
         
     | 
| 
      
 329 
     | 
    
         
            +
             
     | 
| 
      
 330 
     | 
    
         
            +
                    # Writes out a list
         
     | 
| 
      
 331 
     | 
    
         
            +
                    #
         
     | 
| 
      
 332 
     | 
    
         
            +
                    #@todo Split that to just write an ordered list of colors (get
         
     | 
| 
      
 333 
     | 
    
         
            +
                    #their names ?)
         
     | 
| 
      
 334 
     | 
    
         
            +
                    def write_colors(opts, out = STDOUT)
         
     | 
| 
      
 335 
     | 
    
         
            +
                      clrs = Tioga::ColorConstants::constants.sort
         
     | 
| 
      
 336 
     | 
    
         
            +
                      colors = clrs.map do |c|
         
     | 
| 
      
 337 
     | 
    
         
            +
                        Tioga::ColorConstants::const_get(c)
         
     | 
| 
      
 338 
     | 
    
         
            +
                      end
         
     | 
| 
      
 339 
     | 
    
         
            +
                      color_names = clrs.map do |c|
         
     | 
| 
      
 340 
     | 
    
         
            +
                        c.to_s
         
     | 
| 
      
 341 
     | 
    
         
            +
                      end
         
     | 
| 
      
 342 
     | 
    
         
            +
                      
         
     | 
| 
      
 343 
     | 
    
         
            +
                      write_color_list(colors, opts, out, color_names)
         
     | 
| 
      
 344 
     | 
    
         
            +
                    end
         
     | 
| 
      
 345 
     | 
    
         
            +
             
     | 
| 
      
 346 
     | 
    
         
            +
                    def write_color_sets(opts, out = STDOUT)
         
     | 
| 
      
 347 
     | 
    
         
            +
                      sets = Graphics::Styles::CurveStyleFactory::parameters['color'].sets
         
     | 
| 
      
 348 
     | 
    
         
            +
                      set_names = sets.keys.sort
         
     | 
| 
      
 349 
     | 
    
         
            +
             
     | 
| 
      
 350 
     | 
    
         
            +
                      if opts['include']
         
     | 
| 
      
 351 
     | 
    
         
            +
                        set_names = set_names.select do |x|
         
     | 
| 
      
 352 
     | 
    
         
            +
                          x =~ opts['include']
         
     | 
| 
      
 353 
     | 
    
         
            +
                        end
         
     | 
| 
      
 354 
     | 
    
         
            +
                      elsif opts['exclude']
         
     | 
| 
      
 355 
     | 
    
         
            +
                        set_names = set_names.select do |x|
         
     | 
| 
      
 356 
     | 
    
         
            +
                          x !~ opts['exclude']
         
     | 
| 
      
 357 
     | 
    
         
            +
                        end
         
     | 
| 
      
 358 
     | 
    
         
            +
                      end
         
     | 
| 
      
 359 
     | 
    
         
            +
             
     | 
| 
      
 360 
     | 
    
         
            +
                      set_names = sets.keys.sort
         
     | 
| 
      
 361 
     | 
    
         
            +
             
     | 
| 
      
 362 
     | 
    
         
            +
                      for s in set_names
         
     | 
| 
      
 363 
     | 
    
         
            +
                        out.puts "<h5>Color set: <code>#{s}</code></h5>"
         
     | 
| 
      
 364 
     | 
    
         
            +
                        colors = sets[s]
         
     | 
| 
      
 365 
     | 
    
         
            +
                        write_color_list(colors, opts, out)
         
     | 
| 
      
 366 
     | 
    
         
            +
                      end
         
     | 
| 
       283 
367 
     | 
    
         
             
                    end
         
     | 
| 
       284 
368 
     | 
    
         | 
| 
       285 
369 
     | 
    
         | 
| 
         @@ -169,9 +169,13 @@ EOH 
     | 
|
| 
       169 
169 
     | 
    
         
             
            With this on, ctioga2 writes a whole lot of debugging information. You
         
     | 
| 
       170 
170 
     | 
    
         
             
            probably will not need that unless you intend to file a bug report or
         
     | 
| 
       171 
171 
     | 
    
         
             
            to tackle a problem yourself.
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
            Be warned that it *will* slow down very significantly the processing
         
     | 
| 
      
 174 
     | 
    
         
            +
            of ctioga2 (up to hundreds of times slower), especially if you are not
         
     | 
| 
      
 175 
     | 
    
         
            +
            redirecting the output to a file.
         
     | 
| 
       172 
176 
     | 
    
         
             
            EOH
         
     | 
| 
       173 
177 
     | 
    
         | 
| 
       174 
     | 
    
         
            -
                #  
     | 
| 
      
 178 
     | 
    
         
            +
                # Prints the command-line used
         
     | 
| 
       175 
179 
     | 
    
         
             
                EchoCmd = 
         
     | 
| 
       176 
180 
     | 
    
         
             
                  Cmd.new("echo", nil,  "--echo", [ ]) do |plotmaker|
         
     | 
| 
       177 
181 
     | 
    
         
             
                  STDERR.puts "Command-line used: "
         
     | 
| 
         @@ -183,7 +187,22 @@ EOH 
     | 
|
| 
       183 
187 
     | 
    
         
             
            Writes the whole command-line used to standard error, quoted in such a
         
     | 
| 
       184 
188 
     | 
    
         
             
            way that it should be usable directly for copy/paste.
         
     | 
| 
       185 
189 
     | 
    
         
             
            EOH
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
                # Writes down the list of instruction run so far
         
     | 
| 
      
 192 
     | 
    
         
            +
                PrintInstructionsCmd = 
         
     | 
| 
      
 193 
     | 
    
         
            +
                  Cmd.new("print-instructions", nil,  "--print-instructions", [ ]) do |plotmaker|
         
     | 
| 
      
 194 
     | 
    
         
            +
                  for ins in plotmaker.interpreter.instructions
         
     | 
| 
      
 195 
     | 
    
         
            +
                    puts ins.to_s
         
     | 
| 
      
 196 
     | 
    
         
            +
                  end
         
     | 
| 
      
 197 
     | 
    
         
            +
                end
         
     | 
| 
       186 
198 
     | 
    
         | 
| 
      
 199 
     | 
    
         
            +
                PrintInstructionsCmd.describe("Prints the list of all the instructions run so far", 
         
     | 
| 
      
 200 
     | 
    
         
            +
                                 <<EOH, GeneralGroup)
         
     | 
| 
      
 201 
     | 
    
         
            +
            Writes the list of all the instructions run so far.
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
            This is not very helpful for now, possibly.
         
     | 
| 
      
 204 
     | 
    
         
            +
            EOH
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
       187 
206 
     | 
    
         | 
| 
       188 
207 
     | 
    
         
             
              end
         
     | 
| 
       189 
208 
     | 
    
         
             
            end
         
     | 
| 
         @@ -53,6 +53,8 @@ Running this will give the following syntax error: 
     | 
|
| 
       53 
53 
     | 
    
         
             
            Doing it right would require the use of a decent amount of quotes.
         
     | 
| 
       54 
54 
     | 
    
         
             
            EOD
         
     | 
| 
       55 
55 
     | 
    
         | 
| 
      
 56 
     | 
    
         
            +
                # dataset functions
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
       56 
58 
     | 
    
         
             
                FuncPoint = Function.new("point", "Get dataset point information") do |pm, what, spec, *rest|
         
     | 
| 
       57 
59 
     | 
    
         
             
                  dataset = if rest.first
         
     | 
| 
       58 
60 
     | 
    
         
             
                              pm.data_stack.stored_dataset(rest.first)
         
     | 
| 
         @@ -106,6 +108,30 @@ optional third. It is parsed as {type: stored-dataset} 
     | 
|
| 
       106 
108 
     | 
    
         | 
| 
       107 
109 
     | 
    
         
             
            EOD
         
     | 
| 
       108 
110 
     | 
    
         | 
| 
      
 111 
     | 
    
         
            +
                Stats = []
         
     | 
| 
      
 112 
     | 
    
         
            +
                [:x, :y, :z].each do |col|
         
     | 
| 
      
 113 
     | 
    
         
            +
                  [:min, :max, :range, :avg].each do |what|
         
     | 
| 
      
 114 
     | 
    
         
            +
                    name = "#{col}#{what}"
         
     | 
| 
      
 115 
     | 
    
         
            +
                    Stats << Function.new(name, "Gets the #{what} of the #{col} column") do |pm, ds, *rest|
         
     | 
| 
      
 116 
     | 
    
         
            +
                      dataset = pm.data_stack.stored_dataset(ds)
         
     | 
| 
      
 117 
     | 
    
         
            +
                      cln = dataset.send(col)
         
     | 
| 
      
 118 
     | 
    
         
            +
                      clv = cln.values
         
     | 
| 
      
 119 
     | 
    
         
            +
                      case what
         
     | 
| 
      
 120 
     | 
    
         
            +
                      when :range
         
     | 
| 
      
 121 
     | 
    
         
            +
                        "#{clv.min}:#{clv.max}"
         
     | 
| 
      
 122 
     | 
    
         
            +
                      when :avg
         
     | 
| 
      
 123 
     | 
    
         
            +
                        return clv.sum/clv.size
         
     | 
| 
      
 124 
     | 
    
         
            +
                      else
         
     | 
| 
      
 125 
     | 
    
         
            +
                        clv.send(what)
         
     | 
| 
      
 126 
     | 
    
         
            +
                      end
         
     | 
| 
      
 127 
     | 
    
         
            +
                    end
         
     | 
| 
      
 128 
     | 
    
         
            +
                    Stats.last.describe <<EOD
         
     | 
| 
      
 129 
     | 
    
         
            +
            This is replaced by the the value of '#{what}' from the column '#{col}',
         
     | 
| 
      
 130 
     | 
    
         
            +
            applied to the dataset given.
         
     | 
| 
      
 131 
     | 
    
         
            +
            EOD
         
     | 
| 
      
 132 
     | 
    
         
            +
                  end
         
     | 
| 
      
 133 
     | 
    
         
            +
                end
         
     | 
| 
      
 134 
     | 
    
         
            +
                    
         
     | 
| 
       109 
135 
     | 
    
         | 
| 
       110 
136 
     | 
    
         | 
| 
       111 
137 
     | 
    
         
             
              end
         
     | 
| 
         @@ -159,6 +159,7 @@ A dataset that has already been loaded. It is either: 
     | 
|
| 
       159 
159 
     | 
    
         
             
               dataset), 1 the second, -1 the last one, -2 the one before the last
         
     | 
| 
       160 
160 
     | 
    
         
             
               and so on. (it works just like Ruby's arrays).
         
     | 
| 
       161 
161 
     | 
    
         
             
             * The name of a named dataset.
         
     | 
| 
      
 162 
     | 
    
         
            +
             * @#@ followed by the id of a plot element
         
     | 
| 
       162 
163 
     | 
    
         
             
            EOD
         
     | 
| 
       163 
164 
     | 
    
         | 
| 
       164 
165 
     | 
    
         
             
                # Something meant to be fed to PlotStyle#get_axis_style
         
     | 
| 
         @@ -0,0 +1,61 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # instruction.rb: an instruction
         
     | 
| 
      
 2 
     | 
    
         
            +
            # copyright (c) 2015 by Vincent Fourmond
         
     | 
| 
      
 3 
     | 
    
         
            +
              
         
     | 
| 
      
 4 
     | 
    
         
            +
            # This program is free software; you can redistribute it and/or modify
         
     | 
| 
      
 5 
     | 
    
         
            +
            # it under the terms of the GNU General Public License as published by
         
     | 
| 
      
 6 
     | 
    
         
            +
            # the Free Software Foundation; either version 2 of the License, or
         
     | 
| 
      
 7 
     | 
    
         
            +
            # (at your option) any later version.
         
     | 
| 
      
 8 
     | 
    
         
            +
              
         
     | 
| 
      
 9 
     | 
    
         
            +
            # This program is distributed in the hope that it will be useful,
         
     | 
| 
      
 10 
     | 
    
         
            +
            # but WITHOUT ANY WARRANTY; without even the implied warranty of
         
     | 
| 
      
 11 
     | 
    
         
            +
            # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         
     | 
| 
      
 12 
     | 
    
         
            +
            # GNU General Public License for more details (in the COPYING file).
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            require 'ctioga2/utils'
         
     | 
| 
      
 15 
     | 
    
         
            +
            require 'ctioga2/commands/arguments'
         
     | 
| 
      
 16 
     | 
    
         
            +
            require 'ctioga2/commands/groups'
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            module CTioga2
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              module Commands
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                # This class represents an instruction, i.e. the execution of one
         
     | 
| 
      
 24 
     | 
    
         
            +
                # Command. It is different in Command in that, for most of them,
         
     | 
| 
      
 25 
     | 
    
         
            +
                # there will be arguments
         
     | 
| 
      
 26 
     | 
    
         
            +
                class Instruction
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  # The Command
         
     | 
| 
      
 29 
     | 
    
         
            +
                  attr_accessor :command
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  # The list of its arguments, already in the correct type.
         
     | 
| 
      
 32 
     | 
    
         
            +
                  attr_accessor :arguments
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  # The options, already in the correct type
         
     | 
| 
      
 35 
     | 
    
         
            +
                  attr_accessor :options
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  def initialize(cmd, args, opts)
         
     | 
| 
      
 38 
     | 
    
         
            +
                    if not cmd.respond_to?(:run_command)
         
     | 
| 
      
 39 
     | 
    
         
            +
                      c = Interpreter.command(cmd)
         
     | 
| 
      
 40 
     | 
    
         
            +
                      if ! c
         
     | 
| 
      
 41 
     | 
    
         
            +
                        raise "Invalid command #{cmd}"
         
     | 
| 
      
 42 
     | 
    
         
            +
                      end
         
     | 
| 
      
 43 
     | 
    
         
            +
                      cmd = c
         
     | 
| 
      
 44 
     | 
    
         
            +
                    end
         
     | 
| 
      
 45 
     | 
    
         
            +
                    @command = cmd
         
     | 
| 
      
 46 
     | 
    
         
            +
                    @arguments = args
         
     | 
| 
      
 47 
     | 
    
         
            +
                    @options = opts
         
     | 
| 
      
 48 
     | 
    
         
            +
                  end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  # Runs this instruction again
         
     | 
| 
      
 51 
     | 
    
         
            +
                  def run(plotmaker_target)
         
     | 
| 
      
 52 
     | 
    
         
            +
                    @command.run_command(plotmaker_target, @arguments, @options)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  def to_s
         
     | 
| 
      
 56 
     | 
    
         
            +
                    "#{@command.name} #{@arguments.inspect} #{@options.inspect}"
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
              end
         
     | 
| 
      
 60 
     | 
    
         
            +
            end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
         @@ -13,6 +13,7 @@ 
     | 
|
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
            require 'ctioga2/utils'
         
     | 
| 
       15 
15 
     | 
    
         
             
            require 'ctioga2/commands/commands'
         
     | 
| 
      
 16 
     | 
    
         
            +
            require 'ctioga2/commands/instruction'
         
     | 
| 
       16 
17 
     | 
    
         
             
            require 'ctioga2/commands/context'
         
     | 
| 
       17 
18 
     | 
    
         
             
            require 'ctioga2/commands/variables'
         
     | 
| 
       18 
19 
     | 
    
         
             
            require 'ctioga2/commands/strings'
         
     | 
| 
         @@ -65,8 +66,6 @@ module CTioga2 
     | 
|
| 
       65 
66 
     | 
    
         
             
                  # All types defined so fat
         
     | 
| 
       66 
67 
     | 
    
         
             
                  @@types = {}
         
     | 
| 
       67 
68 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
69 
     | 
    
         
             
                  # Registers a given command. This is called automatically from
         
     | 
| 
       71 
70 
     | 
    
         
             
                  # Command.new, so you should not have to do it yourself.
         
     | 
| 
       72 
71 
     | 
    
         
             
                  def self.register_command(command)
         
     | 
| 
         @@ -166,6 +165,9 @@ module CTioga2 
     | 
|
| 
       166 
165 
     | 
    
         
             
                  # The current context
         
     | 
| 
       167 
166 
     | 
    
         
             
                  attr_accessor :context
         
     | 
| 
       168 
167 
     | 
    
         | 
| 
      
 168 
     | 
    
         
            +
                  # The list of Instruction that were run so far
         
     | 
| 
      
 169 
     | 
    
         
            +
                  attr_accessor :instructions
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
       169 
171 
     | 
    
         
             
                  # Creates an Interpreter with _target_ as the PlotMaker target
         
     | 
| 
       170 
172 
     | 
    
         
             
                  # object.
         
     | 
| 
       171 
173 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -192,7 +194,15 @@ module CTioga2 
     | 
|
| 
       192 
194 
     | 
    
         | 
| 
       193 
195 
     | 
    
         
             
                    @file_parser = Parsers::FileParser.new
         
     | 
| 
       194 
196 
     | 
    
         
             
                    @context = ParsingContext.new
         
     | 
| 
      
 197 
     | 
    
         
            +
                    @instructions = []
         
     | 
| 
      
 198 
     | 
    
         
            +
                  end
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
                  # Adds the given instruction to the list of Instruction that
         
     | 
| 
      
 201 
     | 
    
         
            +
                  # were run so far.
         
     | 
| 
      
 202 
     | 
    
         
            +
                  def add_instruction(instruction)
         
     | 
| 
      
 203 
     | 
    
         
            +
                    @instructions << instruction
         
     | 
| 
       195 
204 
     | 
    
         
             
                  end
         
     | 
| 
      
 205 
     | 
    
         
            +
                                    
         
     | 
| 
       196 
206 
     | 
    
         | 
| 
       197 
207 
     | 
    
         
             
                  # Calls the given function and returns the result
         
     | 
| 
       198 
208 
     | 
    
         
             
                  def call_function(name, args)
         
     | 
| 
         @@ -291,6 +291,44 @@ module CTioga2 
     | 
|
| 
       291 
291 
     | 
    
         
             
                    end
         
     | 
| 
       292 
292 
     | 
    
         
             
                  end
         
     | 
| 
       293 
293 
     | 
    
         | 
| 
      
 294 
     | 
    
         
            +
                  # Bins the values of the columns into nb bins between min and
         
     | 
| 
      
 295 
     | 
    
         
            +
                  # max. Values outside that range are not taken into account. If
         
     | 
| 
      
 296 
     | 
    
         
            +
                  # @a normalize is true, then each value is normalized by the
         
     | 
| 
      
 297 
     | 
    
         
            +
                  # total number of samples.
         
     | 
| 
      
 298 
     | 
    
         
            +
                  #
         
     | 
| 
      
 299 
     | 
    
         
            +
                  # It returns [xv, yv], where xv are the centers of the bins, and
         
     | 
| 
      
 300 
     | 
    
         
            +
                  # yv the counts
         
     | 
| 
      
 301 
     | 
    
         
            +
                  #
         
     | 
| 
      
 302 
     | 
    
         
            +
                  # Does not take into account the error columns.
         
     | 
| 
      
 303 
     | 
    
         
            +
                  def bin(min, max, nb, normalize = false)
         
     | 
| 
      
 304 
     | 
    
         
            +
                    total = @values.size*1.0
         
     | 
| 
      
 305 
     | 
    
         
            +
                    xv = Dobjects::Dvector.new(nb)
         
     | 
| 
      
 306 
     | 
    
         
            +
                    yv = Dobjects::Dvector.new(nb)
         
     | 
| 
      
 307 
     | 
    
         
            +
             
     | 
| 
      
 308 
     | 
    
         
            +
                    0.upto(nb-1) do |i|
         
     | 
| 
      
 309 
     | 
    
         
            +
                      xv[i] = min + (max-min)*(i+0.5)/nb
         
     | 
| 
      
 310 
     | 
    
         
            +
                      yv[i] = 0
         
     | 
| 
      
 311 
     | 
    
         
            +
                    end
         
     | 
| 
      
 312 
     | 
    
         
            +
                    
         
     | 
| 
      
 313 
     | 
    
         
            +
                    for v in @values
         
     | 
| 
      
 314 
     | 
    
         
            +
                      idx = (v-min)/(max-min)
         
     | 
| 
      
 315 
     | 
    
         
            +
                      if idx > 1.0 or idx < 0
         
     | 
| 
      
 316 
     | 
    
         
            +
                        next
         
     | 
| 
      
 317 
     | 
    
         
            +
                      end
         
     | 
| 
      
 318 
     | 
    
         
            +
                      idx = (idx*nb).to_i
         
     | 
| 
      
 319 
     | 
    
         
            +
                      if idx == nb
         
     | 
| 
      
 320 
     | 
    
         
            +
                        idx = nb-1          # case v = max
         
     | 
| 
      
 321 
     | 
    
         
            +
                      end
         
     | 
| 
      
 322 
     | 
    
         
            +
                      yv[idx] += 1
         
     | 
| 
      
 323 
     | 
    
         
            +
                    end
         
     | 
| 
      
 324 
     | 
    
         
            +
             
     | 
| 
      
 325 
     | 
    
         
            +
                    if normalize
         
     | 
| 
      
 326 
     | 
    
         
            +
                      yv *= (1.0/total)
         
     | 
| 
      
 327 
     | 
    
         
            +
                    end
         
     | 
| 
      
 328 
     | 
    
         
            +
             
     | 
| 
      
 329 
     | 
    
         
            +
                    return [xv, yv]
         
     | 
| 
      
 330 
     | 
    
         
            +
                  end
         
     | 
| 
      
 331 
     | 
    
         
            +
             
     | 
| 
       294 
332 
     | 
    
         
             
                  # Averages over the given indices, and puts the result at the
         
     | 
| 
       295 
333 
     | 
    
         
             
                  # target index.
         
     | 
| 
       296 
334 
     | 
    
         
             
                  #
         
     |