Skip to content

Conversation

@alexdewar
Copy link
Collaborator

@alexdewar alexdewar commented Jun 5, 2024

Let's try this again. It turns out the fix for my previous mistake was really trivial (5fb3ff5). Sorry about all the noise!

Fixes #320.

@codecov
Copy link

codecov bot commented Jun 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.39%. Comparing base (d331f46) to head (b444f68).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #328      +/-   ##
===========================================
+ Coverage    71.24%   71.39%   +0.15%     
===========================================
  Files           44       44              
  Lines         5870     5887      +17     
  Branches      1158     1162       +4     
===========================================
+ Hits          4182     4203      +21     
+ Misses        1366     1364       -2     
+ Partials       322      320       -2     

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

@alexdewar alexdewar marked this pull request as ready for review June 6, 2024 09:38
@alexdewar alexdewar requested a review from dalonsoa June 6, 2024 09:38
Copy link
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

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

The changes look ok, but I've a couple of comments/concerns, and a request.


data = data.apply(lambda x: pd.to_numeric(x, errors="ignore"))
data = check_utilization_not_all_zero(data, filename)
check_utilization_not_all_zero(data, filename)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment on lines 25 to 36
"minimum_service_factors",
permutations((np.linspace(0, 1, 6), [0] * 6)),
)
def test_minimum_service_factor(tmpdir, minimum_service_factor, process_name):
def test_minimum_service_factor(tmpdir, minimum_service_factors):
import pandas as pd
from muse import examples
from muse.mca import MCA

sector = "power"
processes = ("gasCCGT", "windturbine")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Concrete values of the service factor aside, this does not check the same scenarios as before. Before there were 4 tests being launched, and now they are only 2. Not that the previous 4 cases were necessary, but just flagging this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There should still be 4... permutations() returns the inputs in 2 different orders

Copy link
Collaborator

@tsmbland tsmbland 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, although I think we also need to have a similar check for MinimumServiceFactor in the read_technodata_timeslices function. While we're at it, it would also be good to have a similar check for UtilizationFactor (i.e. it needs to be between 0 and 1). And we could also check that UtilizationFactor is always >= MinimumServiceFactor.

Also, it might be nice to have a some tests with invalid inputs to make sure these checks fail when they should.

@alexdewar
Copy link
Collaborator Author

All good points @tsmbland!

@alexdewar alexdewar mentioned this pull request Jun 18, 2024
8 tasks
@alexdewar alexdewar force-pushed the enforce_minimum_service_factor_limits branch 3 times, most recently from a760cab to 4d1558b Compare June 20, 2024 15:54
@alexdewar
Copy link
Collaborator Author

Ok, I think I've made all the changes that were suggested and I've added a bunch more tests. I'm glad I had a more thorough look at this because it turns out my original fix didn't actually work 😟

@alexdewar alexdewar requested review from dalonsoa and tsmbland June 20, 2024 16:34
Copy link
Collaborator

@dalonsoa dalonsoa 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! Way more comprehensive validation than before.

@dalonsoa
Copy link
Collaborator

But tests are failing...

@alexdewar
Copy link
Collaborator Author

Sorry 😞. I pushed this at the end of the day and figured it was all fine (the tests I was working on were passing!). I'll take another look. Hopefully it's just something trivial!

@alexdewar
Copy link
Collaborator Author

Converting to draft until I fix the test failures (see also #362)

@alexdewar alexdewar force-pushed the enforce_minimum_service_factor_limits branch from 310af65 to b444f68 Compare June 24, 2024 10:33
@alexdewar alexdewar marked this pull request as ready for review June 24, 2024 10:33
@patch("muse.readers.csv._check_utilization_not_all_zero")
@patch("muse.readers.csv._check_utilization_not_below_minimum")
@patch("muse.readers.csv._check_minimum_service_factors_in_range")
def test_check_utilization_and_minimum_service_factors_fail_missing_utilization(*mocks):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you need the mocks here. Otherwise, everything looks good!

@alexdewar alexdewar merged commit 5ab22bb into develop Jun 24, 2024
@alexdewar alexdewar deleted the enforce_minimum_service_factor_limits branch June 24, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Invalid values for minimum service factor in test_minimum_service_factor

4 participants