def test_case_for_transposes(batch, beta, trans_lhs, trans_rhs): """ Create a list of strings corresponding to separate lines in the full test case. The output contains headers, includes, setup and all the tests for the test case. """ scriptname = os.path.basename(__file__) test_case = TEST_CASE_TPL.format(batch=batch, beta=beta, trans_lhs=trans_lhs, trans_rhs=trans_rhs) output = [ helpers.get_license(), helpers.get_dont_modify_comment(scriptname=scriptname), INCLUDES, DATA_TYPES, TYPED_TEST_SUITE_DECL_TPL.format( test_case=test_case, trans_lhs=helpers.to_lower_case_str(trans_lhs), trans_rhs=helpers.to_lower_case_str(trans_rhs)), ] in_sizes = get_input_sizes() for m, k, n in itertools.product(in_sizes, in_sizes, in_sizes): output.extend( get_test_lines(batch, m, k, n, beta, trans_lhs, trans_rhs)) return output
def output_for_test_case(test_case): """ Create a list of strings corresponding to separate lines in the full test case. The output contains headers, includes, setup and all the tests for the test case. """ scriptname = os.path.basename(__file__) camel_case_type = helpers.to_camel_case(test_case.test_type) test_case_name = TEST_CASE_TPL.format( test_type=camel_case_type, direction=helpers.to_camel_case(test_case.direction), operation=helpers.to_camel_case(test_case.operation)) output = [ helpers.get_license(), helpers.get_dont_modify_comment(scriptname=scriptname), INCLUDES, TYPED_TEST_CASE_DECL_TPL.format( test_case=test_case_name, direction=DIRECTION_MAP[test_case.direction], operation=OPERATION_MAP[test_case.operation]), ] for test_params in test_params_for_test_case(test_case): output.extend(get_test_lines(test_case, test_params)) output.append("\n") return output
def get_initial_boilerplate(): """ Get the boilerplate for the top of the test file. """ scriptname = os.path.basename(__file__) return [ helpers.get_license(), helpers.get_dont_modify_comment(scriptname=scriptname), INCLUDES, DATA_TYPES, ]
def transpose_test_case(n_dimensions): """ Create a list of strings corresponding to separate lines in the full test case. The output contains headers, includes, setup and all the tests for the test case. """ scriptname = os.path.basename(__file__) test_case = TEST_CASE_TPL.format(n_dimensions=n_dimensions) output = [ helpers.get_license(), helpers.get_dont_modify_comment(scriptname=scriptname), INCLUDES, DATA_TYPES, TYPED_TEST_SUITE_DECL_TPL.format(test_case=test_case), ] for in_shape, permutation in test_cases(n_dimensions): output.extend(get_test_lines(in_shape, permutation)) return output
def output_for_test_case(test_case): """ Create a list of strings corresponding to separate lines in the full test case. The output contains headers, includes, setup and all the tests for the test case. """ scriptname = os.path.basename(__file__) camel_case_type = helpers.to_camel_case(test_case.test_type) test_case_name = TEST_CASE_TPL.format(test_type=camel_case_type, window=test_case.window, stride=test_case.stride) output = [ helpers.get_license(), helpers.get_dont_modify_comment(scriptname=scriptname), INCLUDES, DATA_TYPES, TYPED_TEST_SUITE_DECL_TPL.format(test_case=test_case_name, window=test_case.window, stride=test_case.stride) ] for test_params in test_params_for_test_case(test_case): output.extend(get_test_lines(test_case, test_params)) return output
def main(argv: argparse.Namespace): """Executes program. :param argv: object holding attributes parsed from command-line args.""" # Check everything is properly configured (Anti-TL;DR) error = False if not consts.TEMPLATE_DIR.exists(): print(f"Error: directory `{consts.TEMPLATE_DIR}` doesn't exist.") error = True else: with open(consts.PROGRAM_DIR / "config.json") as f: config = json.load(f) if config["USERNAME"] is None: print("Error: A GitHub username was not configured.") error = True if error: print("\nBefore using the program, please take some time to read the " "documentation and configure the needed files.") exit() # Initialise logging helpers.start_logging(argv.verbose) # If a folder is not provided, set project folder to current folder project_folder = helpers.get_project_folder(argv.folder) # Gather rest of information repo_name = helpers.get_repo_name(argv.name) repo_description = helpers.get_repo_description(argv.description) project_license = helpers.get_license(argv.license) # Check out print(f"\n{'Repository name:':>25} {repo_name}") print(f"{'Repository description:':>25} {repo_description}") print(f"{'Project license:':>25} {project_license}") print(f"{'Project folder:':>25} {project_folder}") if not helpers.empty_folder(project_folder): print("\n *** WARNING: project folder is not empty!! ***") print("Make sure there is no confidential information inside") helpers.get_user_approval() print("\nStarting...\n") # [Step-1] Build readme.md # =================================================================== actions.build_readme(repo_name, repo_description, project_license, project_folder, config["README_CONTENT"]) # [Step-2] Copy template files # =================================================================== actions.copy_templates(project_license, project_folder, config["ENABLE_GH_PAGES"]) # [Step-3] Build index.md and _config.yml files # =================================================================== if config["ENABLE_GH_PAGES"]: actions.build_gh_pages(repo_description, project_folder, config["JEKILL_CONFIG"]) # [Step-4] Create a virtual environment for the project # =================================================================== actions.build_environment(project_folder, config["PYTHON_VERSION"]) # [Step-5] Install linter # =================================================================== actions.install_linter(project_folder, config["LINTER"]) # [Step-6] Get interpreter path inside the virtual environment # =================================================================== interpreter_path = actions.get_interpreter_path(project_folder) # [Step-7] Building VSCode settings file # =================================================================== actions.build_vscode_settings(project_folder, config["LINTER"], interpreter_path) # [Step-8] Initialise git in project directory # =================================================================== actions.initialise_git(project_folder) # [Step-9] Add all not .gitignored files to the stage area # =================================================================== actions.stage_files(project_folder) # [Step-10] Commit files to the local repository # =================================================================== actions.commit_files(project_folder) # [Step-11] Authentication for GitHub API v3 # =================================================================== headers = actions.build_headers(config["USERNAME"]) # [Step-12] Create the remote repository in GitHub # =================================================================== remote_path = actions.create_remote_repository(repo_name, repo_description, headers) # [Step-13] Add a remote pointing to GitHub repository # =================================================================== actions.add_origin(project_folder, remote_path) # [Step-14] Push local commit to remote repository # =================================================================== actions.update_remote(project_folder) # [Step-15] Enable GitHub pages # =================================================================== if config["ENABLE_GH_PAGES"]: actions.enable_pages(headers, remote_path) # [Step-16] Request page build to include the new project in personal blog # =================================================================== if config["ENABLE_GH_PAGES"]: actions.build_pages(config["USERNAME"], headers) # [Finished] # =================================================================== print(f"\nWork successfully finished!") print(f" - Check the log file at `{consts.LOG_FILE}`") print(f" - Check the project files at `{project_folder}`") print(" - Check the remote repository at `https://github.com/" f"{remote_path}`")