Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dimension.label replacing global alias state #1083

Merged
merged 18 commits into from Jan 30, 2017
Merged
Diff settings

Always

Just for now

Add Dataset aliasing unit tests

  • Loading branch information...
Philipp Rudiger Philipp Rudiger
Philipp Rudiger authored and Philipp Rudiger committed Jan 21, 2017
commit 0c3aa694bcae101f85a5d88d064b688291df5b65
Copy path View file
@@ -38,6 +38,8 @@ def init_data(self):
self.y_ints = [i*2 for i in range(11)]
self.dataset_hm = Dataset((self.xs, self.y_ints),
kdims=['x'], vdims=['y'])
self.dataset_hm_alias = Dataset((self.xs, self.y_ints),
kdims=[('x', 'X')], vdims=[('y', 'Y')])

def tearDown(self):
Dataset.datatype = self.restore_datatype
@@ -109,24 +111,37 @@ def test_dataset_redim_hm_kdim(self):
self.assertEqual(redimmed.dimension_values('Time'),
self.dataset_hm.dimension_values('x'))

def test_dataset_redim_hm_kdim_alias(self):
redimmed = self.dataset_hm_alias.redim(x='Time')
self.assertEqual(redimmed.dimension_values('Time'),
self.dataset_hm_alias.dimension_values('x'))

def test_dataset_redim_hm_vdim(self):
redimmed = self.dataset_hm.redim(y='Value')
self.assertEqual(redimmed.dimension_values('Value'),
self.dataset_hm.dimension_values('y'))

def test_dataset_redim_hm_vdim_alias(self):
redimmed = self.dataset_hm.redim(y=Dimension(('val', 'Value')))
redimmed = self.dataset_hm_alias.redim(y=Dimension(('val', 'Value')))
self.assertEqual(redimmed.dimension_values('Value'),
self.dataset_hm.dimension_values('y'))
self.dataset_hm_alias.dimension_values('y'))

def test_dataset_sample_hm(self):
samples = self.dataset_hm.sample([0, 5, 10]).dimension_values('y')
self.assertEqual(samples, np.array([0, 10, 20]))

def test_dataset_sample_hm_alias(self):
samples = self.dataset_hm_alias.sample([0, 5, 10]).dimension_values('y')
self.assertEqual(samples, np.array([0, 10, 20]))

def test_dataset_array_hm(self):
self.assertEqual(self.dataset_hm.array(),
np.column_stack([self.xs, self.y_ints]))

def test_dataset_array_hm_alias(self):
self.assertEqual(self.dataset_hm_alias.array(),
np.column_stack([self.xs, self.y_ints]))

def test_dataset_add_dimensions_value_hm(self):
table = self.dataset_hm.add_dimension('z', 1, 0)
self.assertEqual(table.kdims[1], 'z')
@@ -145,7 +160,7 @@ def test_dataset_slice_hm(self):
def test_dataset_slice_hm_alias(self):
dataset_slice = Dataset({'x':range(5, 9), 'y':[2 * i for i in range(5, 9)]},
kdims=[('x', 'X')], vdims=[('y', 'Y')])
self.assertEqual(self.dataset_hm[5:9].redim(x='X', y='Y'), dataset_slice)
self.assertEqual(self.dataset_hm_alias[5:9], dataset_slice)

def test_dataset_slice_fn_hm(self):
dataset_slice = Dataset({'x':range(5, 9), 'y':[2 * i for i in range(5, 9)]},
@@ -594,6 +609,8 @@ def init_data(self):
self.y_ints = [i*2 for i in range(11)]
self.dataset_hm = Dataset((self.xs, self.y_ints),
kdims=['x'], vdims=['y'])
self.dataset_hm_alias = Dataset((self.xs, self.y_ints),
kdims=[('x', 'X')], vdims=[('y', 'Y')])
self.grid_xs = [0, 1]
self.grid_ys = [0.1, 0.2, 0.3]
self.grid_zs = [[0, 1], [2, 3], [4, 5]]
@@ -869,6 +886,10 @@ def test_dataset_2D_aggregate_partial_hm_alias(self):
def test_dataset_sample_hm(self):
raise SkipTest("Not supported")

def test_dataset_sample_hm_alias(self):
raise SkipTest("Not supported")


class XArrayDatasetTest(GridDatasetTest):
"""
Tests for Iris interface
@@ -893,3 +914,6 @@ def test_dataset_sort_vdim_hm(self):

def test_dataset_sample_hm(self):
raise SkipTest("Not supported")

def test_dataset_sample_hm_alias(self):
raise SkipTest("Not supported")
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.