def test_getMatplotlibVersion(self): """ Tests for the getMatplotlibVersion() function as it continues to cause problems. """ original_version = matplotlib.__version__ matplotlib.__version__ = "1.2.3" version = getMatplotlibVersion() self.assertEqual(version, [1, 2, 3]) matplotlib.__version__ = "0.9.11" version = getMatplotlibVersion() self.assertEqual(version, [0, 9, 11]) matplotlib.__version__ = "0.9.svn" version = getMatplotlibVersion() self.assertEqual(version, [0, 9, 0]) matplotlib.__version__ = "1.1.1~rc1-1" version = getMatplotlibVersion() self.assertEqual(version, [1, 1, 1]) matplotlib.__version__ = "1.2.x" version = getMatplotlibVersion() self.assertEqual(version, [1, 2, 0]) # Set it to the original version str just in case. matplotlib.__version__ = original_version
def test_getMatplotlibVersion(self): """ Tests for the getMatplotlibVersion() function as it continues to cause problems. """ original_version = matplotlib.__version__ matplotlib.__version__ = "1.2.3" version = getMatplotlibVersion() self.assertEqual(version, [1, 2, 3]) matplotlib.__version__ = "0.9.11" version = getMatplotlibVersion() self.assertEqual(version, [0, 9, 11]) matplotlib.__version__ = "0.9.svn" version = getMatplotlibVersion() self.assertEqual(version, [0, 9, 0]) matplotlib.__version__ = "1.1.1~rc1-1" version = getMatplotlibVersion() self.assertEqual(version, [1, 1, 1]) matplotlib.__version__ = "1.2.x" version = getMatplotlibVersion() self.assertEqual(version, [1, 2, 0]) # Set it to the original version str just in case. matplotlib.__version__ = original_version
def get_matplotlib_defaul_tolerance(): """ The two test images ("ok", "fail") result in the following rms values: matplotlib v1.3.x (git rev. 26b18e2): 0.8 and 9.0 matplotlib v1.2.1: 1.7e-3 and 3.6e-3 """ if getMatplotlibVersion() < [1, 3, 0]: return 2e-3 else: return 1
def get_matplotlib_defaul_tolerance(): """ The two test images ("ok", "fail") result in the following rms values: matplotlib v1.3.x (git rev. 26b18e2): 0.8 and 9.0 matplotlib v1.2.1: 1.7e-3 and 3.6e-3 """ if getMatplotlibVersion() < [1, 3, 0]: return 2e-3 else: return 1
def get_matplotlib_defaul_tolerance(): """ The two test images ("ok", "fail") result in the following rms values: matplotlib v1.3.x (git rev. 26b18e2): 0.8 and 9.0 matplotlib v1.2.1: 1.7e-3 and 3.6e-3 """ # Baseline images are created with 1.3.1, # be very generous when testing other matplotlib versions. if getMatplotlibVersion() == [1, 3, 1]: return 2 else: return 20
def checkForMatplotlibCompareImages(): try: # trying to stay inside 80 char line import matplotlib.testing.compare as _compare compare_images = _compare.compare_images # NOQA except: return False # matplotlib's (< 1.2) compare_images() uses PIL internally if getMatplotlibVersion() < [1, 2, 0]: try: import PIL # NOQA except ImportError: return False return True
def checkForMatplotlibCompareImages(): try: # trying to stay inside 80 char line import matplotlib.testing.compare as _compare compare_images = _compare.compare_images # NOQA @UnusedVariable except: return False # matplotlib's (< 1.2) compare_images() uses PIL internally if getMatplotlibVersion() < [1, 2, 0]: try: import PIL # NOQA @UnusedImport except ImportError: return False return True
from __future__ import (absolute_import, division, print_function, unicode_literals) from future.builtins import * # NOQA from obspy import UTCDateTime, Stream, Trace from obspy.core.util.base import getMatplotlibVersion from obspy.core.util.testing import ImageComparison, HAS_COMPARE_IMAGE from obspy.core.util.decorator import skipIf from obspy.imaging import spectrogram import numpy as np import os import unittest import warnings MATPLOTLIB_VERSION = getMatplotlibVersion() class SpectrogramTestCase(unittest.TestCase): """ Test cases for spectrogram plotting. """ def setUp(self): # directory where the test files are located self.path = os.path.join(os.path.dirname(__file__), 'images') @skipIf(not HAS_COMPARE_IMAGE, 'nose not installed or matplotlib too old') def test_spectrogram(self): """ Create spectrogram plotting examples in tests/output directory. """