Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gini polarization #87

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4c231f6
Wolfson bipolarization index and tests
sjsrey Aug 13, 2024
507fd0c
Merge branch 'main' of github.com:pysal/inequality into wolfson
sjsrey Aug 22, 2024
aaa63ab
ENH: Wolfson bipolarization index
sjsrey Aug 22, 2024
8e307c1
ENH: Wolfson bipolarization index
sjsrey Aug 23, 2024
9ada1c4
add pen and pengram to tutorials
sjsrey Sep 1, 2024
ace0e1a
DOCS: change theme
sjsrey Sep 1, 2024
c3ef50f
doc refactor
sjsrey Sep 4, 2024
0cd0d8f
DEV: add seaborn for dev
sjsrey Sep 4, 2024
88e7751
Wolfson documentation
sjsrey Sep 4, 2024
a643205
Merge branch 'tutorial' into wolfson
sjsrey Sep 4, 2024
0df9cfc
links for user guide
sjsrey Sep 4, 2024
94d614f
pyproject.toml update
sjsrey Oct 3, 2024
bd33f33
reorg docs
sjsrey Oct 3, 2024
a597534
Contributing docs
sjsrey Oct 3, 2024
a4e7f9c
DOC: Mac OSX and proj instructions
sjsrey Oct 4, 2024
3354455
DOC: update test dependencies and instructions
sjsrey Oct 4, 2024
aba6ff8
New interface for Wolfson
sjsrey Oct 16, 2024
ff62ba4
Support dataframes or sequence args in Theil
sjsrey Oct 16, 2024
b07a734
Trimmed wolfson nb
sjsrey Nov 7, 2024
bf197c6
prune docs
sjsrey Nov 7, 2024
63bc6f4
prunning
sjsrey Nov 7, 2024
56056c1
prunning
sjsrey Dec 6, 2024
f594da9
Merge branch 'main' of github.com:sjsrey/inequality into wolfson
sjsrey Dec 6, 2024
317769d
Refactoring atkinson
sjsrey Dec 6, 2024
58f2d97
REF: add default title for schutz plot
Dec 28, 2024
4fee375
ENH: add Gini polarization index
Dec 28, 2024
524a8fc
DOC: new gini documentation/nb
sjsrey Dec 29, 2024
b26b37f
ENH: Gini spatial polarization index
sjsrey Dec 29, 2024
9a8ac09
REF: provide meaningful default title in schutz
sjsrey Dec 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Contribute

PySAL-inequality is under active development and contributors are welcome.

Please see the [Contributing](contributing.md) instructions.

If you have any suggestion, feature request, or bug report, please open a new [issue](https://github.com/pysal/inequality/issues) on GitHub. To submit patches, please follow the PySAL development [guidelines](http://pysal.org/docs/devs/) and open a [pull request](https://github.com/pysal/inequality). Once your changes get merged, you’ll automatically be added to the [Contributors List](https://github.com/pysal/inequality/graphs/contributors).

Support
Expand Down
84 changes: 84 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Contributing to inequality

Contributions to inequality are much appreciated.

## Steps to Contribute

1. Fork the inequality git repository
2. Create a development environment
3. Activate the new environment
4. Install project dependencies
5. Verify installation and run tests
6. Build documentation
7. Submitting a Pull Request

## 1. Fork the inequality git repository

- On github, fork the repository at: <https://github.com/pysal/inequality>
- From your new fork, grab the clone url:
```
git clone [email protected]:your-user-name/inequality.git inequality-yourname
cd inequality-yourname
git remote add upstream git://github.com/pysal/inequality.git
```

## 2. Create a development environment

- Install either [Anaconda](http://docs.continuum.io/anaconda/) or [miniconda](http://conda.pydata.org/miniconda.html)
- `cd` into the `inequality-yourname` source directory that you cloned in step 1

```
conda create --name inequality python=3.10
```

## 3. Activate the new environment
```
conda activate inequality
```
## 4. Install project dependencies
```
pip install .[dev,docs,tests]
```

Note, if you are on zsh use:

```
pip install '.[dev,docs,tests]'
```
If this fails on MacOS you have to have `proj` installed:
```
brew install proj
```

Set this variable in your shell configuration (e.g., ~/.zshrc or ~/.bashrc):
```
export PROJ_DIR="/opt/homebrew/opt/proj"
```
Then, reload your shell configuration:
```
source ~/.zshrc
```
and check that `proj` is correctly installed:
```
proj
```

## 5. Verify installation and run tests
```
python -c "import libpysal; print('libpysal version:', libpysal.__version__)"
pytest inequality
```


## 6. Build documentation
```
cd docs
make html
```

## 7. Submitting a Pull Request

If you have made changes that you have pushed to your forked repository, you can
submit a pull request to have them integrated into the `inequality` code base.

See the [GitHUB tutorial](https://help.github.com/articles/using-pull-requests/).
15 changes: 13 additions & 2 deletions docs/_static/auto/references.el
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
;; -*- lexical-binding: t; -*-

(TeX-add-style-hook
"references"
(lambda ()
(LaTeX-add-bibitems
"hoffmann2024MeasuringMismeasuring"
"wolfson1994WhenInequalities"
"schutz1951MeasurementIncome"
"Atkinson_1970_Measurement"
"care_2012"
"ellison_1997"
"maurel_1999"
"nijkamp2015cultural"
"rey_interregional_2010"
"rey_comparative_2015"
"Rey_2013_sea"))
:bibtex)
"Rey_2013_sea"
"van_Mourik_1989"))
'(or :bibtex :latex))

30 changes: 30 additions & 0 deletions docs/_static/references.bib
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@

@misc{hoffmann2024MeasuringMismeasuring,
title = {Measuring and {{Mismeasuring Income Polarization}}},
author = {Hoffmann, Rodolfo and Kassouf, Ana Lucia},
year = {2024},
month = mar,
doi = {10.21203/rs.3.rs-4139220/v1},
urldate = {2024-08-12},
abstract = {The main contribution of this paper is to clarify some of the misconceptions about income polarization indices observed in the existing literature. Our analysis explores the domain of measures of polarization of the income distribution, with a specific emphasis on elucidating the importance of distinguishing between bipolarization and multipolarization measures. Additionally, we assert that a valid polarization metric must adhere to the principle of scale-invariance. Furthermore, in cases where the income distribution is categorized into relatively poor and relatively rich, a valid bipolarization measure should consistently increase when regressive transfers occur from poorer to richer individuals and when progressive transfers occur between two poorer or two richer individuals. The study identifies instances where bipolarization measures that fail to adhere to these criteria have been employed in previous research, leading to erroneous conclusions. The research also provides a succinct analysis of the challenges faced by scholars in employing Esteban and Ray's multipolarization measure and its adapted versions. Artificial numerical examples are used to illustrate the application of different polarization measures in various scenarios. Additionally, a real-world illustration is presented that depicts a declining trend of the bipolarization of income distribution in Brazil from 2001 to 2015, coinciding with a decrease in inequality during this period. The study concludes by pinpointing errors in previously published works.},
copyright = {https://creativecommons.org/licenses/by/4.0/},
langid = {english},
file = {/home/serge/Zotero/storage/WM4696MT/Hoffmann and Kassouf - 2024 - Measuring and Mismeasuring Income Polarization.pdf}
}

@article{wolfson1994WhenInequalities,
title = {When {{Inequalities Diverge}}},
author = {Wolfson, Michael C.},
year = {1994},
journal = {The American Economic Review},
volume = {84},
number = {2},
eprint = {2117858},
eprinttype = {jstor},
pages = {353--358},
publisher = {American Economic Association},
issn = {0002-8282},
urldate = {2024-08-12},
file = {/home/serge/Zotero/storage/8JYHLHTW/Wolfson - 1994 - When Inequalities Diverge.pdf}
}

@article{schutz1951MeasurementIncome,
title = {On the {{Measurement}} of {{Income Inequality}}},
author = {Schutz, Robert R.},
Expand Down
32 changes: 19 additions & 13 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,56 @@ API reference

.. _inequality_api:


Atkinson Inequality Measures
----------------------------

.. autosummary::
:toctree: generated/

inequality.atkinson.Atkinson

atkinson.Atkinson


Gini Inequality Measures
------------------------

.. autosummary::
:toctree: generated/

inequality.gini.Gini
inequality.gini.Gini_Spatial
gini.Gini
gini.Gini_Spatial

Schutz Inequality Measures
--------------------------

.. autosummary::
:toctree: generated/

inequality.schutz.Schutz


schutz.Schutz

Theil Inequality Measures
-------------------------

.. autosummary::
:toctree: generated/

inequality.theil.Theil
inequality.theil.TheilD
inequality.theil.TheilDSim
theil.Theil
theil.TheilD
theil.TheilDSim

Wolfson Bipolarization Measure
------------------------------
.. autosummary::
:toctree: generated/

wolfson.wolfson


Pengram
-------

.. autosummary::
:toctree: generated/

inequality.pen.pen
inequality.pen.pengram
pen.pen
pen.pengram

26 changes: 14 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#

import sphinx_bootstrap_theme

from datetime import datetime

# import your package to obtain the version info to display on the docs website
import inequality
import sphinx_bootstrap_theme

# -- General configuration ------------------------------------------------

Expand All @@ -31,7 +31,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [ #'sphinx_gallery.gen_gallery',
extensions = [ # 'sphinx_gallery.gen_gallery',
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
Expand Down Expand Up @@ -60,7 +60,7 @@

# General information about the project.
project = "inequality" # string of your project name, for example, 'giddy'
copyright = "2018, pysal developers"
copyright = f"2018 - {datetime.now().year}, pysal developers (BSD License)"
author = "pysal developers"

# The version info for the project you're documenting, acts as replacement for
Expand Down Expand Up @@ -95,8 +95,9 @@
# a list of builtin themes.
#
# html_theme = 'alabaster'
html_theme = "bootstrap"
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
# html_theme = "bootstrap"
html_theme = "pydata_sphinx_theme"
# html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
html_title = "%s v%s Manual" % (project, version)

# (Optional) Logo of your package. Should be small enough to fit the navbar (ideally 24x24).
Expand All @@ -105,7 +106,8 @@

# (Optional) PySAL favicon
html_favicon = "_static/images/pysal_favicon.ico"

html_logo = '_static/images/pysal_logo.png'
icon_links_label = 'inequality'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -117,12 +119,12 @@
# Render the next and previous page links in navbar. (Default: true)
"navbar_sidebarrel": False,
# Render the current pages TOC in the navbar. (Default: true)
#'navbar_pagenav': True,
#'navbar_pagenav': False,
# 'navbar_pagenav': True,
# 'navbar_pagenav': False,
# No sidebar
"nosidebar": True,
# Tab name for the current pages TOC. (Default: "Page")
#'navbar_pagenav_name': "Page",
# 'navbar_pagenav_name': "Page",
# Global TOC depth for "site" navbar tab. (Default: 1)
# Switching to -1 shows all levels.
"globaltoc_depth": 2,
Expand All @@ -136,7 +138,7 @@
"globaltoc_includehidden": "true",
# HTML navbar class (Default: "navbar") to attach to <div> element.
# For black navbar, do "navbar navbar-inverse"
#'navbar_class': "navbar navbar-inverse",
# 'navbar_class': "navbar navbar-inverse",
# Fix navigation bar to top of page?
# Values: "true" (default) or "false"
"navbar_fixed_top": "true",
Expand All @@ -154,7 +156,7 @@
# Navigation bar menu
"navbar_links": [
("Installation", "installation"),
("Tutorials", "tutorials"),
("User Guide", "user-guide/intro"),
("API", "api"),
("References", "references"),
],
Expand Down
15 changes: 10 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,19 @@ software, terms & conditions for usage, and a DISCLAIMER OF ALL
WARRANTIES.


inequality
==========

Documentation contents
----------------------

.. toctree::
:hidden:
:maxdepth: 4
:caption: Contents:
:maxdepth: 1

Home <self>
Installation <installation>
Tutorials <tutorials>
API <api>
API reference <api>
user-guide/intro
References <references>

.. _PySAL: https://github.com/pysal/pysal
Expand Down
11 changes: 0 additions & 11 deletions docs/tutorials.rst

This file was deleted.

12 changes: 12 additions & 0 deletions docs/user-guide/intro.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
==========
User Guide
==========

This user guide covers essential features of pysal-inequality, mostly in the form of interactive Jupyter notebooks. Reading this guide, you will learn:

- how to :ref:`visualize <viz>` spatial inequality
- how to :ref:`measure <measure>` spatial inequality

Notebooks cover just a small selection of functions as an illustration of
principles. For a full overview of pysal-inequality capabilities, head to the `API <../api.rst>`_.

Loading
Loading