GithubHelp home page GithubHelp logo

mnarayan / matlab_makefile Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kolia/matlab_makefile

0.0 2.0 0.0 136 KB

makefile-like functionality for matlab - saves target results to disk

MATLAB 98.63% Mercury 1.37%
makefile matlab octave pipeline-framework

matlab_makefile's Introduction

kolia's matlab_makefile

A tool for specifying calculations that depend on other calculations that depend on other calculations...

matlab_makefile uses a target.m file and a context matlab structure.

  • The targets.m file specifies which targets depend on which, what functions should be called to build each target, whether the built target should be saved to disk, and how to calculate the paths where results should be saved. Targets are not rebuilt if they can be loaded from disk.

  • context is a matlab structure which contains contextual information: which data set is being used, with which parameters, etc. Information in context is also used to calculate file and folder names where results will be stored.

See examples/targets.m for an example of a target file. Note that the target file MUST be called targets.m

Informally, the grammar for a target is:

 <target> = [':' <target>]                      Example: :target1

 <target> = { @make_function (list of <target>s) }

 <target> = a matlab expression that doesn't match the above 2 rules
  • :target1 stands for 'the result of calculating target1'

  • { @make_function (list of <target>s) } stands for the result of calling make_function with the results from evaluating the list of targets as arguments.

  • Any matlab expression which is not of these two forms stands for itself.

usage

  1. write a targets.m file. see next section and example/targets.m

  2. context = initialize_context() ;

  3. add whatever contextual information you like as additional fields in context

  4. [result,context] = make_target('my_targets_*', context) ;

this will build all targets in targets.m that match pattern 'my_targets_*', using the additional info in context

target.m should contain

  • SAVE_HERE.ROOT_DIRECTORY: root directory where results are saved (string)

  • SAVE_HERE.USING_FOLDERS: N-by-2 cell array specifying in which subdirectory of SAVE_HERE.ROOT_DIRECTORY each result is saved. Each row corresponds to a pair ( dependency , folder ) where - dependency is a string, the name of a target - folder is a function of the context which returns a string, the folder name corresponding to dependency. An example of SAVE_HERE.USING_FOLDERS with a single dependency could be: SAVE_HERE.USING_FOLDERS = {'DataSet' @(context)sprintf('DataSet_%d',context.DataSetNumber)} The result of a calculation which depends on the data set number (42) will be saved in ROOT_DIRECTORY/DataSet_42, whereas the result of a calcuation which does not depend on a data set number will be saved in ROOT_DIRECTORY/.

  • t : a structure containing all targets. Examples: - t.target0.SAVE = { @make_target0 ':target2' 10 ':target4' } ; Here, target0 will be saved to disk because it has the field .SAVE. It will be built by calling the function make_target0 with 3 arguments: the result of building target2, the number 10, and the result of building target4. - t.target1 = matlab expression exp1 the result target1 is the result of matlab expression exp1. The result is not saved to disk, but it is saved in memory inside context.STORE

what it does

Evaluating :target1 starts with the definition t.target1, which can take two froms:

  • t.target1 = :some_other_target

    some_other_target is first sought as context.some_other_target. If some_other_target it is not a field of context it is sought as context.STORE.some_other_target, where previous builds have been stored. If it is not found there and t.target1 has field .SAVE it is sought on disk with filename target1.mat in the folder calculated using context with SAVE_HERE.ROOT_DIRECTORY and SAVE_HERE.USING_FOLDERS. If target1.mat was not found at that location, then some_other_target is calculated using the rule t.some_other_target.

  • t.target1 = { @make_function (list of <target>s) }

    each target in the list of arguments is retrieved from context, context.STORE, from disk, or rebuilt (as above), and then make_function is called with these as arguments.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.