GeoDaCenter / spatial_access

https://spatial.uchicago.edu
37 stars 11 forks source link

AccessTime / AccessCount / AccessSum models don't work with calculate() #89

Open angela-li opened 4 years ago

angela-li commented 4 years ago

When running accessT.calculate() in the demo notebook I get the following IndexError and cannot continue further:

IndexError                                Traceback (most recent call last)
<ipython-input-18-d35958627452> in <module>()
----> 1 accessT.calculate()

~/Desktop/spatial_access/spatial_access/Models.py in calculate(self)
    314             results[source_id] = []
    315             for category in focus_categories_list:
--> 316                 time_to_nearest_neighbor = self.time_to_nearest_dest(source_id, category)
    317                 results[source_id].append(time_to_nearest_neighbor)
    318 

~/Desktop/spatial_access/spatial_access/BaseModel.py in time_to_nearest_dest(self, source_id, category)
    503             return self.transit_matrix.matrix_interface.time_to_nearest_dest(source_id, None)
    504         else:
--> 505             return self.transit_matrix.matrix_interface.time_to_nearest_dest(source_id, category)
    506 
    507     def count_dests_in_range_by_categories(self, source_id, category, upper_threshold):

~/Desktop/spatial_access/spatial_access/MatrixInterface.py in time_to_nearest_dest(self, source_id, category)
    425         else:
    426             return self.transit_matrix.timeToNearestDestPerCategory(self._parser.encode_source_id(source_id),
--> 427                                                                     self._parser.encode_category(category))
    428 
    429     def count_dests_in_range(self, source_id, threshold, category=None):

~/Desktop/spatial_access/spatial_access/src/_p2pExtension.pyx in _p2pExtension.pyTransitMatrixIxSxUS.timeToNearestDestPerCategory()
    379 
    380     def timeToNearestDestPerCategory(self, source_id, category):
--> 381         return self.thisptr.timeToNearestDestPerCategory(source_id, category)
    382 
    383     def countDestsInRangePerCategory(self, source_id, category, range):

**IndexError: unordered_map::at: key not found**
angela-li commented 4 years ago

I think this is due to a change made by @lixun910 in commit https://github.com/GeoDaCenter/spatial_access/commit/a726b41e2304455dfd0efe2b7101f8da71efb056 on Models.py that prevents the AccessTime/AccessCount function and others from returning model output, which means that there is nothing to "calculate()" on.

lixun910 commented 4 years ago

@angela-li Just forward the emails (between me and Irene) to you.

lixun910 commented 4 years ago

@angela-li The two files committed in a726b41 were changed by @ifarah , and I just helped to push the changes into GeoDaCenter/spatial_access repo. I'd suggest you can just go and change the code to make it work:)

angela-li commented 4 years ago

Thanks! While we should probably make sure the unit tests work (#90), I'm not sure this has to do with the a726b41 change, because the version on PyPI should be version 1.0.0 (released in June 2019) and shouldn't take into account any of these commits.

So now I'm rethinking that it has something to do with my _p2pExtension again that affects this line in the Models.py code: https://github.com/GeoDaCenter/spatial_access/blob/a726b41e2304455dfd0efe2b7101f8da71efb056/spatial_access/Models.py#L316

lixun910 commented 4 years ago

@angela-li I think spatial_access PyPi verion 1.0.0 does NOT contain the change of a726b41.

angela-li commented 4 years ago

Yes, that's what I meant :) so I think it's something else internally that's not causing this to work.

angela-li commented 4 years ago

@vidal-anguiano is this the same problem that you're running into? I can't get AccessTime or AccessCount to work either; would love if you wanted to take a look into the internals and figure out what's up!

vidal-anguiano commented 4 years ago

@angela-li , yep, this is the exact problem I am running into as well! I'm looking into it right now, will let you know if I can figure it out.