Skip to content

Add unit tests and refactor date cleaning into function#13

Open
hl3986-wq wants to merge 4 commits intomainfrom
part3-unit-tests
Open

Add unit tests and refactor date cleaning into function#13
hl3986-wq wants to merge 4 commits intomainfrom
part3-unit-tests

Conversation

@hl3986-wq
Copy link
Collaborator

What I changed

  • Added clean_mta_df() in utils.py to convert the 'date' column to datetime and sort by date.
  • Added pytest unit tests in tests/test_utils.py (2 tests).
  • Refactored the notebook to use clean_mta_df().

How to run tests

  • python -m pytest -q

@hl3968-hue hl3968-hue enabled auto-merge February 25, 2026 17:21
@hl3968-hue hl3968-hue disabled auto-merge February 25, 2026 17:22
Copy link
Collaborator

@hl3968-hue hl3968-hue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! A few improvements in the latest commit:

  1. Extracted the plotting logic into a plot_ridership_recovery() function in utils.py so the 2 notebook stays clean and the function is reusable
  2. Added more tests — went from 2 to 6, now covering: original df not being mutated, already-sorted data, plot function returning a valid figure, and missing columns raising errors
    3.Added comments in tests to clarify what each assertion is checking (e.g. the reset_index behavior)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants