# Path: anypytools/datautils.py
# def read_anyoutputfile(filepath):
#     """Read an AnyOutput file.
# 
#     Parameters
#     ----------
#     filepath : str
# 
# 
#     Returns
#     -------
#     data : array_like
#         data collumns  in the anyoutput file
#     header : list
#         list of the collumn names
#     constants : dict
#         mapping with constants found in the file
# 
# 
#     """
#     with open(filepath, "rU") as anyoutputfile:
#         constants = {}
#         reader = iter(anyoutputfile.readline, b"")
#         # Check when the header section ends
#         fpos1 = 0
#         fpos0 = 0
#         for row in reader:
#             if _is_scinum(row.split(",")[0]):
#                 break
#             # Save constant from AnyOutput file
#             const, value = _parse_anyoutputfile_constants(row)
#             if const is not None:
#                 constants[const] = value
#             fpos1, fpos0 = fpos0, anyoutputfile.tell()
#         else:
#             warnings.warn("No numeric data in " + os.path.basename(filepath))
#             return (None, None, constants)
#         # Read last line of the header section if there is a header
#         if fpos0 != 0:
#             anyoutputfile.seek(fpos1)
#             header = next(reader).strip("\n").split(",")
#         else:
#             header = None
# 
#         data = []
#         for row in reader:
#             try:
#                 data.append([float(val) for val in row.strip("\n").split(",")])
#             except ValueError:
#                 break
#         data = np.array(data)
#     return (data, header, constants)


from anypytools.datautils import read_anyoutputfile
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  3 11:03:41 2014

@author: Morten
"""


def test_open_anyoutputfile(request):
    testfile = str(request.fspath.new(basename="any_output_file.txt"))

# Path: anypytools/datautils.py
# def read_anyoutputfile(filepath):
#     """Read an AnyOutput file.
# 
#     Parameters
#     ----------
#     filepath : str
# 
# 
#     Returns
#     -------
#     data : array_like
#         data collumns  in the anyoutput file
#     header : list
#         list of the collumn names
#     constants : dict
#         mapping with constants found in the file
# 
# 
#     """
#     with open(filepath, "rU") as anyoutputfile:
#         constants = {}
#         reader = iter(anyoutputfile.readline, b"")
#         # Check when the header section ends
#         fpos1 = 0
#         fpos0 = 0
#         for row in reader:
#             if _is_scinum(row.split(",")[0]):
#                 break
#             # Save constant from AnyOutput file
#             const, value = _parse_anyoutputfile_constants(row)
#             if const is not None:
#                 constants[const] = value
#             fpos1, fpos0 = fpos0, anyoutputfile.tell()
#         else:
#             warnings.warn("No numeric data in " + os.path.basename(filepath))
#             return (None, None, constants)
#         # Read last line of the header section if there is a header
#         if fpos0 != 0:
#             anyoutputfile.seek(fpos1)
#             header = next(reader).strip("\n").split(",")
#         else:
#             header = None
# 
#         data = []
#         for row in reader:
#             try:
#                 data.append([float(val) for val in row.strip("\n").split(",")])
#             except ValueError:
#                 break
#         data = np.array(data)
#     return (data, header, constants)


# Path: tests/test_datautils.py
from anypytools.datautils import read_anyoutputfile

# -*- coding: utf-8 -*-
"""
Created on Wed Sep  3 11:03:41 2014

@author: Morten
"""


def test_open_anyoutputfile(request):
    testfile = str(request.fspath.new(basename="any_output_file.txt"))

    data, header, constants = read_anyoutputfile(testfile)