From 1a53534c02f4c526c3ea1aec38f6bffafc3fe316 Mon Sep 17 00:00:00 2001 From: eli knaap Date: Tue, 29 Dec 2020 11:53:10 -0800 Subject: [PATCH] update docs --- docs/api.rst | 46 +++++++++++++++++- docs/conf.py | 21 +++++++-- .../decomposition/decompose_segregation.py | 47 +++++++++---------- 3 files changed, 82 insertions(+), 32 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 6ef466bf..cddc52ae 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -7,6 +7,9 @@ API reference Aspatial Indices --------------------- + +.. currentmodule:: segregation + .. autosummary:: :toctree: generated/ @@ -26,6 +29,9 @@ Aspatial Indices Spatial Indices --------------------- + +.. currentmodule:: segregation + .. autosummary:: :toctree: generated/ @@ -44,9 +50,22 @@ Spatial Indices spatial.AbsoluteCentralization spatial.RelativeCentralization spatial.SpatialMinMax - + +Multi-Scalar Spatial Measures +---------------------------------- + +.. currentmodule:: segregation + +.. autosummary:: + :toctree: generated/ + + spatial.compute_segregation_profile + Multigroup Indices --------------------- + +.. currentmodule:: segregation + .. autosummary:: :toctree: generated/ @@ -63,6 +82,9 @@ Multigroup Indices Local Indices --------------------- + +.. currentmodule:: segregation + .. autosummary:: :toctree: generated/ @@ -75,6 +97,9 @@ Local Indices Batch Compute Wrappers --------------------- + +.. currentmodule:: segregation + .. autosummary:: :toctree: generated/ @@ -84,6 +109,9 @@ Batch Compute Wrappers Inference Wrappers --------------------- + +.. currentmodule:: segregation + .. autosummary:: :toctree: generated/ @@ -92,6 +120,9 @@ Inference Wrappers Decomposition --------------------- + +.. currentmodule:: segregation + .. autosummary:: :toctree: generated/ @@ -99,8 +130,21 @@ Decomposition Network --------------------- + +.. currentmodule:: segregation + .. autosummary:: :toctree: generated/ network.get_osm_network network.calc_access + +Util +---------------- + +.. currentmodule:: segregation + +.. autosummary:: + :toctree: generated/ + + util.project_gdf \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 145e4b2e..96dab20c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -53,7 +53,6 @@ 'matplotlib.sphinxext.plot_directive'] - # sphinx_gallery_conf = { # # path to your examples scripts # 'examples_dirs': '../examples', @@ -146,7 +145,7 @@ # Global TOC depth for "site" navbar tab. (Default: 1) # Switching to -1 shows all levels. - 'globaltoc_depth': 2, + 'globaltoc_depth': 1, # Include hidden TOCs in Site navbar? # @@ -268,10 +267,11 @@ # Generate the API documentation when building autosummary_generate = True -numpydoc_show_class_members = True +numpydoc_show_class_members = False class_members_toctree = True -numpydoc_show_inherited_class_members = True +numpydoc_show_inherited_class_members = False numpydoc_use_plots = True +numpydoc_xref_param_type = True # display the source code for Plot directive plot_include_source = True @@ -280,4 +280,15 @@ def setup(app): app.add_stylesheet("pysal-styles.css") # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/3.6/': None} +intersphinx_mapping = { + "esda": ("https://pysal.org/esda/", None), + "geopandas": ("https://geopandas.readthedocs.io/en/latest/", None), + "libpysal": ("https://pysal.org/libpysal/", None), + "matplotlib": ("https://matplotlib.org/", None), + "numpy": ("https://numpy.org/doc/stable/", None), + "pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None), + "python": ("https://docs.python.org/3.9/", None), + "scipy": ("https://docs.scipy.org/doc/scipy/reference/", None), +} + +autodoc_default_options = {"members": True, "undoc-members": True} diff --git a/segregation/decomposition/decompose_segregation.py b/segregation/decomposition/decompose_segregation.py index 122885fc..2b5ae22e 100644 --- a/segregation/decomposition/decompose_segregation.py +++ b/segregation/decomposition/decompose_segregation.py @@ -107,35 +107,30 @@ class DecomposeSegregation: to measure whether the differences between index measures arise from differences in spatial structure or population structure - Examples - -------- - Several examples can be found at https://github.com/pysal/segregation/blob/master/notebooks/decomposition_wrapper_example.ipynb. - """ + Parameters + ---------- + index1 : segregation.SegIndex class + First SegIndex class to compare. + index2 : segregation.SegIndex class + Second SegIndex class to compare. + counterfactual_approach : str, one of {"composition", "share", "dual_composition"} + The technique used to generate the counterfactual population + distributions. - def __init__(self, index1, index2, counterfactual_approach="composition"): - """Decompose segregation differences into spatial and attribute components. + Attributes + ---------- + c_s : float + Shapley's Spatial Component of the decomposition + c_a : float + Shapley's Attribute Component of the decomposition + indices : dict + Dictionary of index values for all four combinations of spatial/attribute data - Given two segregation indices of the same type, use Shapley decomposition - to measure whether the differences between index measures arise from - differences in spatial structure or population structure - Parameters - ---------- - index1 : segregation.SegIndex class - First SegIndex class to compare. - index2 : segregation.SegIndex class - Second SegIndex class to compare. - counterfactual_approach : str, one of {"composition", "share", "dual_composition"} - The technique used to generate the counterfactual population - distributions. - - Attributes - ---------- - c_s : float - Shapley's Spatial Component of the decomposition - c_a : float - Shapley's Attribute Component of the decomposition - """ + """ + + def __init__(self, index1, index2, counterfactual_approach="composition"): + """Initialize class.""" aux = _decompose_segregation(index1, index2, counterfactual_approach) self.c_s = aux[0]