Skip to content

Commit

Permalink
added basic test of apply_colormap
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Sep 1, 2021
1 parent 3645caa commit 43dc4d5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/silx/math/test/test_colormap.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import logging
import sys
import unittest

import numpy

Expand Down Expand Up @@ -251,3 +250,20 @@ def test_errors(self):
normalization, vmin, vmax)
with self.assertRaises(ValueError):
self._test(data, colors, vmin, vmax, normalization, None)


def test_apply_colormap():
"""Basic test of silx.math.colormap.apply_colormap"""
data = numpy.arange(256)
expected_colors = numpy.empty((256, 4), dtype=numpy.uint8)
expected_colors[:, :3] = numpy.arange(256, dtype=numpy.uint8).reshape(256, 1)
expected_colors[:, 3] = 255
colors = colormap.apply_colormap(
data,
colormap="gray",
norm="linear",
autoscale="minmax",
vmin=None,
vmax=None,
gamma=1.0)
assert numpy.array_equal(colors, expected_colors)

0 comments on commit 43dc4d5

Please sign in to comment.