Skip to content

Commit

Permalink
Fix handling of dataframe input, issue #300 (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
toni-neurosc authored Apr 15, 2024
1 parent c1f91a1 commit a09aa6d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions py_neuromodulation/nm_stream_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def _handle_data(self, data: np.ndarray | pd.DataFrame) -> np.ndarray:
if not len(names_expected) == data.shape[0]:
raise ValueError(
"If data is passed as an array, the first dimension must"
" match the number of channel names in `nm_channels`. Got:"
f" Data columns: {data.shape[0]}, nm_channels.name:"
f" {len(names_expected)}."
" match the number of channel names in `nm_channels`.\n"
f" Number of data channels (data.shape[0]): {data.shape[0]}\n"
f" Length of nm_channels[\"name\"]: {len(names_expected)}."
)
return data
names_data = data.columns.to_list()
Expand All @@ -100,10 +100,11 @@ def _handle_data(self, data: np.ndarray | pd.DataFrame) -> np.ndarray:
):
raise ValueError(
"If data is passed as a DataFrame, the"
"columns must match the channel names in `nm_channels`. Got:"
f"Data columns: {names_data}, nm_channels.name: {names_data}."
"column names must match the channel names in `nm_channels`.\n"
f"Input dataframe column names: {names_data}\n"
f"Expected (from nm_channels[\"name\"]): : {names_expected}."
)
return data.to_numpy()
return data.to_numpy().transpose()

def _check_settings_for_parallel(self):
"""Check specified settings and raise error if parallel processing is not possible.
Expand Down

0 comments on commit a09aa6d

Please sign in to comment.