# Path: bmlingam/utils/extract_const.py
# def extract_const(sample_coef, var_name):
#     """Extract float constants from string. 
#     """
#     if sample_coef.startswith(var_name + '='):
#         return float(sample_coef[len(var_name + '='):])
#     else:
#         raise ValueError(("Invalid variable name: %s\n" % var_name))
# 
#     # r = re.compile('%s=(-|)([1-9]\d*|0)(\.\d+)?$' % var_name)
#     # m = r.search(sample_coeff)
#     # if m is not None:
#     #     return float(''.join(m.groups()))
#     # else:
#     #     return None


from nose.tools import *
from bmlingam.utils import extract_const

# -*- coding: utf-8 -*-

# Author: Taku Yoshioka
# License: MIT



def test_extract_const():
    var1 = extract_const('var1=10.0', 'var1')
    assert(var1 == 10.0)

@raises(ValueError)
def test_extract_const2():

# Path: bmlingam/utils/extract_const.py
# def extract_const(sample_coef, var_name):
#     """Extract float constants from string. 
#     """
#     if sample_coef.startswith(var_name + '='):
#         return float(sample_coef[len(var_name + '='):])
#     else:
#         raise ValueError(("Invalid variable name: %s\n" % var_name))
# 
#     # r = re.compile('%s=(-|)([1-9]\d*|0)(\.\d+)?$' % var_name)
#     # m = r.search(sample_coeff)
#     # if m is not None:
#     #     return float(''.join(m.groups()))
#     # else:
#     #     return None


# Path: bmlingam/tests/test_utils.py
from nose.tools import *
from bmlingam.utils import extract_const

# -*- coding: utf-8 -*-

# Author: Taku Yoshioka
# License: MIT



def test_extract_const():
    var1 = extract_const('var1=10.0', 'var1')
    assert(var1 == 10.0)

@raises(ValueError)
def test_extract_const2():

    extract_const('var2=12.0', 'var1')
