Skip to content
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 median_speed call when returning confirmed trips #843

Merged
merged 2 commits into from
Dec 11, 2021

Conversation

shankari
Copy link
Contributor

In #841
we added support for returning metrics based on confirmed trips.
This works for all the metrics that we support, except for median_speed, since
the trips don't have a list of speeds.

I first tried to fix this by adding a list of speeds to each trip, but was
worried about breaking the ground_truth comparison tests.

So for now, if we are returning confirmed_trips, and there is no speed
field, we concatenate the speeds lists from the sections to generate the speed
list for the trip.

  • additional pandas test to check the concatenation
  • additional metrics test that retrieves all kinds of metrics and ensures that
    we don't have a similar issue in the future

In e-mission#841
we added support for returning metrics based on confirmed trips.
This works for all the metrics that we support, except for median_speed, since
the trips don't have a list of speeds.

I first tried to fix this by adding a list of speeds to each trip, but was
worried about breaking the `ground_truth` comparison tests.

So for now, if we are returning `confirmed_trips`, and there is no `speed`
field, we concatenate the speeds lists from the sections to generate the speed
list for the trip.

+ additional pandas test to check the concatenation
+ additional metrics test that retrieves all kinds of metrics and ensures that
    we don't have a similar issue in the future
@shankari
Copy link
Contributor Author

We need to create a cleaned trip object and pass it in properly.
Otherwise we get the error:

```
Traceback (most recent call last):
  File "/home/runner/work/e-mission-server/e-mission-server/emission/tests/netTests/TestMetricsConfirmedTripsPandas.py", line 97, in testGetSpeedsForTrip
    speeds_list = trip_df.apply(earms._get_speeds_for_trip, axis=1)
  File "/home/runner/miniconda-4.8.3/envs/emissiontest/lib/python3.7/site-packages/pandas/core/frame.py", line 7541, in apply
    return op.get_result()
  File "/home/runner/miniconda-4.8.3/envs/emissiontest/lib/python3.7/site-packages/pandas/core/apply.py", line 180, in get_result
    return self.apply_standard()
  File "/home/runner/miniconda-4.8.3/envs/emissiontest/lib/python3.7/site-packages/pandas/core/apply.py", line 255, in apply_standard
    results, res_index = self.apply_series_generator()
  File "/home/runner/miniconda-4.8.3/envs/emissiontest/lib/python3.7/site-packages/pandas/core/apply.py", line 284, in apply_series_generator
    results[i] = self.f(v)
  File "/home/runner/work/e-mission-server/e-mission-server/emission/analysis/result/metrics/simple_metrics.py", line 65, in _get_speeds_for_trip
    section_list = esdt.get_cleaned_sections_for_trip(trip_df_row.user_id, trip_df_row.cleaned_trip)
  File "/home/runner/miniconda-4.8.3/envs/emissiontest/lib/python3.7/site-packages/pandas/core/generic.py", line 5130, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'cleaned_trip'
```

+ comment out extraneous logging statements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant