# Path: deepcpg/utils.py
# def filter_regex(values, regexs):
#     """Filters list of `values` by list of `regexs`.
# 
#     Paramters
#     ---------
#     values: list
#         list of `str` values.
#     regexs: list
#         list of `str` regexs.
# 
#     Returns
#     -------
#     list
#         Sorted `list` of values in `values` that match any regex in `regexs`.
#     """
#     if not isinstance(values, list):
#         values = [values]
#     if not isinstance(regexs, list):
#         regexs = [regexs]
#     filtered = set()
#     for value in values:
#         for regex in regexs:
#             if re.search(regex, value):
#                 filtered.add(value)
#     return sorted(list(filtered))
# 
# def to_list(value):
#     """Convert `value` to a list."""
#     if not isinstance(value, list) and value is not None:
#         value = [value]
#     return value


import re
import h5py as h5
import numpy as np
import six
from six.moves import range
from ..utils import filter_regex, to_list
    from .utils import stack_dict


def hnames_to_names(hnames):
    """Flattens `dict` `hnames` of hierarchical names.

    Converts hierarchical `dict`, e.g. hnames={'a': ['a1', 'a2'], 'b'}, to flat
    list of keys for accessing HDF5 file, e.g. ['a/a1', 'a/a2', 'b']
    """
    names = []
    for key, value in six.iteritems(hnames):
        if isinstance(value, dict):
            for name in hnames_to_names(value):
                names.append('%s/%s' % (key, name))
        elif isinstance(value, list):
            for name in value:
                names.append('%s/%s' % (key, name))
        elif isinstance(value, str):
            names.append('%s/%s' % (key, value))
        else:
            names.append(key)
    return names


def reader(data_files, names, batch_size=128, nb_sample=None, shuffle=False,
           loop=False):
    if isinstance(names, dict):
        names = hnames_to_names(names)
    else:
        names = to_list(names)
    # Copy, since list will be changed if shuffle=True

# Path: deepcpg/utils.py
# def filter_regex(values, regexs):
#     """Filters list of `values` by list of `regexs`.
# 
#     Paramters
#     ---------
#     values: list
#         list of `str` values.
#     regexs: list
#         list of `str` regexs.
# 
#     Returns
#     -------
#     list
#         Sorted `list` of values in `values` that match any regex in `regexs`.
#     """
#     if not isinstance(values, list):
#         values = [values]
#     if not isinstance(regexs, list):
#         regexs = [regexs]
#     filtered = set()
#     for value in values:
#         for regex in regexs:
#             if re.search(regex, value):
#                 filtered.add(value)
#     return sorted(list(filtered))
# 
# def to_list(value):
#     """Convert `value` to a list."""
#     if not isinstance(value, list) and value is not None:
#         value = [value]
#     return value


# Path: deepcpg/data/hdf.py
import re
import h5py as h5
import numpy as np
import six
from six.moves import range
from ..utils import filter_regex, to_list
    from .utils import stack_dict



def hnames_to_names(hnames):
    """Flattens `dict` `hnames` of hierarchical names.

    Converts hierarchical `dict`, e.g. hnames={'a': ['a1', 'a2'], 'b'}, to flat
    list of keys for accessing HDF5 file, e.g. ['a/a1', 'a/a2', 'b']
    """
    names = []
    for key, value in six.iteritems(hnames):
        if isinstance(value, dict):
            for name in hnames_to_names(value):
                names.append('%s/%s' % (key, name))
        elif isinstance(value, list):
            for name in value:
                names.append('%s/%s' % (key, name))
        elif isinstance(value, str):
            names.append('%s/%s' % (key, value))
        else:
            names.append(key)
    return names


def reader(data_files, names, batch_size=128, nb_sample=None, shuffle=False,
           loop=False):
    if isinstance(names, dict):
        names = hnames_to_names(names)
    else:
        names = to_list(names)
    # Copy, since list will be changed if shuffle=True

    data_files = list(to_list(data_files))