def test_build_discrete_cmap(self): for (cmap, levels, extend, filled) in [("jet", [0, 1], "both", False), ("hot", [-4, 4], "max", True)]: ncmap, cnorm = _build_discrete_cmap(cmap, levels, extend, filled) self.assertEqual(ncmap.N, len(levels) - 1) self.assertEqual(len(ncmap.colors), len(levels) - 1) self.assertEqual(cnorm.N, len(levels)) self.assertArrayEqual(cnorm.boundaries, levels) self.assertEqual(max(levels), cnorm.vmax) self.assertEqual(min(levels), cnorm.vmin) if filled: self.assertEqual(ncmap.colorbar_extend, extend) else: self.assertEqual(ncmap.colorbar_extend, "neither")
def test_build_discrete_cmap(self): for (cmap, levels, extend, filled) in [('jet', [0, 1], 'both', False), ('hot', [-4, 4], 'max', True)]: ncmap, cnorm = _build_discrete_cmap(cmap, levels, extend, filled) self.assertEqual(ncmap.N, len(levels) - 1) self.assertEqual(len(ncmap.colors), len(levels) - 1) self.assertEqual(cnorm.N, len(levels)) self.assertArrayEqual(cnorm.boundaries, levels) self.assertEqual(max(levels), cnorm.vmax) self.assertEqual(min(levels), cnorm.vmin) if filled: self.assertEqual(ncmap.colorbar_extend, extend) else: self.assertEqual(ncmap.colorbar_extend, 'neither')
def test_build_discrete_cmap(self): for (cmap, levels, extend, filled) in [('jet', [0, 1], 'both', False), ('hot', [-4, 4], 'max', True)]: ncmap, cnorm = _build_discrete_cmap(cmap, levels, extend, filled) self.assertEqual(ncmap.N, len(levels) - 1) self.assertEqual(len(ncmap.colors), len(levels) - 1) self.assertEqual(cnorm.N, len(levels)) self.assertArrayEqual(cnorm.boundaries, levels) self.assertEqual(max(levels), cnorm.vmax) self.assertEqual(min(levels), cnorm.vmin) if filled: self.assertEqual(ncmap.colorbar_extend, extend) else: self.assertEqual(ncmap.colorbar_extend, 'max')
def test_build_discrete_cmap(self): for (cmap, levels, extend, filled) in [('jet', [0, 1], 'both', False), ('hot', [-4, 4], 'max', True)]: ncmap, cnorm = _build_discrete_cmap(cmap, levels, extend, filled) assert ncmap.N == len(levels) - 1 assert len(ncmap.colors) == len(levels) - 1 assert cnorm.N == len(levels) assert_array_equal(cnorm.boundaries, levels) assert max(levels) == cnorm.vmax assert min(levels) == cnorm.vmin if filled: assert ncmap.colorbar_extend == extend else: assert ncmap.colorbar_extend == 'max'