# Path: mimic3models/common_utils.py
# def convert_to_dict(data, header, channel_info):
# def extract_features_from_rawdata(chunk, header, period, features):
# def read_chunk(reader, chunk_size):
# def sort_and_shuffle(data, batch_size):
# def add_common_arguments(parser):
#     def __init__(self, dataset_dir, listfile=None, small_part=False):
#     def _read_timeseries(self, ts_filename):
# def create_directory(directory):
# def pad_zeros(arr, min_length=None):
# class DeepSupervisionDataLoader:


import numpy as np
import threading
import random
import os
from mimic3models import common_utils
from __future__ import absolute_import
from __future__ import print_function




class BatchGen(object):

    def __init__(self, reader, discretizer, normalizer, batch_size,
                 small_part, target_repl, shuffle, return_names=False):
        self.batch_size = batch_size
        self.target_repl = target_repl
        self.shuffle = shuffle
        self.return_names = return_names

        self._load_data(reader, discretizer, normalizer, small_part)

        self.steps = (len(self.data[0]) + batch_size - 1) // batch_size
        self.lock = threading.Lock()
        self.generator = self._generator()

    def _load_data(self, reader, discretizer, normalizer, small_part=False):
        N = reader.get_number_of_examples()
        if small_part:
            N = 1000

# Path: mimic3models/common_utils.py
# def convert_to_dict(data, header, channel_info):
# def extract_features_from_rawdata(chunk, header, period, features):
# def read_chunk(reader, chunk_size):
# def sort_and_shuffle(data, batch_size):
# def add_common_arguments(parser):
#     def __init__(self, dataset_dir, listfile=None, small_part=False):
#     def _read_timeseries(self, ts_filename):
# def create_directory(directory):
# def pad_zeros(arr, min_length=None):
# class DeepSupervisionDataLoader:


# Path: mimic3models/phenotyping/utils.py
import numpy as np
import threading
import random
import os
from mimic3models import common_utils

from __future__ import absolute_import
from __future__ import print_function




class BatchGen(object):

    def __init__(self, reader, discretizer, normalizer, batch_size,
                 small_part, target_repl, shuffle, return_names=False):
        self.batch_size = batch_size
        self.target_repl = target_repl
        self.shuffle = shuffle
        self.return_names = return_names

        self._load_data(reader, discretizer, normalizer, small_part)

        self.steps = (len(self.data[0]) + batch_size - 1) // batch_size
        self.lock = threading.Lock()
        self.generator = self._generator()

    def _load_data(self, reader, discretizer, normalizer, small_part=False):
        N = reader.get_number_of_examples()
        if small_part:
            N = 1000

        ret = common_utils.read_chunk(reader, N)