Skip to content

Adding by_charge_key argument to calculate_itemized_cost, and some bug fixes#51

Open
dalyw wants to merge 4 commits intomainfrom
itemize-charge-key
Open

Adding by_charge_key argument to calculate_itemized_cost, and some bug fixes#51
dalyw wants to merge 4 commits intomainfrom
itemize-charge-key

Conversation

@dalyw
Copy link
Contributor

@dalyw dalyw commented Feb 5, 2026

Main update: adding by_charge_key argument to calculate_itemized_cost in costs.py, to also return itemized costs by charge key if requested. (for use with flows-mpc)

Adding test for by_charge_key = True

Other bug fixes:n

  • Adding missing pytz requirement for tests
  • adding copy of charge in costs.py during unit conversion to avoid pandas warning
  • Fixing read-only issue in hours definition in get_charge_dict and create_charge_array. Also in test_create_charge_array. Issue is that with pandas 3.0.0, datetime.dt.hours.values is read-only and can't have minutes added

Reformatted with black

Tests passing with python 3.11 and pandas 3.0

Pull request recommendations:

  • Name your pull request your-development-type/short-description. Ex: feature/gui
  • Link to any relevant issue in the PR description. Ex: Resolves [ENH: Support optimization of flexibility metrics #12]
  • Provide context of changes.
  • Provide relevant tests for your feature or bug fix.
  • Provide or update documentation for any feature added by your pull request.

Thanks for contributing!

dalyw added 2 commits February 5, 2026 13:40
…to also return itemized costs by charge key if requested. (for use with flows-mpc)

Adding missing pytz requirement for tests

adding copy of charge in costs.py during unit conversion to avoid pandas issue

Fixing read-only issue in hours definition in get_charge_dict and create_charge_array. Also in test_create_charge_array. Issue is that with pandas 3.0.0,   datetime.dt.hours.values is read-only and can't have minutes added

Reformatted with black

Tests passing with python 3.11 and pandas 3.0
Integrating total_cost into calculate_itemized_cost loop since dict has a different structure with by_charge_key True
@codecov-commenter
Copy link

codecov-commenter commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.38%. Comparing base (63ef646) to head (c2c2244).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
+ Coverage   93.40%   94.38%   +0.97%     
==========================================
  Files          10       10              
  Lines        1593     1603      +10     
==========================================
+ Hits         1488     1513      +25     
+ Misses        105       90      -15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

dalyw added 2 commits February 5, 2026 14:34
…s data has no_day_var=False and rollover=True across months

Adding more specific charge key checks in test_costs updates for by_charge_key
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

Comments