import argparse

if __name__ == '__main__':
    # Argument parsing
    parser = argparse.ArgumentParser()
    parser.add_argument("metric", help="the desired metric",
                        choices=["ais"])
    parser.add_argument("model_path", help="path to the pickled DBM model")
    args = parser.parse_args()

    metric = args.metric
    model_path = args.model_path

import argparse
from pylearn2.utils import serial


def compute_ais(model):
    pass

if __name__ == '__main__':
    # Possible metrics
    metrics = {'ais': compute_ais}

    # Argument parsing
    parser = argparse.ArgumentParser()
    parser.add_argument("metric", help="the desired metric",
                        choices=metrics.keys())
    parser.add_argument("model_path", help="path to the pickled DBM model")
    args = parser.parse_args()

    metric = metrics[args.metric]
    model = serial.load(args.model_path)

    metric(model)

Make the script recuperate the correct method
Make the script recuperate the correct method

  import argparse
+ from pylearn2.utils import serial
+ 
+ 
+ def compute_ais(model):
+     pass
  
  if __name__ == '__main__':
+     # Possible metrics
+     metrics = {'ais': compute_ais}
+ 
      # Argument parsing
      parser = argparse.ArgumentParser()
      parser.add_argument("metric", help="the desired metric",
-                         choices=["ais"])
+                         choices=metrics.keys())
      parser.add_argument("model_path", help="path to the pickled DBM model")
      args = parser.parse_args()
  
-     metric = args.metric
+     metric = metrics[args.metric]
-     model_path = args.model_path
+     model = serial.load(args.model_path)
  
+     metric(model)
+ 
Make the script recuperate the correct method
## Code Before:
import argparse

if __name__ == '__main__':
    # Argument parsing
    parser = argparse.ArgumentParser()
    parser.add_argument("metric", help="the desired metric",
                        choices=["ais"])
    parser.add_argument("model_path", help="path to the pickled DBM model")
    args = parser.parse_args()

    metric = args.metric
    model_path = args.model_path

## Instruction:
Make the script recuperate the correct method
## Code After:
import argparse
from pylearn2.utils import serial


def compute_ais(model):
    pass

if __name__ == '__main__':
    # Possible metrics
    metrics = {'ais': compute_ais}

    # Argument parsing
    parser = argparse.ArgumentParser()
    parser.add_argument("metric", help="the desired metric",
                        choices=metrics.keys())
    parser.add_argument("model_path", help="path to the pickled DBM model")
    args = parser.parse_args()

    metric = metrics[args.metric]
    model = serial.load(args.model_path)

    metric(model)
