-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix preprocessing API initialization #44
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,6 @@ def __init__( | |
data_source (str): Data source name. Use `EnergyPlus` or `Other`. | ||
timestamp_column_name (str): Name of the column header that contains the time series timestamps. | ||
""" | ||
|
||
self.data = None | ||
|
||
if data_path is None: | ||
|
@@ -44,13 +43,13 @@ def __init__( | |
# check if data file exists | ||
if os.path.isfile(data_path): | ||
try: | ||
if data_source == "EnergyPlus": | ||
if data_source.lower() == "energyplus": | ||
# Use CSVReader to parse EnergyPlus timestamps | ||
data = CSVReader(csv_file=data_path).getseries() | ||
data = DateTimeEP(data, 2000).transform() | ||
data.drop("Date/Time", inplace=True, axis=1) | ||
|
||
elif data_source == "Other": | ||
elif data_source.lower() == "bms": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Other" seemed to synonymous with an "else" statement, the intent here is to deal with data from BMS. |
||
if timestamp_column_name is None: | ||
logging.error( | ||
"timestamp_column_name is required when data_source = 'Other'" | ||
|
@@ -65,7 +64,7 @@ def __init__( | |
return None | ||
data.set_index(timestamp_column_name, inplace=True) | ||
try: | ||
data = pd.to_datetime(data.index) | ||
data.index = pd.to_datetime(data.index) | ||
except: | ||
logging.error( | ||
f"The data in {timestamp_column_name} could not be converted to Python datetime object. Make sure that the data is consistent defined as a set of date strings." | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import unittest, sys, datetime, copy | ||
import unittest, sys, datetime, copy, pandas | ||
|
||
import matplotlib | ||
|
||
|
@@ -76,18 +76,20 @@ def test_ep_data_file(self): | |
t = DataProcessing(data_path=filep, data_source="EnergyPlus") | ||
assert len(t.data) == 2 | ||
|
||
def test_other_data_file(self): | ||
def test_BMS_data_file(self): | ||
filep = "./tests/api/data/data_non_ep_head.csv" | ||
dp = DataProcessing( | ||
data_path=filep, data_source="Other", timestamp_column_name="Date Time" | ||
data_path=filep, data_source="BMS", timestamp_column_name="Date Time" | ||
) | ||
assert len(dp.data) == 2 | ||
assert len(dp.data.columns) == 106 | ||
assert isinstance(dp.data.index, pandas.DatetimeIndex) | ||
|
||
Comment on lines
+85
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure that we're getting the expected full dataset. |
||
def test_datafile_error_parsing(self): | ||
with self.assertLogs() as logobs: | ||
filep = "./tests/api/data/data_err_parse.csv" | ||
dp = DataProcessing( | ||
data_path=filep, data_source="Other", timestamp_column_name="Date/Time" | ||
data_path=filep, data_source="BMS", timestamp_column_name="Date/Time" | ||
) | ||
self.assertEqual( | ||
f"ERROR:root:The data in Date/Time could not be converted to Python datetime object. Make sure that the data is consistent defined as a set of date strings.", | ||
|
@@ -97,9 +99,9 @@ def test_datafile_error_parsing(self): | |
def test_datafile_missing_datetimecol(self): | ||
with self.assertLogs() as logobs: | ||
filep = "./tests/api/data/data_non_ep_head.csv" | ||
dp = DataProcessing(data_path=filep, data_source="Other") | ||
dp = DataProcessing(data_path=filep, data_source="BMS") | ||
self.assertEqual( | ||
"ERROR:root:timestamp_column_name is required when data_source = 'Other'", | ||
"ERROR:root:timestamp_column_name is required when data_source = 'BMS'", | ||
logobs.output[0], | ||
) | ||
|
||
|
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.
No point in doing a case sensitive check.