-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip appliance if func_time==0 or rand_time==0 #116
Merged
Bachibouzouk
merged 6 commits into
RAMP-project:development
from
JW-Kraft:fix/func_time_zero_error
Mar 19, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
76e5342
Fix issue 114. Skip app if func_time or rand_time==0
1f87cc0
Add warning if appliance with func_time=0 is defined
d9fcb0a
Add tests and fix faulty func_time warning
8d5d504
Formatted code with black.
3d864d2
Remove comments about the issue number
Bachibouzouk 0c65148
Check for raising of warning within the test function
Bachibouzouk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import numpy as np | ||
import pytest | ||
from ramp import UseCase, User | ||
|
||
|
||
def test_skip_when_func_time_zero(): | ||
# Generate test user and appliance | ||
user = User(user_name="Test User", num_users=1) | ||
appliance = user.add_appliance( | ||
name="Test Appliance", | ||
func_time=0, # Set func_time to be 0 | ||
func_cycle=20, | ||
time_fraction_random_variability=0.1, | ||
) | ||
|
||
# Add to use_case | ||
use_case = UseCase(name="test_use_case", users=[user]) | ||
|
||
# Calculate peak time range for this use_case | ||
peak_time_range = use_case.calc_peak_time_range() | ||
|
||
# Generated one load profile of this appliance | ||
power = 1000 | ||
appliance.generate_load_profile( | ||
prof_i=0, peak_time_range=peak_time_range, day_type=0, power=power | ||
) | ||
|
||
# Check that no use of this appliance is simulated -> the appliances load profile is always smaller than it's power | ||
# (Checking for the load_profile to always be 0 might be unreliable, since the RAMP core "marks" potential usage | ||
# windows with small power values larger 0) | ||
assert np.max(appliance.daily_use) < power | ||
|
||
|
||
def test_warning_when_func_time_zero(): | ||
user = User(user_name="Test User", num_users=1) | ||
with pytest.warns(): | ||
appliance = user.add_appliance( | ||
name="Test Appliance", | ||
func_time=0, # Set func_time to be 0 | ||
func_cycle=20, | ||
time_fraction_random_variability=0.1, | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normally you could simply create an appliance without user or usecase and call
generate_load_profile