How to use series_strategy method in pandera

Best Python code snippet using pandera_python

grader.py

Source:grader.py Github

copy

Full Screen

1#!/usr/bin/python32import click3import configparser4import json5import sys6import os.path7# Hard-coded rubric8# TODO: Load from a configuration file9RUBRIC = [10 ("Task 1: One Dollar", "one_dollar", 10),11 ("Task 1: Double On Win", "double_on_win", 15),12 ("Task 1: Double On Loss", "double_on_loss", 15),13 ("Task 1: Fibonacci Strategy", "fib_strategy", 20),14 ("Task 1: Series Strategy", "series_strategy", 25),15 ("Task 2: Multiple games - One Dollar", "multiple_one_dollar", 3),16 ("Task 2: Multiple games - Double on Win", "multiple_double_on_win", 3),17 ("Task 2: Multiple games - Double on Loss", "multiple_double_on_loss", 3),18 ("Task 2: Multiple games - Fibonacci Strategy", "multiple_fib_strategy", 3),19 ("Task 2: Multiple games - Series Strategy", "multiple_series_strategy", 3)20 ]21def print_empty_gradescope():22 gradescope_json = {}23 gradescope_json["score"] = 0.024 gradescope_json["output"] = "We were unable to run the tests due to an error in your code."25 gradescope_json["visibility"] = "visible"26 gradescope_json["stdout_visibility"] = "visible"27 print(json.dumps(gradescope_json, indent=2))28@click.command(name="criterion-grader")29@click.option('--json-file', type=click.Path(), default="results.json")30@click.option('--csv', is_flag=True)31@click.option('--gradescope', is_flag=True)32def cmd(json_file, csv, gradescope):33 def fail(msg):34 print(msg, file=sys.stderr)35 if gradescope:36 print_empty_gradescope()37 sys.exit(0)38 else:39 sys.exit(1)40 if not os.path.exists(json_file):41 msg = "No such file: {}\n".format(json_file)42 msg += "Make sure you run py.test before running the grader!"43 fail(msg)44 with open(json_file) as f:45 results = json.load(f)46 rubric_ids = [x[1] for x in RUBRIC]47 tests = {}48 for rubric_id in rubric_ids:49 tests[rubric_id] = {}50 for test_suite in results["test_suites"]:51 rubric_entry = test_suite["name"]52 53 for test in test_suite["tests"]:54 test_id = test["name"]55 if test["status"] == "PASSED":56 tests[rubric_entry][test_id] = 157 else:58 tests[rubric_entry][test_id] = 059 scores = {}60 for rubric_id in rubric_ids:61 num_total = len(tests[rubric_id])62 num_success = sum(tests[rubric_id].values())63 num_failed = num_total - num_success64 scores[rubric_id] = (num_success, num_failed, num_total)65 empty_categories = [rubric_id for rubric_id in rubric_ids if len(tests[rubric_id]) == 0]66 if gradescope:67 gradescope_json = {}68 gradescope_json["tests"] = []69 if len(empty_categories) > 0:70 msg = "WARNING: The following test suites had no test results:", ", ".join(empty_categories)71 msg += "\n Make sure you run py.test without '-k' before you run the grader\n"72 fail(msg)73 pscores = []74 pscore = 0.075 if not csv and not gradescope:76 print("%-62s %-6s / %-10s %-6s / %-10s" % ("Category", "Passed", "Total", "Score", "Points"))77 print("-" * 100)78 total_points = 0.079 for rubric_name, rubric_id, rubric_points in RUBRIC:80 total_points += rubric_points81 (num_success, num_failed, num_total) = scores[rubric_id]82 if num_total == 0:83 cscore = 0.084 else:85 cscore = (float(num_success) / num_total) * rubric_points86 pscore += cscore87 if not csv and not gradescope:88 print("%-62s %-6i / %-10i %-6.2f / %-10.2f" % (rubric_name, num_success, num_total, cscore, rubric_points))89 elif gradescope:90 gs_test = {}91 gs_test["score"] = cscore92 gs_test["max_score"] = rubric_points93 gs_test["name"] = rubric_name94 gradescope_json["tests"].append(gs_test)95 if not csv and not gradescope:96 print("-" * 100)97 print("%81s = %-6.2f / %-10i" % ("TOTAL", pscore, total_points))98 print("=" * 100)99 print()100 pscores.append(pscore)101 if csv:102 print(",".join([str(s) for s in pscores]))103 elif gradescope:104 gradescope_json["score"] = pscore105 gradescope_json["visibility"] = "visible"106 gradescope_json["stdout_visibility"] = "visible"107 print(json.dumps(gradescope_json, indent=2))108if __name__ == "__main__":...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1from .multiposition import MultiPositionStrategy2from .series_strategy import SeriesSignals, SeriesStrategy...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pandera automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful