#!/usr/bin/env python
"""
.. todo::

    WRITEME
"""
#usage: show_weights.py model.pkl
from pylearn2.gui import get_weights_report
import argparse

def main():
    """
    .. todo::

        WRITEME
    """
    parser = argparse.ArgumentParser()

    parser.add_argument("--rescale", default="individual")
    parser.add_argument("--out", default=None)
    parser.add_argument("--border", action="store_true", default=False)
    parser.add_argument("path")

    options = parser.parse_args()

    pv = get_weights_report.get_weights_report(model_path=options.path,
                                               rescale=options.rescale,
                                               border=options.border)

    if options.out is None:
        pv.show()
    else:
        pv.save(options.out)

if __name__ == "__main__":
    main()

@@ -23,474 +23,529 @@
 %22%22%22%0A
-.. todo::%0A%0A    WRITEME%0A%22%22%22%0A#usage: show_weights.py model.pkl%0Afrom pylearn2.gui import get_weights_report%0Aimport argparse%0A%0Adef main():%0A    %22%22%22%0A    .. todo::%0A%0A        WRITEME%0A    %22%22%22%0A    parser = argparse.ArgumentParser()
+Visualizes the weight matrices of a pickled model%0A%22%22%22%0Aimport argparse%0A%0Afrom pylearn2.gui import get_weights_report%0A%0A%0Adef show_weights(model_path, rescale=%22individual%22,%0A                 border=False, out=None):%0A    %22%22%22%0A    Show or save weights to an image for a pickled model
 %0A%0A    
-parser.add_argument(%22--rescale%22, default=%22individual%22)%0A    parser.add_argument(%22--out%22, default=None)%0A    parser.add_argument(%22--border%22, action=%22store_true%22, default=False)%0A    parser.add_argument(%22path%22)%0A%0A    options = parser.parse_args()%0A
+Parameters%0A    ----------%0A    model_path : str%0A        Path of the model to show weights for%0A    rescale : str%0A        WRITEME%0A    border : bool, optional%0A        WRITEME%0A    out : str, optional%0A        Output file to save weights to%0A    %22%22%22
 %0A   
@@ -599,24 +599,22 @@
 el_path=
-options.
+model_
 path,%0A  
@@ -666,24 +666,16 @@
 rescale=
-options.
 rescale,
@@ -729,24 +729,16 @@
  border=
-options.
 border)%0A
@@ -745,24 +745,16 @@
 %0A    if 
-options.
 out is N
@@ -807,55 +807,566 @@
 ve(o
-ptions.out)%0A%0Aif __name__ == %22__main__%22:%0A    main(
+ut)%0A%0A%0Adef make_argument_parser():%0A    %22%22%22%0A    Creates an ArgumentParser to read the options for this script from%0A    sys.argv%0A    %22%22%22%0A    parser = argparse.ArgumentParser()%0A%0A    parser.add_argument(%22--rescale%22, default=%22individual%22)%0A    parser.add_argument(%22--out%22, default=None)%0A    parser.add_argument(%22--border%22, action=%22store_true%22, default=False)%0A    parser.add_argument(%22path%22)%0A    return parser%0A%0Aif __name__ == %22__main__%22:%0A    parser = make_argument_parser()%0A    args = parser.parse_args()%0A    show_weights(args.path, args.rescale, args.border, args.out
 )%0A

Refactor show_weights.py to allow unit testing