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
406 stars 134 forks source link

Type checking for `model_list` in CombinedGaussianTransitionModel #1013

Closed narykov closed 4 months ago

narykov commented 4 months ago

I've just spent an hour debugging a piece of code that uses CombinedGaussianTransitionModel. The issue was in how I passed the models in:

transition_model = CombinedGaussianTransitionModel(ModelA(), ModelB())

I forgot to organise them as a Sequence of some kind, while the correct way is to use a tuple or a list, e.g.,

transition_model = CombinedGaussianTransitionModel([ModelA(), ModelB()])

I am surprised this has not been caught by the internal check, and instead I've been receiving this rather unhelpful message:

Traceback (most recent call last): File "_mt19937.pyx", line 178, in numpy.random._mt19937.MT19937._legacy_seeding TypeError: 'ModelB' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "_mt19937.pyx", line 186, in numpy.random._mt19937.MT19937._legacy_seeding TypeError: Cannot cast scalar from dtype('O') to dtype('int64') according to the rule 'safe' Exception ignored in: <module 'threading' from '/Users/alexeynarykov/miniconda3/envs/godot_devel/lib/python3.10/threading.py'> Traceback (most recent call last): File "/Users/alexeynarykov/miniconda3/envs/godot_devel/lib/python3.10/threading.py", line 1567, in _shutdown lock.acquire() KeyboardInterrupt: Process finished with exit code 1

Perhaps, this could be accounted for? Talking to @A-acuto revealed that he, too, stepped on the same rake.