Skip to content

Commit

Permalink
tweak ranges on fake csv
Browse files Browse the repository at this point in the history
  • Loading branch information
mccalluc committed Oct 16, 2024
1 parent 5227110 commit 8cd1e78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ filterwarnings =

addopts = --doctest-glob '*.md' --doctest-modules --ignore dp_creator_ii/templates/ --ignore dp_creator_ii/tests/fixtures/

# If an xfail starts passes unexpectedly, that should count as a failure:
# If an xfail starts passing unexpectedly, that should count as a failure:
xfail_strict=true
11 changes: 8 additions & 3 deletions dp_creator_ii/argparse_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _get_arg_parser():

def _get_args(): # pragma: no cover
arg_parser = _get_arg_parser()
if "--port" in argv or "-v" in argv:
if "--port" in argv or "-v" in argv or "-k" in argv:
# We are running a test,
# and ARGV is polluted, so override:
return arg_parser.parse_args([])
Expand All @@ -66,7 +66,12 @@ def _get_demo_csv_contrib():
>>> with open(csv_path, newline="") as csv_handle:
... reader = csv.DictReader(csv_handle)
... reader.fieldnames
... rows = list(reader)
... rows[0]
... rows[-1]
['student_id', 'class_year', 'hw_number', 'grade']
{'student_id': '1', 'class_year': '2', 'hw_number': '1', 'grade': '73'}
{'student_id': '100', 'class_year': '1', 'hw_number': '10', 'grade': '78'}
"""
random.seed(0) # So the mock data will be stable across runs.

Expand All @@ -77,11 +82,11 @@ def _get_demo_csv_contrib():
fields = ["student_id", "class_year", "hw_number", "grade"]
writer = csv.DictWriter(demo_handle, fieldnames=fields)
writer.writeheader()
for student_id in range(1, 100):
for student_id in range(1, 101):
class_year = int(_clip(random.gauss(2, 1), 1, 4))
# Older students do slightly better in the class:
mean_grade = random.gauss(80, 5) + class_year * 2
for hw_number in range(1, contributions):
for hw_number in range(1, contributions + 1):
grade = int(_clip(random.gauss(mean_grade, 5), 0, 100))
writer.writerow(
{
Expand Down

0 comments on commit 8cd1e78

Please sign in to comment.