2 Star 0 Fork 0

陌路微尘/CustomDataProcess

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
utils.py 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
陌路微尘 提交于 2022-09-03 18:21 +08:00 . 字典递归转换为对象
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
"""
@version: 0.1
@author: 张宇洁
@contact: a_ff1984@163.com
@site: https://gitee.com/moluweichen
@software: PyCharm
@file: utils.py
@time: 2021/11/6 13:11
"""
import numpy as np
from configuration import configuration
def is_int(value):
if not isinstance(value, (np.int64, np.int32, np.int16, np.int8, np.int0)):
raise TypeError("argument expected int but got %s" % type(value).__name__)
def anliquates(pcs, weight, price, tax_rate):
"""
获取整除数列表
:param pcs:
:param weight:
:return:
"""
is_int(pcs)
is_int(weight)
top_value = pcs // weight
final_rest_list = list()
while 1:
if top_value <= 1:
break
if pcs % top_value == 0:
final_rest_list.append(top_value)
top_value -= 1
if len(final_rest_list) == 0:
return None
return quantile(final_rest_list, pcs, price, tax_rate)
def quantile(anli_list, pcs, price, tax_rate):
"""
取相应的分位整数
:param anli_list:
:return:
"""
anli_list_length = len(anli_list)
if anli_list_length == 1:
return anli_list[0]
elif anli_list_length > 1:
pcs_num_real = None
for pcs_num in anli_list:
new_pcs = pcs // pcs_num
if new_pcs * price * tax_rate < configuration.config.benchmark:
pcs_num_real = pcs_num
break
if pcs_num_real is None:
pos = float(configuration.config.pos)
index = int((anli_list_length - 1) * pos)
return anli_list[index]
else:
return pcs_num_real
else:
return anli_list[0]
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/InsignificantDust/custom-data-process.git
git@gitee.com:InsignificantDust/custom-data-process.git
InsignificantDust
custom-data-process
CustomDataProcess
master

搜索帮助