restored correct bound calculation
test different bounds options
This commit is contained in:
parent
e07c00a592
commit
7d49606597
|
@ -186,7 +186,7 @@ class Colormap(mpl.colors.ListedColormap):
|
|||
np.logical_or (np.isnan(field), field == gap)) # mask gap and NaN (if gap present)
|
||||
|
||||
if bounds is None:
|
||||
hi,lo = field[mask].min(),field[mask].max()
|
||||
hi,lo = field[mask].max(),field[mask].min()
|
||||
else:
|
||||
hi,lo = bounds[::-1]
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 143 B |
Binary file not shown.
After Width: | Height: | Size: 146 B |
Binary file not shown.
After Width: | Height: | Size: 136 B |
|
@ -131,13 +131,14 @@ class TestColormap:
|
|||
c += c
|
||||
assert (np.allclose(c.colors[:len(c.colors)//2],c.colors[len(c.colors)//2:]))
|
||||
|
||||
def test_shade(self,reference_dir,update):
|
||||
@pytest.mark.parametrize('bounds',[None,[2,10]])
|
||||
def test_shade(self,reference_dir,update,bounds):
|
||||
data = np.add(*np.indices((10, 11)))
|
||||
img_current = Colormap.from_predefined('orientation').shade(data)
|
||||
img_current = Colormap.from_predefined('orientation').shade(data,bounds=bounds)
|
||||
if update:
|
||||
img_current.save(reference_dir/'shade.png')
|
||||
img_current.save(reference_dir/f'shade_{bounds}.png')
|
||||
else:
|
||||
img_reference = Image.open(reference_dir/'shade.png')
|
||||
img_reference = Image.open(reference_dir/f'shade_{bounds}.png')
|
||||
diff = ImageChops.difference(img_reference.convert('RGB'),img_current.convert('RGB'))
|
||||
assert not diff.getbbox()
|
||||
|
||||
|
|
Loading…
Reference in New Issue