cheind / py-motmetrics

:bar_chart: Benchmark multiple object trackers (MOT) in Python
MIT License
1.37k stars 258 forks source link

Run pylint #76

Closed jvlmdr closed 4 years ago

jvlmdr commented 4 years ago

Hey, any objections to doing this?

jvlmdr commented 4 years ago

Yeah, I totally agree that duplicating the code in __init__() and reset() is not as nice as before. I did this to fix the following lint warnings (attribute-defined-outside-init):

motmetrics/mot.py:163:8: W0201: Attribute 'dirty_events' defined outside __init__ (attribute-defined-outside-init)
motmetrics/mot.py:304:12: W0201: Attribute 'dirty_events' defined outside __init__ (attribute-defined-outside-init)
motmetrics/mot.py:303:12: W0201: Attribute 'cached_events_df' defined outside __init__ (attribute-defined-outside-init)

These warnings occur at the sites where those member variables are accessed. (The linter isn't smart enough to realise that reset() is called within __init__().)

I didn't want to disable this warning globally because I think it is good to define the member variables in __init__() where possible.

I propose two options:

  1. Disable the warning within MOTAccumulator.
  2. Instead of duplicating the code from reset(), simply set all those variable to None and then call reset().

What do you think?

cheind commented 4 years ago

looking good. did you disable the warning? haven't found a reference.

jvlmdr commented 4 years ago

I did option 2 (initialize all state variables to None in the constructor) rather than option 1 (disable the warning). See the diff here

cheind commented 4 years ago

Ah ok, didn't spot that. Then lets merge! Thanks Jack 😀

Jack Valmadre notifications@github.com schrieb am Sa., 1. Feb. 2020, 15:44:

I did option 2 (initialize all state variables to None in the constructor) rather than option 1 (disable the warning). jvlmdr/py-motmetrics@jvlmdr:613e1e7...jvlmdr:c1a7228 diff-8a7fa6c9ecbaabedee2e2dadd0e08b01R109 https://github.com/jvlmdr/py-motmetrics/compare/jvlmdr:613e1e7...jvlmdr:c1a7228diff-8a7fa6c9ecbaabedee2e2dadd0e08b01R109

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cheind/py-motmetrics/pull/76?email_source=notifications&email_token=AAAJNJO7ZILGJVPMA47TBUTRAWDGTA5CNFSM4KN546R2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKQ6WZQ#issuecomment-581036902, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAJNJMAKJIPVCNA62KNMH3RAWDGTANCNFSM4KN546RQ .

jvlmdr commented 4 years ago

Excellent! Thanks for taking a look!