summaryrefslogtreecommitdiff
path: root/silx/math/test
diff options
context:
space:
mode:
Diffstat (limited to 'silx/math/test')
-rw-r--r--silx/math/test/test_HistogramndLut_nominal.py3
-rw-r--r--silx/math/test/test_colormap.py8
-rw-r--r--silx/math/test/test_combo.py21
-rw-r--r--silx/math/test/test_histogramnd_nominal.py27
4 files changed, 34 insertions, 25 deletions
diff --git a/silx/math/test/test_HistogramndLut_nominal.py b/silx/math/test/test_HistogramndLut_nominal.py
index 9450326..08ca682 100644
--- a/silx/math/test/test_HistogramndLut_nominal.py
+++ b/silx/math/test/test_HistogramndLut_nominal.py
@@ -1,6 +1,6 @@
# coding: utf-8
# /*##########################################################################
-# Copyright (C) 2016 European Synchrotron Radiation Facility
+# Copyright (C) 2016-2019 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -112,6 +112,7 @@ class _TestHistogramndLut_nominal(unittest.TestCase):
def fill_histo(h, v, dim, op=None):
idx = [self.other_axes_index]*len(h.shape)
idx[dim] = slice(0, None)
+ idx = tuple(idx)
if op:
h[idx] = op(h[idx], v)
else:
diff --git a/silx/math/test/test_colormap.py b/silx/math/test/test_colormap.py
index ede7d8d..cafe537 100644
--- a/silx/math/test/test_colormap.py
+++ b/silx/math/test/test_colormap.py
@@ -1,7 +1,7 @@
# coding: utf-8
# /*##########################################################################
#
-# Copyright (c) 2018 European Synchrotron Radiation Facility
+# Copyright (c) 2018-2019 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -34,6 +34,7 @@ __date__ = "16/05/2018"
import logging
import sys
import unittest
+import warnings
import numpy
@@ -66,7 +67,10 @@ class TestColormap(ParametricTestCase):
'sqrt': numpy.sqrt}
norm_function = norm_functions[normalization]
- norm_data, vmin, vmax = map(norm_function, (data, vmin, vmax))
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', category=RuntimeWarning)
+ # Ignore divide by zero and invalid value encountered in log10, sqrt
+ norm_data, vmin, vmax = map(norm_function, (data, vmin, vmax))
if normalization == 'arcsinh' and sys.platform == 'win32':
# There is a difference of behavior of numpy.arcsinh
diff --git a/silx/math/test/test_combo.py b/silx/math/test/test_combo.py
index 2e142f3..8732954 100644
--- a/silx/math/test/test_combo.py
+++ b/silx/math/test/test_combo.py
@@ -1,6 +1,6 @@
# coding: utf-8
# /*##########################################################################
-# Copyright (C) 2016-2017 European Synchrotron Radiation Facility
+# Copyright (C) 2016-2019 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -31,6 +31,7 @@ __date__ = "17/01/2018"
import unittest
+import warnings
import numpy
@@ -73,22 +74,24 @@ class TestMinMax(ParametricTestCase):
filtered_data = data
if filtered_data.size > 0:
- minimum = numpy.nanmin(filtered_data)
- if numpy.isnan(minimum):
+ if numpy.all(numpy.isnan(filtered_data)):
+ minimum = numpy.nan
argmin = 0
+ maximum = numpy.nan
+ argmax = 0
else:
+ minimum = numpy.nanmin(filtered_data)
# nanargmin equivalent
argmin = numpy.where(data == minimum)[0][0]
-
- maximum = numpy.nanmax(filtered_data)
- if numpy.isnan(maximum):
- argmax = 0
- else:
+ maximum = numpy.nanmax(filtered_data)
# nanargmax equivalent
argmax = numpy.where(data == maximum)[0][0]
if min_positive:
- pos_data = filtered_data[filtered_data > 0]
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', category=RuntimeWarning)
+ # Ignore invalid value encountered in greater
+ pos_data = filtered_data[filtered_data > 0]
if pos_data.size > 0:
min_pos = numpy.min(pos_data)
argmin_pos = numpy.where(data == min_pos)[0][0]
diff --git a/silx/math/test/test_histogramnd_nominal.py b/silx/math/test/test_histogramnd_nominal.py
index 9f97521..92febdd 100644
--- a/silx/math/test/test_histogramnd_nominal.py
+++ b/silx/math/test/test_histogramnd_nominal.py
@@ -1,6 +1,6 @@
# coding: utf-8
# /*##########################################################################
-# Copyright (C) 2016 European Synchrotron Radiation Facility
+# Copyright (C) 2016-2019 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -113,6 +113,7 @@ class _Test_chistogramnd_nominal(unittest.TestCase):
def fill_histo(h, v, dim, op=None):
idx = [self.other_axes_index]*len(h.shape)
idx[dim] = slice(0, None)
+ idx = tuple(idx)
if op:
h[idx] = op(h[idx], v)
else:
@@ -366,9 +367,9 @@ class _Test_chistogramnd_nominal(unittest.TestCase):
sample_2 = self.sample[:]
if len(sample_2.shape) == 1:
- idx = [slice(0, None)]
+ idx = (slice(0, None),)
else:
- idx = [slice(0, None), self.tested_dim]
+ idx = slice(0, None), self.tested_dim
sample_2[idx] += 2
@@ -402,9 +403,9 @@ class _Test_chistogramnd_nominal(unittest.TestCase):
sample_2 = self.sample[:]
if len(sample_2.shape) == 1:
- idx = [slice(0, None)]
+ idx = (slice(0, None),)
else:
- idx = [slice(0, None), self.tested_dim]
+ idx = slice(0, None), self.tested_dim
sample_2[idx] += 2
@@ -443,9 +444,9 @@ class _Test_chistogramnd_nominal(unittest.TestCase):
sample_2 = self.sample[:]
if len(sample_2.shape) == 1:
- idx = [slice(0, None)]
+ idx = (slice(0, None),)
else:
- idx = [slice(0, None), self.tested_dim]
+ idx = slice(0, None), self.tested_dim
sample_2[idx] += 2
@@ -787,9 +788,9 @@ class _Test_Histogramnd_nominal(unittest.TestCase):
sample_2 = self.sample[:]
if len(sample_2.shape) == 1:
- idx = [slice(0, None)]
+ idx = (slice(0, None),)
else:
- idx = [slice(0, None), self.tested_dim]
+ idx = slice(0, None), self.tested_dim
sample_2[idx] += 2
@@ -824,9 +825,9 @@ class _Test_Histogramnd_nominal(unittest.TestCase):
sample_2 = self.sample[:]
if len(sample_2.shape) == 1:
- idx = [slice(0, None)]
+ idx = (slice(0, None),)
else:
- idx = [slice(0, None), self.tested_dim]
+ idx = slice(0, None), self.tested_dim
sample_2[idx] += 2
@@ -863,9 +864,9 @@ class _Test_Histogramnd_nominal(unittest.TestCase):
sample_2 = self.sample[:]
if len(sample_2.shape) == 1:
- idx = [slice(0, None)]
+ idx = (slice(0, None),)
else:
- idx = [slice(0, None), self.tested_dim]
+ idx = slice(0, None), self.tested_dim
sample_2[idx] += 2