On forager object creation through the call to dataObject.__init__(), the foragersDF.forager.unique() array is implicitly assumed to be equal to range(len(foragersDF.forager.unique()). This behaviour is
- not documented
- undesirable in many practical situations when
foragersDF is by itself a slice of a larger dataframe, in which case only a handful of foragers are present.
- Is not explicitly checked at object creation, which causes great many issues afterwards.
The ideal solution should be to allow arbitrary non-consecutive indices at object creation and either reindex them right away, or keep track of internal indices vs. actual labels. In any case, any such assumption should be documented and asserted in code, together with a test case.
On forager object creation through the call to
dataObject.__init__(), theforagersDF.forager.unique()array is implicitly assumed to be equal torange(len(foragersDF.forager.unique()). This behaviour isforagersDFis by itself a slice of a larger dataframe, in which case only a handful of foragers are present.The ideal solution should be to allow arbitrary non-consecutive indices at object creation and either reindex them right away, or keep track of internal indices vs. actual labels. In any case, any such assumption should be documented and asserted in code, together with a test case.