Skip to content

Improve input to classification functions #112

@jatkinson1000

Description

@jatkinson1000

At present inputs to the classification functions are clunky and fickle, as per a couple of points raised by @TomHall2020 in #103

  • Lots of string inputs
  • Unclear what is expected 'ladies', 'female', 'women' etc.
  • Hard to get information on what is expected - not in docs, no useful feedback when wrong, have to examine source.

It would be nice to resolve some of these.
I have been pondering this for a while and will consolidate thoughts here before deciding and tackling the issue.

  • Have a 'category' class
    • input are strings, but returns a definitive format that is then used as single input to classification functions
    • variation in inputs (upper/lower cases etc.) handled here in one definitive piece of code
    • But how to handle different systems - e.g. old and new age groups?
    • Will break the current API
    • Feels clunky - need to construct this class before calling a classification function, and checks still need to be done
  • Use a python Enum
    • Provide an enum of form AGB_outdoor_ages.U18
    • Perhaps using a Flag class of enum we could have all categories listed, but then create subsets as relevant to the different schemes
    • Use class methods from the enum flag to check things
    • Make enum flag available at classification import level - this would provide users with feedback about acceptable inputs at runtime.
    • Could access the string and number part from my_age = AGB_outdoor_ages.U18 using my_age.name and my_age.value for purposes of looking up in classification dicts
    • Will break API
    • Number of inputs to the classification functions stay the same, but now rigorously restricted and options can be documented/queried.

Other thoughts:

  • This will likely be API breaking, which means we'd need to move to version 2.0
    • Irritating, as prefer to avoid this, but userbase is probably still localised enough (I think...) and this issue serves as first advance warning.
  • Moving to U18, U16 would be nicer than Under 18
    • But what to do for "Adult"? SNR? - could be confused with 50+. A? - bit short.
  • could the above suggestions somehow be combined?
    • E.g. option of specifiying age, bowstyle, gender separately to function, or as one "class" item?
      • Probably not worth it, and creates overly verbose code.
  • Similarly, is there a way to make this backwards compatible
    • Not fully I think, and again, probably not worth it creating overly verbose spaghetti code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions