import math


def _split_data(age_pic, train_size, threshed=5):
    """
    age_pic: {bone_age : [pic_id, ], ...}
    train_size: range(0, 1)

    return :
        ret_train: [pic_id, ]
        ret_validation: [pic_id, ]
    """
    ret_train, ret_validation = [], []
    for k,v in age_pic.items():
        age_count = len(v)
        if int(math.floor(age_count * train_size)) < threshed:
            split = 0
        else:
            split = int(math.floor(age_count * (1- train_size)))    # 每个年龄的图片向下取整，所以图片并没有按照给定比例严格划分
        ret_validation.extend(v[:split])
        ret_train.extend(v[split:])

    return ret_train, ret_validation