Skip to content

Commit

Permalink
fixed dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
MgeeeeK committed Aug 28, 2020
1 parent 54abf81 commit 72028ba
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 84 deletions.
1 change: 0 additions & 1 deletion ci/36.yaml
Expand Up @@ -12,7 +12,6 @@ dependencies:
- matplotlib
# optional
- geopandas
- numba
- xarray
- joblib
- zstd
26 changes: 5 additions & 21 deletions libpysal/weights/raster.py
Expand Up @@ -4,23 +4,7 @@
from warnings import warn
import os
from scipy import sparse

# taken from esda/#116
try:
from numba import njit
except (ImportError, ModuleNotFoundError):

def jit(*dec_args, **dec_kwargs):
"""
decorator mimicking numba.jit
"""

def intercepted_function(f, *f_args, **f_kwargs):
return f

return intercepted_function

njit = jit
from ..common import jit

__author__ = "Mragank Shekhar <yesthisismrshekhar@gmail.com>"

Expand Down Expand Up @@ -532,7 +516,7 @@ def _index2da(data, index, attrs, coords):
return da.sortby(dims[-2], False)


@njit(fastmath=True)
@jit(nopython=True, fastmath=True)
def _idmap(ids, mask, dtype):
"""
Utility function computes id_map of non-missing raster data
Expand All @@ -556,7 +540,7 @@ def _idmap(ids, mask, dtype):
return id_map


@njit(fastmath=True)
@jit(nopython=True, fastmath=True)
def _SWbuilder(
nrows, ncols, ids, id_map, criterion, k, dtype,
):
Expand Down Expand Up @@ -597,7 +581,7 @@ def _SWbuilder(
return (data, (rows, cols))


@njit(fastmath=True, nogil=True)
@jit(nopython=True, fastmath=True, nogil=True)
def _compute_chunk(
nrows, ncols, ids, id_map, criterion, k, dtype,
):
Expand Down Expand Up @@ -720,7 +704,7 @@ def _compute_chunk(
return rows[:ni], cols[:ni], ni


@njit(fastmath=True)
@jit(nopython=True, fastmath=True)
def chunk_generator(
n_jobs, starts, ids,
):
Expand Down
4 changes: 2 additions & 2 deletions libpysal/weights/tests/test_raster.py
Expand Up @@ -15,7 +15,7 @@ def setUp(self):
self.data1 = pd.Series(np.ones(5))

def test_da2W(self):
w1 = raster.da2W(self.da1, "queen", k=2)
w1 = raster.da2W(self.da1, "queen", k=2, n_jobs=-1)
self.assertEqual(w1[13], {11: 1, 14: 1, 8: 1})
self.assertEqual(w1[14], {8: 1, 13: 1, 11: 1})
self.assertEqual(w1.n, 5)
Expand Down Expand Up @@ -56,7 +56,7 @@ def test_da2WSP(self):
self.assertEqual(w1.index.tolist()[1], (1, -30.0, -180.0))
self.assertEqual(w1.index.tolist()[2], (1, -30.0, 180.0))
self.assertEqual(w1.index.tolist()[3], (1, -90.0, -60.0))
w2 = raster.da2W(self.da2, "queen")
w2 = raster.da2W(self.da2, "queen", n_jobs=-1)
sw = lat2SW(4, 4, "queen")
self.assertEqual(w2.sparse.nnz, sw.nnz)
self.assertEqual(w2.sparse.todense().tolist(), sw.todense().tolist())
Expand Down
198 changes: 142 additions & 56 deletions notebooks/Raster Interface.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions notebooks/Raster_awareness_API.ipynb
Expand Up @@ -673,8 +673,8 @@
}
],
"source": [
"w_queen = raster.da2WSP(da_s, \"rook\", k=2, n_jobs=-1)\n",
"splot.plot_spatial_weights(w_queen, da=da_s)"
"w_rook2 = raster.da2WSP(da_s, \"rook\", k=2, n_jobs=-1)\n",
"splot.plot_spatial_weights(w_rook2, da=da_s)"
]
},
{
Expand Down Expand Up @@ -715,8 +715,8 @@
}
],
"source": [
"w_queen = raster.da2WSP(da_s, \"rook\", k=2, n_jobs=-1, include_nas=True)\n",
"splot.plot_spatial_weights(w_queen, da=da_s)"
"w_rook2 = raster.da2WSP(da_s, \"rook\", k=2, n_jobs=-1, include_nas=True)\n",
"splot.plot_spatial_weights(w_rook2, da=da_s)"
]
},
{
Expand Down

0 comments on commit 72028ba

Please sign in to comment.