From eb33972e9525971a22142637afd376b183ef7c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Sun, 17 Jul 2016 12:18:00 +0200 Subject: [PATCH] DOC: add a note on warning treatment --- doc/source/user_guide/data_types.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/source/user_guide/data_types.rst b/doc/source/user_guide/data_types.rst index 640e845f..a381c037 100644 --- a/doc/source/user_guide/data_types.rst +++ b/doc/source/user_guide/data_types.rst @@ -73,6 +73,14 @@ issued:: float64 to uint8 array([ 0, 128, 255], dtype=uint8) +Warnings can be locally ignored with a context manager:: + + >>> import warnings + >>> image = np.array([0, 0.5, 1], dtype=float) + >>> with warnings.catch_warnings(): + ... warnings.simplefilter("ignore") + ... img_as_ubyte(image) + array([ 0, 128, 255], dtype=uint8) Additionally, some functions take a ``preserve_range`` argument where a range conversion is convenient but not necessary. For example, interpolation in