def test_Axis_iterator_multiple_items_0d(): name = "some_name" label = "some_label" unit = "some_unit" arrays = [np.array(1), np.array(2), np.array(3)] axis = Axis(arrays[0], name=name, label=label, unit=unit) axis.append(Axis(arrays[1], name=name, label=label, unit=unit)) axis.append(Axis(arrays[2], name=name, label=label, unit=unit)) for ax, arr in zip(axis, arrays): assert ax is not axis assert ax.name == name assert ax.label == label assert ax.unit == unit np.testing.assert_array_equal(ax, arr)
def test_Axis_len(): axis = Axis(1) assert len(axis) == 1 axis.append(Axis(2)) assert len(axis) == 2 axis.append(Axis([3, 4])) assert len(axis) == 4 axis = Axis([1]) assert len(axis) == 1 axis = Axis([1, 2]) assert len(axis) == 2 axis = Axis([[1, 2]]) assert len(axis) == 1
def test_Axis_append(): axis = Axis(1) assert axis.shape == () axis.append(Axis(2)) assert axis.shape == (2, ) np.testing.assert_array_equal(axis, [1, 2]) axis.append(Axis([3, 4])) assert axis.shape == (4, ) np.testing.assert_array_equal(axis, [1, 2, 3, 4]) axis = Axis(1) axis.append(Axis([2, 3])) assert axis.shape == (3, ) np.testing.assert_array_equal(axis, [1, 2, 3]) axis = Axis([[1, 2]]) assert axis.shape == (2, ) axis.append(Axis([[3, 4]])) assert axis.shape == (2, 2) axis.append(Axis([[5, 6]])) assert axis.shape == (3, 2)