@pytest.mark.skipif(u'not HAS_SCIPY')
def test_z_at_value_roundtrip():
 z = 0.5
 skip = (u'Ok', u'angular_diameter_distance_z1z2', u'clone', u'de_density_scale', u'w')
 import inspect
 methods = inspect.getmembers(core.Planck13, predicate=inspect.ismethod)
 for (name, func) in methods:
  if (name.startswith(u'_') or (name in skip)):
   continue
  print(u'Round-trip testing {0}'.format(name))
  fval = func(z)
  assert allclose(z, funcs.z_at_value(func, fval, zmax=1.5), rtol=2e-08)
 z2 = 2.0
 func_z1z2 = [(lambda z1: core.Planck13._comoving_distance_z1z2(z1, z2)), (lambda z1: core.Planck13._comoving_transverse_distance_z1z2(z1, z2)), (lambda z1: core.Planck13.angular_diameter_distance_z1z2(z1, z2))]
 for func in func_z1z2:
  fval = func(z)
  assert allclose(z, funcs.z_at_value(func, fval, zmax=1.5), rtol=2e-08)

@ pytest . mark . skipif ( u'not HAS_SCIPY' ) def test_z_at_value_roundtrip ( ) : z = 0.5 skip = ( u'Ok' , u'angular_diameter_distance_z1z2' , u'clone' , u'de_density_scale' , u'w' ) import inspect methods = inspect . getmembers ( core . Planck13 , predicate = inspect . ismethod ) for ( name , func ) in methods : if ( name . startswith ( u'_' ) or ( name in skip ) ) : continue print ( u'Round-trip testing {0}' . format ( name ) ) fval = func ( z ) assert allclose ( z , funcs . z_at_value ( func , fval , zmax = 1.5 ) , rtol = 2e-08 ) z2 = 2.0 func_z1z2 = [ ( lambda z1 : core . Planck13 . _comoving_distance_z1z2 ( z1 , z2 ) ) , ( lambda z1 : core . Planck13 . _comoving_transverse_distance_z1z2 ( z1 , z2 ) ) , ( lambda z1 : core . Planck13 . angular_diameter_distance_z1z2 ( z1 , z2 ) ) ] for func in func_z1z2 : fval = func ( z ) assert allclose ( z , funcs . z_at_value ( func , fval , zmax = 1.5 ) , rtol = 2e-08 )
calculate values from a known redshift .