Skip to content

Commit

Permalink
Merge branch 'master' into lps_weights_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jGaboardi authored Jan 26, 2021
2 parents 06f3e96 + 57c0b3d commit 8f94406
Show file tree
Hide file tree
Showing 13 changed files with 774 additions and 961 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@
run: |
export PKG=$(ls dist/)
set -- $PKG
echo "name=whl_path" >> $GITHUB_ENV
echo "name=$1" >> $GITHUB_ENV
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/${{ env.whl_path }}
asset_name: ${{ env.whl_path }}
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: dist/${{ env.name }}
asset_name: ${{ env.name }}
asset_content_type: application/zip
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
Expand Down
15 changes: 7 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Python Spatial Analysis Library Core


.. image:: https://github.com/pysal/libpysal/workflows/.github/workflows/unittests.yml/badge.svg
:target: https://github.com/pysal/libpysal/actions?query=workflow%3A.github%2Fworkflows%2Funittests.yml
:target: https://github.com/pysal/libpysal/actions?query=workflow%3A.github%2Fworkflows%2Funittests.yml

.. image:: https://codecov.io/gh/pysal/libpysal/branch/master/graph/badge.svg
:target: https://codecov.io/gh/pysal/libpysal
Expand All @@ -12,10 +12,10 @@ Python Spatial Analysis Library Core
:target: https://badge.fury.io/py/libpysal

.. image:: https://img.shields.io/conda/vn/conda-forge/libpysal.svg
:target: https://anaconda.org/conda-forge/libpysal
:target: https://anaconda.org/conda-forge/libpysal

.. image:: https://zenodo.org/badge/81501824.svg
:target: https://zenodo.org/badge/latestdoi/81501824
:target: https://zenodo.org/badge/latestdoi/81501824


****************
Expand Down Expand Up @@ -69,14 +69,13 @@ the `Contributors List <https://github.com/pysal/libpysal/graphs/contributors>`_
Bug reports
***********

To search for or report bugs, please see libpysal's issues_.
To search for or report bugs, please see `libpysal's issues <https://github.com/pysal/libpysal/issues>`_.

.. _issues : http://github.com/pysal/libpysal/issues

*******************
License information
*******************

See the `LICENSE <https://github.com/pysal/libpysal/blob/master/LICENSE.txt>`_ for information on the history of this
software, terms & conditions for usage, and a DISCLAIMER OF ALL
WARRANTIES.
See the `LICENSE <https://github.com/pysal/libpysal/blob/master/LICENSE.txt>`_
for information on the history of this software, terms & conditions for usage,
and a DISCLAIMER OF ALL WARRANTIES.
2 changes: 2 additions & 0 deletions ci/38.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ dependencies:
# optional
- geopandas>=0.7.0
- numba
- xarray
- joblib
- zstd
34 changes: 34 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: libpysal
channels:
- conda-forge
dependencies:
- jupyterlab
- beautifulsoup4
- pandas
- requests
- jinja2
- numpydoc
- nbsphinx
- pandoc
- sphinx>=1.4.3
- sphinxcontrib-bibtex
- sphinx_bootstrap_theme>=0.7.0
- bokeh>=0.11.1
- folium>=0.2.1
- geojson>=1.3.2
- geopandas>=0.2
- matplotlib>=1.5.1
- mplleaflet>=0.0.5
- numba
- numexpr
- networkx
- scikit-learn>=0.17.1
- seaborn>=0.7.0
- sqlalchemy
- statsmodels>=0.6.1
- xarray
- codecov
- pytest
- pytest-cov
- descartes
- mapclassify
2 changes: 1 addition & 1 deletion libpysal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "4.3.1"
__version__ = "4.3.5"

# __version__ has to be define in the first line

Expand Down
80 changes: 68 additions & 12 deletions libpysal/weights/contiguity.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,21 @@ def from_dataframe(
return w

@classmethod
def from_xarray(cls, da, z_value=None, coords_labels={}, sparse=False, **kwargs):
"""Construct a weights object from a ``xarray.DataArray``.
def from_xarray(
cls,
da,
z_value=None,
coords_labels={},
k=1,
include_nodata=False,
n_jobs=1,
sparse=True,
**kwargs,
):
"""
Construct a weights object from a ``xarray.DataArray`` with an additional
attribute index containing coordinate values of the raster
in the form of ``pandas.Index or ``pandas.MultiIndex``.
Parameters
----------
Expand All @@ -246,14 +259,29 @@ def from_xarray(cls, da, z_value=None, coords_labels={}, sparse=False, **kwargs)
sparse : bool
The type of weight object. Default is ``False``.
For sparse set to ``True``.
k : int
Order of contiguity, this will select all neighbors up to ``k``th order.
Default is ``1``.
include_nodata : bool
If ``True,`` missing values will be assumed as non-missing when
selecting higher_order neighbors. Default is ``False``.
n_jobs : int
Number of cores to be used in the sparse weight construction. If ``-1``,
all available cores are used. Default is ``1``.
**kwargs : keyword arguments
Optional arguments passed when ``sparse=False``.
Returns
-------
w : {libpysal.weights.W, libpysal.weights.WSP}
An instance of spatial weights class `W` or `WSP`.
An instance of spatial weights class `W` or `WSP` with an index attribute.
Notes
-----
1. Lower order contiguities are also selected.
2. Returned object contains and ``index`` attribute that includes a
``pandas.MultiIndex`` object from the ``xarray.DataArray``.
See Also
--------
Expand All @@ -263,9 +291,9 @@ def from_xarray(cls, da, z_value=None, coords_labels={}, sparse=False, **kwargs)
"""

if sparse:
w = da2WSP(da, "rook", z_value, coords_labels)
w = da2WSP(da, "rook", z_value, coords_labels, k, include_nodata)
else:
w = da2W(da, "rook", z_value, coords_labels, **kwargs)
w = da2W(da, "rook", z_value, coords_labels, k, include_nodata, **kwargs)

return w

Expand Down Expand Up @@ -474,8 +502,21 @@ def from_dataframe(cls, df, geom_col=None, **kwargs):
return w

@classmethod
def from_xarray(cls, da, z_value=None, coords_labels={}, sparse=False, **kwargs):
"""Construct a weights object from a ``xarray.DataArray``.
def from_xarray(
cls,
da,
z_value=None,
coords_labels={},
k=1,
include_nodata=False,
n_jobs=1,
sparse=True,
**kwargs,
):
"""
Construct a weights object from a ``xarray.DataArray`` with an additional
attribute index containing coordinate values of the raster
in the form of ``pandas.Index`` or ``pandas.MultiIndex``.
Parameters
----------
Expand All @@ -492,14 +533,29 @@ def from_xarray(cls, da, z_value=None, coords_labels={}, sparse=False, **kwargs)
sparse : bool
The type of weight object. Default is ``False``.
For sparse set to ``True``.
k : int
Order of contiguity, this will select all neighbors up to ``k``th order.
Default is ``1``.
include_nodata : bool
If ``True``, missing values will be assumed as non-missing when
selecting higher_order neighbors. Default is ``False``.
n_jobs : int
Number of cores to be used in the sparse weight construction. If ``-1``,
all available cores are used. Default is ``1``.
**kwargs : keyword arguments
Optional arguments passed when ``sparse=False``.
Returns
-------
w : {libpysal.weights.W, libpysal.weights.WSP}
An instance of spatial weights class `W` or `WSP`.
An instance of spatial weights class `W` or `WSP` with an index attribute.
Notes
-----
1. Lower order contiguities are also selected.
2. Returned object contains `index` attribute that includes a
``pandas.MultiIndex`` object from the ``xarray.DataArray``.
See Also
--------
Expand All @@ -509,9 +565,9 @@ def from_xarray(cls, da, z_value=None, coords_labels={}, sparse=False, **kwargs)
"""

if sparse:
w = da2WSP(da, "queen", z_value, coords_labels)
w = da2WSP(da, "queen", z_value, coords_labels, k, include_nodata)
else:
w = da2W(da, "queen", z_value, coords_labels, **kwargs)
w = da2W(da, "queen", z_value, coords_labels, k, include_nodata, **kwargs)
return w


Expand Down
Loading

0 comments on commit 8f94406

Please sign in to comment.