UDST / spandex

Spatial Analysis and Data Extraction
http://nbviewer.ipython.org/github/synthicity/user_meeting_2014/blob/gh-pages/spandex/spandex_demo.ipynb
BSD 3-Clause "New" or "Revised" License
22 stars 7 forks source link

targets/synthesis .pop() error #59

Open cvanoli opened 6 years ago

cvanoli commented 6 years ago

In targets/synthesis, when a count column is passed, the adding or removing rows is done in two functions: _add_rows_by_count or _remove_rows_by_count.

Inside these functions, there is a case that is not contemplated. From the df, after applying the corresponding filters, only the rows that have a value in the count column less or equal than the amount (to add or remove) are saved into the sort_count array which is then used to pick to_add or to_remove indexes. BUT, the unforeseen case is when the sort_count array is empty, meaning that all of the available rows in the filtered df have count values bigger than the amount value. In the case of adding rows, an error is raised in line 213 https://github.com/UDST/spandex/blob/master/spandex/targets/synthesis.py#L213 when trying to pop out an index from to_add when this is empty.

In the case of removing, an error will not raise, but the process will iterate over the empty sort_count and the function will end up returning the same df.