functions.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:seniority_list 作者: rubydatasystems 项目源码 文件源码
def make_delayed_job_counts(imp_month,
                            delayed_jnums,
                            lower,
                            upper):
    '''Make an array of job counts to be inserted into the long_form job counts
    array of the job assignment function.  The main assignment function calls
    this function prior to the implementation month. The array output of this
    function is inserted into what will become the job count column.
    These jobs are from the standalone job results.
    The job count column displays a total monthly count of the job in the
    corresponding jnum (job number) column.
    inputs
        imp_month (integer)
            implementation month, defined by settings dictionary
        delayed_jnums (numpy array)
            array of job numbers, normally data from the start of the model
            through the implementation month
        lower (numpy array)
            array of indexes marking the beginning of data for each month
            within a larger array of stacked, multi-month data
        upper (numpy array)
            array of indexes marking the end of data for each month
    '''
    imp_high = upper[imp_month]
    stand_job_counts = np.zeros(imp_high)
    job_numbers = sorted(list(set(delayed_jnums[:imp_high])))

    for month in range(imp_month + 1):
        low = lower[month]
        high = upper[month]
        jnums_range = delayed_jnums[low:high]
        stand_range = stand_job_counts[low:high]

        for job in job_numbers:
            job_indexes = np.where(jnums_range == job)[0]
            np.put(stand_range,
                   job_indexes,
                   job_indexes.size)

    return stand_job_counts


# MAKE GAIN_LOSS_TABLE
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号