pysal / segregation

Segregation Measurement, Inferential Statistics, and Decomposition Analysis
https://pysal.org/segregation/
BSD 3-Clause "New" or "Revised" License
112 stars 26 forks source link

update nbsit notebook #51

Closed knaaptime closed 5 years ago

renanxcortes commented 5 years ago

Cool! This notebook is a huge improvement! I'm trying to reproduce the notebook here and am getting this from cenpy (do you know what might be happening?):

image

renanxcortes commented 5 years ago

I've seen that products is a branch of cenpy, right?

knaaptime commented 5 years ago

i added a note. you can either use the github version of cenpy and checkout the products branch, or you can test out the first alpha with pip install --pre cenpy

renanxcortes commented 5 years ago

Ok, cool, I managed to install the pre-version, but when I run the third cell I get:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-b813ef537da5> in <module>()
----> 1 atl = products.ACS(2017).from_msa(name='Atlanta, GA', variables=variables.copy(), level='tract')

~\AppData\Local\Continuum\anaconda3\lib\site-packages\cenpy\products.py in from_msa(self, name, variables, level, **kwargs)
    357     def from_msa(self, name, variables=None, level='tract', **kwargs):
    358         return self._from_name(name, variables, level,
--> 359                                'Metropolitan Statistical Area', '_msas', **kwargs)
    360     from_msa.__doc__ = _Product.from_place.__doc__.replace('place', 'MSA')
    361     def from_csa(self, name, variables=None, level='tract', **kwargs):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\cenpy\products.py in _from_name(self, place, variables, level, layername, cache_name, strict_within, return_bounds, geometry_precision)
    326                    strict_within=True,
    327                    return_bounds=False, geometry_precision=2):
--> 328         if level not in self._layer_lookup().keys():
    329             raise NotImplementedError('Only levels {} are supported. You provided {}.'
    330                                       'Try picking the state containing that level,'

TypeError: 'dict' object is not callable

image

renanxcortes commented 5 years ago

Trying to debug here.. this must have something to do with from_msa from these functions: https://github.com/ljwolf/cenpy/blob/product/cenpy/products.py

knaaptime commented 5 years ago

that's been fixed upstream if you use the github version

renanxcortes commented 5 years ago

hm... so I reinstalled cenpy running pip install --pre cenpy and then from cenpy import products worked smoothly... what would be the github version in this case?

knaaptime commented 5 years ago

the products branch has an early RC available on pip using the --pre flag, but that release has a small bug in the _from_msa method. That bug is fixed upstream in @ljwolf's repo, so to use it you

  1. uninstall any cenpy's you currently have
  2. clone https://github.com/ljwolf/cenpy.git
  3. git checkout products
  4. python setup.py develop (note that since you're using the develop command, the version you import will change depending on which branch you have checked out)
renanxcortes commented 5 years ago

the products branch has an early RC available on pip using the --pre flag, but that release has a small bug in the _from_msa method. That bug is fixed upstream in @ljwolf's repo, so to use it you

  1. uninstall any cenpy's you currently have
  2. clone https://github.com/ljwolf/cenpy.git
  3. git checkout products
  4. python setup.py develop (note that since you're using the develop command, the version you import will change depending on which branch you have checked out)

Ow, I see, thanks! I'll try here!

renanxcortes commented 5 years ago

It worked! Thank you! :) I'm gonna try to reproduce now! (I'm downloading the network...)

knaaptime commented 5 years ago

were you able to reproduce?

renanxcortes commented 5 years ago

So, I still didn't reproduce the notebook on my side (I'll keep trying), but I think this is good to be merged will some small tweaks:

# balt_network.save_hdf5('atl_network.h5')
knaaptime commented 5 years ago

excellent, thanks

renanxcortes commented 5 years ago

No sweat! Ow, also consider using the recent Multi_Information_Theory class for the last function. I wanted to check if the values were matching.

EDIT: I checked here and, indeed, the values matched:

image

renanxcortes commented 5 years ago

I think I managed to run the notebook reducing the buffer to 1000. Since this is a tutorial notebook for explaining functions, could we change this parameter?

renanxcortes commented 5 years ago

Also, shouldn't nbsit function should be run in atl_access instead of atl? I think with the latter it is building the aspatial version of the index, isn't it?

knaaptime commented 5 years ago

lol yeah, oops. I had both in there for comparison (the stats are quite different) but apparently deleted the wrong cell when I tried to simplify. Good catch

renanxcortes commented 5 years ago

Also, geopandas is being imported two times. I think you can drop one.

renanxcortes commented 5 years ago

Awesome, thanks for adding these new functionalities, @knaaptime !