Skip to content

Commit

Permalink
Added unit tests for grid reindexing
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 28, 2018
1 parent e947bb4 commit de4cba1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions tests/core/data/testgridinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@ def test_dataset_ndloc_slice_two_vdims(self):
datatype=['dictionary'])
self.assertEqual(ds.ndloc[[0, 1, 2], [1, 2, 3]], sliced)

def test_reindex_drop_scalars_xs(self):
reindexed = self.dataset_grid.ndloc[:, 0].reindex()
ds = Dataset((self.grid_ys, self.grid_zs[:, 0]), 'y', 'z')
self.assertEqual(reindexed, ds)

def test_reindex_drop_scalars_ys(self):
reindexed = self.dataset_grid.ndloc[0].reindex()
ds = Dataset((self.grid_xs, self.grid_zs[0]), 'x', 'z')
self.assertEqual(reindexed, ds)



class DaskGridInterfaceTests(GridInterfaceTests):
Expand Down
4 changes: 2 additions & 2 deletions tests/core/data/testxarrayinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def init_grid_data(self):
import dask.array
self.grid_xs = [0, 1]
self.grid_ys = [0.1, 0.2, 0.3]
self.grid_zs = [[0, 1], [2, 3], [4, 5]]
dask_zs = dask.array.from_array(np.array(self.grid_zs), 2)
self.grid_zs = np.array([[0, 1], [2, 3], [4, 5]])
dask_zs = dask.array.from_array(self.grid_zs, 2)
self.dataset_grid = self.element((self.grid_xs, self.grid_ys,
dask_zs), kdims=['x', 'y'],
vdims=['z'])
Expand Down

0 comments on commit de4cba1

Please sign in to comment.