Esempio n. 1
0
    def record_details(self):
        tline = self.testline
        i0 = 5 + tline.index('find(')
        tline = tline[i0:-1]
        checks = tline.split('|')
        parts = []
        for check in checks:
            check = check.strip()
            if check.startswith('('):
                check = check[1:-1].strip()
            part = Bunch(check=check)
            LHS, RHS = check.split('>=')
            part.tolerance = eval(RHS)
            LHS = LHS.strip()[4:-1]  # chop off abs(...)
            target, calculated = LHS.split('-')
            part.checkval = eval(target)
            part.val = eval(calculated)
            parts.append(part)

        self.details = parts
Esempio n. 2
0
    def record_details(self):
        tline = self.testline
        i0 = 5 + tline.index('find(')
        tline = tline[i0:-1]
        checks = tline.split('|')
        parts = []
        for check in checks:
            check = check.strip()
            if check.startswith('('):
                check = check[1:-1].strip()
            part = Bunch(check=check)
            LHS, RHS = check.split('>=')
            part.tolerance = eval(RHS)
            LHS = LHS.strip()[4:-1]  # chop off abs(...)
            target, calculated = LHS.split('-')
            part.checkval = eval(target)
            part.val = eval(calculated)
            parts.append(part)

        self.details = parts
Esempio n. 3
0
# Bjørn Ådlandsvik <*****@*****.**>
# 2011-03-03

import os
import unittest
import functools  # Requires python 2.5.
import numpy as np

import gsw
from gsw.utilities import Bunch


# Read data file with check value profiles.
datadir = os.path.join(os.path.dirname(gsw.utilities.__file__), 'data')
cv = Bunch(np.load(os.path.join(datadir, 'gsw_cv_v3_0.npz')))
cf = Bunch(np.load(os.path.join(datadir, 'gsw_cf.npz')))

# Main dictionary of functions with arguments. Could perhaps be auto-generated.
function_arguments = dict(
    # absolute_salinity_sstar_ct.py
    SA_from_SP=('SP', 'p', 'long', 'lat'),  # uses SAAR
    # Sstar_from_SP  TODO
    CT_from_t=('SA', 't', 'p'),
    #
    # thermodynamics_from_t.py
    rho_t_exact=('SA', 't', 'p'),
    pot_rho_t_exact=('SA', 't', 'p', 'pr'),
    sigma0_pt0_exact=('SA', 'pt0'),
    alpha_wrt_CT_t_exact=('SA', 't', 'p'),
    alpha_wrt_pt_t_exact=('SA', 't', 'p'),
Esempio n. 4
0
                        dest='mfiledir',
                        default="gsw_matlab_v3_04",
                        help='location of gsw_check_functions.m')
    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        help='print output mismatch arrays')
    parser.add_argument('--find', help='run functions with this substring')

    args = parser.parse_args()

    mfile = os.path.join(args.mfiledir, "gsw_check_functions.m")
    checks = parse_check_functions(mfile)

    datadir = os.path.join(os.path.dirname(gsw.utilities.__file__), 'data')
    cv = Bunch(np.load(os.path.join(datadir, 'gsw_cv_v3_0.npz')))
    cf = Bunch()

    if args.find:
        checks = [c for c in checks if args.find in c.runline]

    for fc in checks:
        fc.run()

    passes = [f for f in checks if f.passed]
    failures = [f for f in checks if f.passed is False]

    run_problems = [f for f in checks if f.exception is not None]

    etypes = [NameError, UnboundLocalError, TypeError, AttributeError]
    ex_dict = dict()
Esempio n. 5
0
from __future__ import print_function

import os
import sys
import unittest
import functools
import numpy as np

import gsw
from gsw.utilities import Bunch

# Read data file with check value profiles
datadir = os.path.join(os.path.dirname(gsw.utilities.__file__), 'data')
fname = 'gsw_cv_v3_0.npz'
cv = Bunch(np.load(os.path.join(datadir, fname)))
cf = Bunch(np.load(os.path.join(datadir, 'gsw_cf.npz')))

# derivatives.py
#CT_first_derivatives=('SA', 'pt'),  # NOTE: TI, BUG
#CT_second_derivatives=('SA', 'pt'),  # NOTE: TI FIXME BUG
#enthalpy_first_derivatives=('SA', 'CT', 'p'), FIXME name match
#enthalpy_second_derivatives=('SA', 'CT', 'p'), FIXME name match
#entropy_first_derivatives=('SA', 'CT'),  #NOTE: TI FIXME name match
#entropy_second_derivatives=('SA', 'pt'),  #NOTE: TI FIXME name match
#pt_first_derivatives':,  #NOTE: TI FIXME name match
#pt_second_derivatives= #NOTE: TI FIXME name match

# Make aliases for some values to be used as arguments
cv.entropy_chck_cast = cv.entropy_from_CT
cv.Abs_Pressure_from_p_chck_cast = cv.Abs_Pressure_from_p