Skip to content

Commit

Permalink
Do not pass masked arrays to numba (#1205)
Browse files Browse the repository at this point in the history
* Do not pass masked arrays to numba

* Linting

* Temporarily force use of numba 0.57.0rc1 in CI

* Replace deprecated getargspec with getfullargspec

* Add python 3.11 to CI

* Update tox

* Use numba 0.57 release not RC

* Reduce number of pip tests

* Remove numba and pandas version pins
  • Loading branch information
ianthomas23 authored May 9, 2023
1 parent 80d1ccf commit 31b3182
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
timeout-minutes: 180
defaults:
run:
Expand All @@ -35,7 +35,7 @@ jobs:
name: unit_test_suite
python-version: ${{ matrix.python-version }}
channel-priority: strict
channels: pyviz/label/dev,conda-forge,nodefaults
channels: pyviz/label/dev,numba,conda-forge,nodefaults
envs: "-o tests -o examples"
cache: true
conda-update: true
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest']
python-version: ["3.9"]
python-version: ["3.10"]
steps:
- name: Checkout source
uses: actions/checkout@v3
Expand Down
11 changes: 1 addition & 10 deletions datashader/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,6 @@ def raster(self,
if layer is not None:
source=source.sel(**{source.dims[0]: layer})
array = orient_array(source, res)
dtype = array.dtype

if nan_value is not None:
mask = array==nan_value
Expand Down Expand Up @@ -1166,14 +1165,6 @@ def raster(self,
if res[1] > 0: data = data[::-1]
if res[0] < 0: data = data[:, ::-1]

# Restore nan_value from masked array
if nan_value is not None:
data = data.filled()

# Restore original dtype
if dtype != data.dtype:
data = data.astype(dtype)

# Compute DataArray metadata

# To avoid floating point representation error,
Expand Down Expand Up @@ -1230,7 +1221,7 @@ def validate_ranges(self, x_range, y_range):
def validate_size(self, width, height):
if width <= 0 or height <= 0:
raise ValueError("Invalid size: plot_width and plot_height must be bigger than 0")

def validate(self):
"""Check that parameter settings are valid for this object"""
self.validate_ranges(self.x_range, self.y_range)
Expand Down
4 changes: 2 additions & 2 deletions datashader/glyphs/glyph.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ def _expand_aggs_and_cols(append, ndims, antialiased):
warnings.simplefilter("ignore")
try:
# Numba keeps original function around as append.py_func
append_args = inspect.getargspec(append.py_func).args
append_args = inspect.getfullargspec(append.py_func).args
except (TypeError, AttributeError):
# Treat append as a normal python function
append_args = inspect.getargspec(append).args
append_args = inspect.getfullargspec(append).args

# Get number of arguments accepted by append
append_arglen = len(append_args)
Expand Down
3 changes: 3 additions & 0 deletions datashader/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ def resample_2d(src, w, h, ds_method='mean', us_method='linear',
us_method=upsample_methods[us_method]
ds_method=downsample_methods[ds_method]

if isinstance(src, np.ma.MaskedArray):
src = src.data

resampled = _resample_2d(src, mask, use_mask, ds_method, us_method,
fill_value, mode_rank, x_offset, y_offset, out)
return _mask_or_not(resampled, src, fill_value)
Expand Down
2 changes: 1 addition & 1 deletion datashader/tests/test_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def function_with_vararg_call_numba(a, b, *others):
def get_args(fn):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
spec = inspect.getargspec(fn)
spec = inspect.getfullargspec(fn)

args = spec.args
if spec.varargs:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
'colorcet',
'dask',
'datashape',
'numba >=0.51',
'numba',
'numpy',
'pandas <2',
'pandas',
'param',
'pillow',
'pyct',
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[tox]
# python version test group extra envs extra commands
envlist = {py38,py39,py310}-{lint,unit,unit_nojit,unit_deploy,examples,all,examples_extra}-{default}-{dev,pkg}
envlist = {py38,py39,py310,py311}-{lint,unit,unit_nojit,unit_deploy,examples,all,examples_extra}-{default}-{dev,pkg}
build = wheel

[_lint]
Expand Down

0 comments on commit 31b3182

Please sign in to comment.