Commit 8baa40c4 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[cmd] Standardization: Rename chart_file variable to model_file

parent 8630cb0f
......@@ -88,7 +88,7 @@ def solutions_2_graph(args):
import solution_sort
solution_sort.solutions_2_graph(
args['output'],
args['chart_file'],
args['model_file'],
args['path']
)
......@@ -107,7 +107,7 @@ def solutions_2_json(args):
import solution_sort
solution_sort.solutions_2_json(
args['output'],
args['chart_file'],
args['model_file'],
args['path'],
conditions=not args['no_conditions'], # Reverse the param...
)
......@@ -145,7 +145,7 @@ def solutions_2_common_graph(args):
import solution_sort
solution_sort.solutions_2_common_graph(
args['output'],
args['chart_file'],
args['model_file'],
args['path']
)
......@@ -160,7 +160,7 @@ def solutions_2_occcurrences_matrix(args):
import solution_sort
solution_sort.solutions_2_occcurrences_matrix(
args['output'],
args['chart_file'],
args['model_file'],
args['path'],
transposed=args['transpose_csv']
)
......@@ -298,7 +298,7 @@ def main():
# Default log level: debug
parser.add_argument('-vv', '--verbose', nargs='?', default='info')
# Subparsers
subparsers = parser.add_subparsers(title='subcommands')
subparsers = parser.add_subparsers(title='subcommands', dest="subcommand")
# PS: nargs='?' = optional
# subparser: Compute macs
......@@ -311,7 +311,7 @@ def main():
help=solutions_search.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser_input_file.add_argument('chart_file')
parser_input_file.add_argument('model_file')
# Get final_property alone OR an input_file containing multiple properties
group = parser_input_file.add_mutually_exclusive_group(required=True)
group.add_argument('final_prop', nargs='?',
......@@ -370,7 +370,7 @@ def main():
'solutions_2_graph',
help=solutions_2_graph.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_trajectories.add_argument('chart_file',
parser_trajectories.add_argument('model_file',
help="bcx model file.")
parser_trajectories.add_argument('path',
help="Complete solution file or directory with MAC solutions files "
......@@ -388,7 +388,7 @@ def main():
'solutions_2_json',
help=solutions_2_json.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_solutions_2_json.add_argument('chart_file',
parser_solutions_2_json.add_argument('model_file',
help="bcx model file.")
parser_solutions_2_json.add_argument('path',
help="Complete solution file or directory with MAC solutions files "
......@@ -430,7 +430,7 @@ def main():
'solutions_2_common_graph',
help=solutions_2_common_graph.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_trajectories.add_argument('chart_file',
parser_trajectories.add_argument('model_file',
help="bcx model file.")
parser_trajectories.add_argument('path',
help="Complete solution file or directory with MAC solutions files "
......@@ -448,7 +448,7 @@ def main():
'solutions_2_occcurrences_matrix',
help=solutions_2_occcurrences_matrix.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_occurrences_matrix.add_argument('chart_file',
parser_occurrences_matrix.add_argument('model_file',
help="bcx model file.")
parser_occurrences_matrix.add_argument('path',
help="Directory with MAC solutions files "
......@@ -472,8 +472,9 @@ def main():
parser_merge_macs.add_argument('solutions_directory', nargs='?',
default='result/')
parser_merge_macs.add_argument('--output', nargs='?',
default='result/merged_macs.csv',
help="CSV file: <Final property formula>;<mac>")
default='result/',
help="Directory for the CSV file merged_macs.csv; "
"Structure: <Final property formula>;<mac>")
parser_merge_macs.set_defaults(func=merge_macs)
## Model-related commands ##################################################
......
......@@ -28,7 +28,7 @@ import glob
import csv
import itertools as it
def merge_macs_to_csv(directory, csvfile='merged_macs.csv'):
def merge_macs_to_csv(directory, output_dir, csvfile='merged_macs.csv'):
"""Merge \*mac.txt files from a directory to a csv file.
:Structure of the CSV file:
......@@ -57,7 +57,7 @@ def merge_macs_to_csv(directory, csvfile='merged_macs.csv'):
csv_data.append([[formula] + [line.rstrip('\n')] for line in f_d])
# Write the final csv
with open(csvfile, 'w') as f_d:
with open(output_dir + csvfile, 'w') as f_d:
writer = csv.writer(f_d, delimiter=str(';'))
writer.writerows(it.chain(*csv_data))
......
......@@ -152,11 +152,11 @@ def get_dimacs_start_properties(mcla, previous_frontier_places):
def search_entry_point(
chart_file, mac_file, mac_step_file, mac_complete_file, mac_strong_file,
model_file, mac_file, mac_step_file, mac_complete_file, mac_strong_file,
steps, final_prop, start_prop, inv_prop, all_macs, continue_run, limit):
"""Search solutions
:param chart_file: Model file (bcx, xml, cal).
:param model_file: Model file (bcx, xml, cal).
:param mac_file: File used to store Minimal Activation Condition (MAC/CAM).
:param mac_step_file: File used to store Minimal step numbers for each solution.
:param mac_complete_file: File used to store MAC & trajectories.
......@@ -189,7 +189,7 @@ def search_entry_point(
:param continue_run: If set to True (not default), previous macs from a previous
run, will be reloaded.
:param limit: Limit the number of solutions.
:type chart_file: <str>
:type model_file: <str>
:type mac_file: <str>
:type mac_step_file: <str>
:type mac_complete_file: <str>
......@@ -218,7 +218,7 @@ def search_entry_point(
mcla = MCLAnalyser(ErrorRep())
# Load model file
detect_model_type(mcla, chart_file)(chart_file)
detect_model_type(mcla, model_file)(model_file)
if mcla.reporter.error:
raise "Error during loading of file"
......@@ -472,7 +472,7 @@ def detect_model_type(mclanalyser, filepath):
return build_func[extension]
# def main(chart_file, mac_file, mac_step_file, mac_complete_file, mac_strong_file,
# def main(model_file, mac_file, mac_step_file, mac_complete_file, mac_strong_file,
# steps, final_prop, start_prop, inv_prop, all_macs):
#
# LOGGER.debug("Params: start: {}, inv: {}, final: {}".format(start_prop,
......@@ -495,7 +495,7 @@ def detect_model_type(mclanalyser, filepath):
# # BUILD MCLA
# error_reporter = ErrorRep()
# mcla = MCLAnalyser(error_reporter)
# mcla.build_from_chart_file(chart_file)
# mcla.build_from_chart_file(model_file)
#
# if error_reporter.error:
# #cancel_warn(error_reporter.memory)
......@@ -706,7 +706,7 @@ def compute_macs(params):
sys.setrecursionlimit(10000)
# QUERY PARAMETERS
model_filename = os.path.basename(os.path.splitext(params["chart_file"])[0])
model_filename = os.path.basename(os.path.splitext(params["model_file"])[0])
# FILES
mac_file_prefix = params["output"] + model_filename + "_" + params["final_prop"] + "_mac"
......@@ -736,7 +736,7 @@ def compute_macs(params):
# MAC research
search_entry_point(
params["chart_file"], # chart_file
params["model_file"], # model_file
mac_file, # mac_file
mac_step_file, # mac_step_file
mac_complete_file, # mac_complete_file
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment