MUSA Graderv0.1.0

API reference · assignments/hw1.py · 991 lines

assignments.hw1

Assignment 1 autograder — "The Donut Effect for Philadelphia ZIP Codes".

Graded against assignment_template/assignment-1.ipynb.

The class downloads its own Zillow ZHVI extract, and Zillow revises that file continuously, so absolute row counts, ZIP counts and final percentages are not gradeable facts. These checks ask whether each step in the instructions worked, and verify it against the student's own data:

  • the tidy frame must match the student's own (ZIP x date) grid,
  • the two split frames must partition the student's own Philadelphia ZIPs,
  • the percent-increase function is called on a frame the grader builds, so the right answer is known regardless of what the student loaded,
  • the final comparison is checked for shape and direction, never for a value.

The only fixed values live in rubrics/hw1.yaml, and they are the ones the assignment itself fixes: the Center City ZIP list printed in the template, and the two comparison dates named in the instructions.

Summary

NameKindDescription
HW1Graderclass

Constants

NameValueNotes
DEFAULT_CENTER_WORDS('center', 'centre', 'cc', 'inner', 'inside', 'in', 'within', 'downtown', 'core', 'central')Name words that place a value in one group or the other (see _group_of).
DEFAULT_OUTSIDE_WORDS('outside', 'outer', 'out', 'non', 'not', 'rest', 'other', 'others', 'remaining', 'suburb', 'suburbs', 'beyond', 'excluding', 'noncenter')
DATE_COLUMN_REre.compile('(19|20)\\d{2}[-/_.]?\\d{1,2}|^\\d{1,2}[-/.]\\d{1,2}[-/.](19|20)?\\d{2}$')A Zillow extract's value columns are dates: "2020-03-31", "2020-03", and — once Excel has re-saved the file — "3/31/2020" or "3/31/20".

Classes

class HW1Grader(AssignmentGrader) #[source]

registered grader

No description.

Class attributes

NameTypeDefaultNotes
assignment_id'hw1'

Properties

property id_hints: list[str] #[source]

No description.

property date_hints: list[str] #[source]

No description.

property value_hints: list[str] #[source]

No description.

Rubric checks 6

Each check_<rubric_id> method grades the rubric item with that id and returns one RubricItemResult.

check_data_loading(ctx: GradingContext, item: RubricItem) -> RubricItemResult #[source]

10 ptsstructuralData loaded correctlyrubrics/hw1.yaml

The ZHVI file is read with pandas from a relative path.

Config keys: absolute_path_penalty min_date_columns missing_read_penalty no_dataframe_penalty required_imports

check_philadelphia_subset(ctx: GradingContext, item: RubricItem) -> RubricItemResult #[source]

15 ptsdeterministicData trimmed to Philadelphiarubrics/hw1.yaml

A Philadelphia-only subset of the ZHVI data exists.

Config keys: city_column_hints expected_city_values expected_state_values expected_zip_prefix min_zip_count state_column_hints

check_tidy_transformation(ctx: GradingContext, item: RubricItem) -> RubricItemResult #[source]

20 ptsdeterministicData melted into tidy formatrubrics/hw1.yaml

Wide date columns are melted into rows, with the values in a column named ZHVI as the instructions require.

Config keys: consistency_tolerance min_long_ratio required_value_column value_column_alternatives wrong_name_penalty_ratio

check_center_city_split(ctx: GradingContext, item: RubricItem) -> RubricItemResult #[source]

15 ptsdeterministicCenter City split correctlyrubrics/hw1.yaml

The tidy data is split into a greater-Center-City frame and a frame for the rest of Philadelphia, using the ZIP list supplied in the template.

Config keys: center_city_zips flag_column_credit_ratio min_match_similarity partition_tolerance require_partition

check_percent_increase_function(ctx: GradingContext, item: RubricItem) -> RubricItemResult #[source]

20 ptshidden_testPercent increase function worksrubrics/hw1.yaml

calculate_percent_increase(group_df) returns the percent change in ZHVI between the two dates named in the assignment.

Config keys: abs_tol cases end_date first_last_credit_ratio fraction_form_credit_ratio frame rel_tol selector start_date stub_credit_ratio tabular_return_credit_ratio type whole_frame_credit_ratio

check_donut_effect_comparison(ctx: GradingContext, item: RubricItem) -> RubricItemResult #[source]

10 ptsdeterministicCenter City vs. rest of Philadelphia comparedrubrics/hw1.yaml

Average percent increase is computed per ZIP code for both groups and the two averages are compared.

Config keys: center_words expect_outside_greater outside_words percent_hints plausible_range