dstl / Stone-Soup

A software project to provide the target tracking community with a framework for the development and testing of tracking algorithms.
https://stonesoup.rtfd.io
MIT License
400 stars 131 forks source link

Fix bug with pre-fetching noise in cases of only a single target #724

Closed sdhiscocks closed 1 year ago

codecov[bot] commented 1 year ago

Codecov Report

Base: 94.79% // Head: 94.75% // Decreases project coverage by -0.04% :warning:

Coverage data is based on head (aceea70) compared to base (e5955f6). Patch coverage: 86.66% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #724 +/- ## ========================================== - Coverage 94.79% 94.75% -0.05% ========================================== Files 168 168 Lines 8190 8196 +6 Branches 1560 1563 +3 ========================================== + Hits 7764 7766 +2 - Misses 317 319 +2 - Partials 109 111 +2 ``` | Flag | Coverage Δ | | |---|---|---| | integration | `69.26% <33.33%> (-0.12%)` | :arrow_down: | | unittests | `92.55% <73.33%> (-0.02%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://codecov.io/gh/dstl/Stone-Soup/pull/724?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl) | Coverage Δ | | |---|---|---| | [stonesoup/sensor/passive.py](https://codecov.io/gh/dstl/Stone-Soup/pull/724/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl#diff-c3RvbmVzb3VwL3NlbnNvci9wYXNzaXZlLnB5) | `85.71% <0.00%> (-14.29%)` | :arrow_down: | | [stonesoup/sensor/radar/radar.py](https://codecov.io/gh/dstl/Stone-Soup/pull/724/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl#diff-c3RvbmVzb3VwL3NlbnNvci9yYWRhci9yYWRhci5weQ==) | `96.10% <100.00%> (+0.09%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

sdhiscocks commented 1 year ago

In the scenario len(ground_truths) == 1 and noise == True (which happens in the Disjoint_Tracking_Classification.py example) Then measurement_noise = True Which doesn't cause an error on the line measurement_vector += measurement_noise It just adds 1 to the measurement_vector

Would this be a suitable solution:

if noise is True:
    # Pre-fetch noise values when more than one target
    if len(ground_truths) > 1:
        noise_vectors_iter = iter(measurement_model.rvs(len(ground_truths), **kwargs))
    else:
        noise_vectors_iter = iter([measurement_model.rvs(**kwargs)])

Thanks @gawebb-dstl, I hadn't spotted that. I've updated it for sensors where this is an issue.

gawebb-dstl commented 1 year ago

@sdhiscocks I noticed you were having to rewrite the same code in many different places, so I tried to abstract that code to one class see #732