Skip to content

Commit

Permalink
formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
misi9170 committed Oct 16, 2024
1 parent 5636071 commit 4101f8f
Show file tree
Hide file tree
Showing 6 changed files with 1,096 additions and 1,090 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,368 changes: 684 additions & 684 deletions examples_smarteole/02_download_and_format_dataset.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@
" f = root_path / \"postprocessed\" / \"df_scada_data_60s_filtered_and_northing_calibrated.pkl\"\n",
" df_scada = pd.read_pickle(f)\n",
"\n",
"\n",
" if timebase_s != 60:\n",
" import flasc.data_processing.time_operations as fto\n",
"\n",
Expand Down
15 changes: 8 additions & 7 deletions flasc/flasc_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, *args, channel_name_map=None, long_data_columns=None, **kwarg
super().__init__(*args, **kwargs)

# Check that the time column is present
#if "time" not in self.columns:
# if "time" not in self.columns:
# raise ValueError("Column 'time' must be present in the DataFrame")

# check that name_map dictionary is valid
Expand Down Expand Up @@ -83,19 +83,21 @@ def in_flasc_format(self):
return True
else:
return False

@property
def channel_name_map(self):
"""Return the channel_name_map attribute."""
return self._channel_name_map

@channel_name_map.setter
def channel_name_map(self, value):
"""Set the channel_name_map attribute."""
self._channel_name_map = value
# Save the reversed name_map (to go to user_format)
self._channel_name_map_to_user = (
{v: k for k, v in self._channel_name_map.items()} if self._channel_name_map is not None else None
{v: k for k, v in self._channel_name_map.items()}
if self._channel_name_map is not None
else None
)

@property
Expand Down Expand Up @@ -133,7 +135,7 @@ def check_flasc_format(self):

def copy_metadata(self, other):
"""Copy metadata from another FlascDataFrame to self.
Args:
other (FlascDataFrame): DataFrame to copy metadata from.
"""
Expand Down Expand Up @@ -190,10 +192,9 @@ def convert_time_to_datetime(self, inplace=False):
FlascDataFrame: FlascDataFrame with time column as datetime object if inplace is False,
None otherwise
"""

if "time" not in self.columns:
raise KeyError("Column 'time' must be present in the DataFrame")

if inplace:
self["time"] = pd.to_datetime(self["time"])
else:
Expand Down
13 changes: 7 additions & 6 deletions tests/flasc_dataframe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ def test_printout():
# print("\n")


def test_time_required():
# Check that the time column is present
with pytest.raises(ValueError):
FlascDataFrame(
{"pow_000": [0, 100, 200], "ws_000": [8, 8, 8]}, channel_name_map=test_channel_name_map
)
# def test_time_required():
# # Check that the time column is present
# with pytest.raises(ValueError):
# FlascDataFrame(
# {"pow_000": [0, 100, 200], "ws_000": [8, 8, 8]},
# channel_name_map=test_channel_name_map
# )


def test_check_flasc_format():
Expand Down

0 comments on commit 4101f8f

Please sign in to comment.