class_docstr: Test environment to validate a pythran execution against python. 
class_docstr_tok: ["Test","environment","to","validate","a","pythran","execution","against","python","."]
docstr: Improved version of assertAlmostEqual.
  
  This new version supports nan, complex and ndarray.
docstr_tok: ["Improved","version","of","assertAlmostEqual",".","This","new","version","supports","nan",",","complex","and","ndarray","."]
code: def assertAlmostEqual(self, ref, res):
      """
      Improved version of assertAlmostEqual.
  
      This new version supports nan, complex and ndarray.
      """
      self.check_type(ref, res)
      if isinstance(res, (list, tuple)):
          self.assertEqual(len(res), len(ref))
          for res_v, ref_v in zip(res, ref):
              self.assertAlmostEqual(ref_v, res_v)
      elif isinstance(ref, ndarray):
          npt.assert_array_almost_equal(ref, res)
      elif isinstance(ref, float):
          if isinf(ref) or isinf(res):
              self.assertEqual(isinf(ref), isinf(res))
              self.assertEqual(isneginf(ref), isneginf(res))
          elif isnan(ref) or isnan(res):
              self.assertEqual(isnan(ref), isnan(res))
          elif ref == res:
              pass
          else:
              # Check float equality using upl :
              # http://numscale.github.io/nstest/design_rationale.html
              (m_ref, e_ref) = math.frexp(ref)
              (m_res, e_res) = math.frexp(res)
              expo = max(e_ref, e_res)
              n_ref = math.ldexp(ref, -expo)
              n_res = math.ldexp(res, -expo)
              e = (m_ref - m_res) if e_ref == e_res else (n_ref - n_res)
              self.assertLessEqual(abs(e) / sys.float_info.epsilon, 3.0)
      elif isinstance(ref, (complex, complex64, complex128)):
          self.assertAlmostEqual(ref.real, res.real)
          self.assertAlmostEqual(ref.imag, res.imag)
      else:
          self.assertEqual(ref, res)
  
imports: import importlib
  from numpy import float32, float64, complex128
  from numpy import intp, intc, number, bool_
  from numpy import ndarray, isnan, isinf, isneginf, complex128, complex64
  from textwrap import dedent
  from threading import Thread
  import copy
  import math
  import glob
  import numpy.testing
  import os
  import numbers
  import sys
  import unittest
  from functools import reduce
  from operator import add
  import logging
  from pythran import compile_pythrancode, spec_parser, load_specfile, frontend
  from pythran.backend import Python
  from pythran.middlend import refine
  from pythran.passmanager import PassManager
  from pythran.toolchain import _parse_optimization
  from pythran.spec import Spec
label_desc: Use image node_id 2 for calling the TestEnv obj's underlying member method code with example usage: obj.assertAlmostEqual(ref, res) without return types