Skip to content

Commit

Permalink
Minor cleanup; bump version number
Browse files Browse the repository at this point in the history
  • Loading branch information
mdbartos committed Jan 27, 2022
1 parent 2964c8d commit b0f8bf5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pysheds/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.1"
__version__ = "0.3.2"
2 changes: 2 additions & 0 deletions pysheds/_sgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,8 @@ def _flatten_fdir_numba(fdir, dirmap):
on_bottom = (k > (n - c - 1))
on_boundary = (on_left | on_right | on_top | on_bottom)
if on_boundary:
# TODO: This seems like it could cause errors at corner points
# TODO: Check if offset is already zero
if on_left:
offset = left_map[cell_dir]
if on_right:
Expand Down
20 changes: 8 additions & 12 deletions pysheds/sview.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,6 @@ def view(self, raster, **kwargs):
target_view = self
return View.view(raster, data_view, target_view, **kwargs)

# TODO: Ensure that target_view cannot be 3-dimensional
# TODO: Or use only last two entries of viewfinder.shape
class View():
"""
Class containing methods for manipulating views of gridded datasets.
Expand Down Expand Up @@ -585,7 +583,7 @@ def view(cls, data, target_view, data_view=None, interpolation='nearest',
# Mask input data if desired
has_input_mask = not data_view.mask.all()
if apply_input_mask and has_input_mask:
# TODO: Is this necessary?
# TODO: Rewrite to avoid copying.
arr = np.where(data_view.mask, data, target_view.nodata).astype(dtype)
data = Raster(arr, data.viewfinder, metadata=data.metadata)
if is_multiraster or is_3d_array:
Expand Down Expand Up @@ -738,10 +736,10 @@ def axes(cls, affine, shape):
y, x : tuple
y- and x-coordinates of axes
"""
y_ix = np.arange(shape[0])
x_ix = np.arange(shape[1])
x_null = np.zeros(shape[0])
y_null = np.zeros(shape[1])
y_ix = np.arange(shape[-2])
x_ix = np.arange(shape[-1])
x_null = np.zeros(shape[-2])
y_null = np.zeros(shape[-1])
x, _ = cls.affine_transform(affine, x_ix, y_null)
_, y = cls.affine_transform(affine, x_null, y_ix)
return y, x
Expand Down Expand Up @@ -922,7 +920,6 @@ def _override_dtype(cls, data, target_view, dtype=None, interpolation='nearest')
raise TypeError('`object` and `flexible` dtypes not allowed.')
return dtype

# TODO: Can speed this up by giving option to not copy
@classmethod
def _view_same_viewfinder(cls, data, data_view, target_view, out, dtype,
apply_output_mask=True):
Expand All @@ -936,7 +933,6 @@ def _view_same_viewfinder(cls, data, data_view, target_view, out, dtype,
@classmethod
def _view_different_viewfinder(cls, data, data_view, target_view, out, dtype,
apply_output_mask=True, interpolation='nearest'):
# TODO: May need to fill with nodata here
if (data_view.crs == target_view.crs):
out = cls._view_same_crs(out, data, data_view,
target_view, interpolation)
Expand All @@ -954,13 +950,13 @@ def _view_same_crs(cls, view, data, data_view, target_view, interpolation='neare
y, x = target_view.axes
inv_affine = ~data_view.affine
_, y_ix = cls.affine_transform(inv_affine,
np.zeros(target_view.shape[0],
np.zeros(target_view.shape[-2],
dtype=np.float64), y)
x_ix, _ = cls.affine_transform(inv_affine, x,
np.zeros(target_view.shape[1],
np.zeros(target_view.shape[-1],
dtype=np.float64))
nodata = target_view.nodata
# TODO: Does this work for rotated data? Or is it for axis-aligned data only?
# TODO: Check that this works for rotated data.
if interpolation == 'nearest':
view = _self._view_fill_by_axes_nearest_numba(data, view, y_ix, x_ix, nodata)
elif interpolation == 'linear':
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup

setup(name='pysheds',
version='0.3.1',
version='0.3.2',
description='🌎 Simple and fast watershed delineation in python.',
author='Matt Bartos',
author_email='mdbartos@umich.edu',
Expand Down

0 comments on commit b0f8bf5

Please sign in to comment.