Skip to content

Commit

Permalink
fix series
Browse files Browse the repository at this point in the history
  • Loading branch information
jackx111 committed Jan 24, 2024
1 parent 351250b commit 85e690d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
10 changes: 2 additions & 8 deletions howso/client/pandas/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,9 @@ def react_series(
"""
trainee_id = self._resolve_trainee_id(trainee_id)
feature_attributes = self.trainee_cache.get(trainee_id).features
response = super().react_series(trainee_id, *args, **kwargs)
response = super().react_series(trainee_id, series_index, *args, **kwargs)

# If series_index is not a string, the intention is likely for it to not be included
if not isinstance(series_index, str):
series_index = None

# Build response DataFrame
df = build_react_series_df(response, series_index=series_index)
response['series'] = format_dataframe(df, feature_attributes)
response['series'] = format_dataframe(response.get("series"), feature_attributes)

return response

Expand Down
11 changes: 9 additions & 2 deletions howso/direct/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
TraineeVersion
)
from howso.utilities import (
build_react_series_df,
internals,
num_list_dimensions,
ProgressTimer,
Expand Down Expand Up @@ -1917,6 +1918,7 @@ def react_series( # noqa: C901
series_context_features: Optional[Iterable[str]] = None,
series_context_values: Optional[Union[List[object], List[List[object]]]] = None,
series_id_tracking: Literal["dynamic", "fixed", "no"] = "fixed",
series_index: Optional[str] = None,
series_stop_maps: Optional[List[Dict[str, Dict]]] = None,
substitute_output: bool = True,
suppress_warning: bool = False,
Expand Down Expand Up @@ -2035,7 +2037,10 @@ def react_series( # noqa: C901
allowed to change the series ID that it tracks based on its
current context.
- If "no", does not track any particular series ID.
series_index : str, Optional
When set to a string, will include the series index as a
column in the returned DataFrame using the column name given.
If set to None, no column will be added.
progress_callback : callable, optional
A callback method that will be called before each
batched call to react series and at the end of reacting. The method
Expand Down Expand Up @@ -2359,7 +2364,9 @@ def react_series( # noqa: C901
suppress_warning=suppress_warning
)

response = CasesWithDetails(response.get('series'), response.get('explanation'))
series_df = build_react_series_df(response, series_index=series_index)

response = CasesWithDetails(series_df, response.get('explanation'))

return response

Expand Down
8 changes: 5 additions & 3 deletions howso/utilities/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ def __init__(self,
details: t.Optional[t.MutableMapping[str, t.Any]] = None
):
"""Initialize the dictionary with the allowed keys."""

self._data = {
'action': None,
'details': {}
}

if action:
self.add_reaction(action, details or {})
if details is None:
details = {}

if action is not None:
self.add_reaction(action, details)
elif details:
self._data['details'] = details

Expand Down

0 comments on commit 85e690d

Please sign in to comment.