# Path: fluids/units.py
# def kwargs_to_args(args, kwargs, signature):
#     '''Accepts an *args and **kwargs and a signature
#     like ['rho', 'mu', 'nu'] which is an ordered list of
#     all accepted arguments.
# 
#     Returns a list containing all the arguments, sorted, and
#     left as None if not specified
#     '''
#     argument_number = len(signature)
#     arg_number = len(args)
#     output = list(args)
#     # Extend the list and initialize as None by default
#     output.extend([None]*(argument_number - arg_number))
#     for i in range(arg_number, argument_number):
#         if signature[i] in kwargs:
#             output[i] = kwargs[signature[i]]
#     return output


import types
import numpy as np
import pytest
import fluids
    import copy
from fluids.numerics import assert_close, assert_close1d, assert_close2d
from fluids.units import *
from fluids.units import kwargs_to_args
    from fluids.units import convert_input
    from fluids.units import check_args_order
    assert_close(D.to_base_units().magnitude, 7.829454643649386)
    assert dict(D.dimensionality) == {u'[length]': 1.0}

    Bo = Bond(1000*u.kg/u.m**3, 1.2*u.kg/u.m**3, .0589*u.N/u.m, 2*u.m)
    assert_close(Bo.to_base_units().magnitude, 665187.2339558573)
    assert dict(Bo.dimensionality) == {}

    head = head_from_P(P=98066.5*u.Pa, rho=1000*u.kg/u.m**3)
    assert_close(head.to_base_units().magnitude, 10.000000000000002)
    assert dict(head.dimensionality) == {u'[length]': 1.0}

    roughness = roughness_Farshad('Cr13, bare', 0.05*u.m)
    assert_close(roughness.to_base_units().magnitude, 5.3141677781137006e-05)
    assert dict(roughness.dimensionality) == {u'[length]': 1.0}



def test_custom_wraps():
    A = A_multiple_hole_cylinder(0.01*u.m, 0.1*u.m, [(0.005*u.m, 1)])
    assert_close(A.to_base_units().magnitude, 0.004830198704894308)
    assert dict(A.dimensionality) == {u'[length]': 2.0}

    V = V_multiple_hole_cylinder(0.01*u.m, 0.1*u.m, [(0.005*u.m, 1)])
    assert_close(V.to_base_units().magnitude, 5.890486225480862e-06)
    assert dict(V.dimensionality) == {u'[length]': 3.0}

    # custom compressible flow model wrappers
    functions = [Panhandle_A, Panhandle_B, Weymouth, Spitzglass_high, Oliphant, Fritzsche]
    values = [42.56082051195928, 42.35366178004172, 32.07729055913029, 29.42670246281681, 28.851535408143057, 39.421535157535565]
    for f, v in zip(functions, values):

# Path: fluids/units.py
# def kwargs_to_args(args, kwargs, signature):
#     '''Accepts an *args and **kwargs and a signature
#     like ['rho', 'mu', 'nu'] which is an ordered list of
#     all accepted arguments.
# 
#     Returns a list containing all the arguments, sorted, and
#     left as None if not specified
#     '''
#     argument_number = len(signature)
#     arg_number = len(args)
#     output = list(args)
#     # Extend the list and initialize as None by default
#     output.extend([None]*(argument_number - arg_number))
#     for i in range(arg_number, argument_number):
#         if signature[i] in kwargs:
#             output[i] = kwargs[signature[i]]
#     return output


# Path: tests/test_units.py
import types
import numpy as np
import pytest
import fluids
    import copy
from fluids.numerics import assert_close, assert_close1d, assert_close2d
from fluids.units import *
from fluids.units import kwargs_to_args
    from fluids.units import convert_input
    from fluids.units import check_args_order

    assert_close(D.to_base_units().magnitude, 7.829454643649386)
    assert dict(D.dimensionality) == {u'[length]': 1.0}

    Bo = Bond(1000*u.kg/u.m**3, 1.2*u.kg/u.m**3, .0589*u.N/u.m, 2*u.m)
    assert_close(Bo.to_base_units().magnitude, 665187.2339558573)
    assert dict(Bo.dimensionality) == {}

    head = head_from_P(P=98066.5*u.Pa, rho=1000*u.kg/u.m**3)
    assert_close(head.to_base_units().magnitude, 10.000000000000002)
    assert dict(head.dimensionality) == {u'[length]': 1.0}

    roughness = roughness_Farshad('Cr13, bare', 0.05*u.m)
    assert_close(roughness.to_base_units().magnitude, 5.3141677781137006e-05)
    assert dict(roughness.dimensionality) == {u'[length]': 1.0}



def test_custom_wraps():
    A = A_multiple_hole_cylinder(0.01*u.m, 0.1*u.m, [(0.005*u.m, 1)])
    assert_close(A.to_base_units().magnitude, 0.004830198704894308)
    assert dict(A.dimensionality) == {u'[length]': 2.0}

    V = V_multiple_hole_cylinder(0.01*u.m, 0.1*u.m, [(0.005*u.m, 1)])
    assert_close(V.to_base_units().magnitude, 5.890486225480862e-06)
    assert dict(V.dimensionality) == {u'[length]': 3.0}

    # custom compressible flow model wrappers
    functions = [Panhandle_A, Panhandle_B, Weymouth, Spitzglass_high, Oliphant, Fritzsche]
    values = [42.56082051195928, 42.35366178004172, 32.07729055913029, 29.42670246281681, 28.851535408143057, 39.421535157535565]
    for f, v in zip(functions, values):

        ans = f(D=0.340*u.m, P1=90E5*u.Pa, P2=20E5*u.Pa, L=160E3*u.m, SG=0.693, Tavg=277.15*u.K)