Exemplo n.º 1
0
def calc(msg):
    text = (re.findall(r'(\-*\w+\.*\w*)(?:\s+)*', msg.text))
    cmd = (text.pop(0))
    if len(text) == 0:
        send_mess = 'Чтобы воспользоваться коммандой {0} укажите после нее набор чисел'.format(
            cmd)
        bot.send_message(msg.chat.id, send_mess)
    else:
        if True not in (list(map(str.isalpha, text))):
            d = list(map(float, text))
            if cmd == 'median':
                bot.send_message(msg.chat.id,
                                 "Медиана: {0}".format(str(mymath.median(d))))
            if cmd == 'mean':
                bot.send_message(
                    msg.chat.id,
                    "Среднее значение: {0}".format(str(mymath.mean(d))))
            if cmd == 'sko':
                bot.send_message(msg.chat.id,
                                 "СКО: {0}".format(str(mymath.sko(d))))
            if cmd == 'cv':
                bot.send_message(msg.chat.id,
                                 "CV: {0} %".format(str(mymath.cv(d))))
            if cmd == 'sum':
                bot.send_message(msg.chat.id, "Сумма: {0}".format(str(sum(d))))
Exemplo n.º 2
0
    def testMean(self):  # - - - - - - - - - - - - - - - - - - - - - - - - - - -
        """Test 'mean' routine"""

        for i in self.vectors:

            m = mymath.mean(i[0])

            assert isinstance(m, float), 'Value returned from "mean" is not a float: ' + str(m)

            assert m == i[1], 'Wrong "mean" with data: ' + str(i[0]) + " (should be: " + str(i[1]) + "): " + str(m)
Exemplo n.º 3
0
def any_text(msg):
    cmd = (re.findall(r'(\-*\w+\.*\w*)(?:\s+)*', msg.text))
    if True not in (list(map(str.isalpha, cmd))):
        d = list(map(float, cmd))
        bot.send_message(msg.chat.id, 'N : {0}'.format(str(len(d))))
        bot.send_message(msg.chat.id,
                         'Среднее значение: {0}'.format(str(mymath.mean(d))))
        bot.send_message(msg.chat.id, 'СКО: {0}'.format(str(mymath.sko(d))))
        bot.send_message(
            msg.chat.id,
            "Коэффициент вариации: {0} %".format(str(mymath.cv(d))))
        bot.send_message(msg.chat.id,
                         "Медиана: {0}".format(str(mymath.median(d))))
Exemplo n.º 4
0
    def testMean(
            self):  # - - - - - - - - - - - - - - - - - - - - - - - - - - -
        """Test 'mean' routine"""

        for i in self.vectors:

            m = mymath.mean(i[0])

            assert (isinstance(m,float)), \
                   'Value returned from "mean" is not a float: '+str(m)

            assert m == i[1], \
                   'Wrong "mean" with data: '+str(i[0])+' (should be: '+str(i[1])+ \
                   '): '+str(m)
Exemplo n.º 5
0
def ss_curve_pos():
    global s, e, properties
    if 'filetosave' in request.files:
        print('File is come!')
        for file in request.files:
            f = request.files[file]
            extension = re.findall(r'(?:\w+.)(\w+)', f.filename)[0]
            if f and mkxlsx.allowed_file(extension):
                f.save(
                    os.path.join(app.config['UPLOAD_FOLDER'],
                                 'upload.' + extension))
                if extension == 'xlsx':
                    try:
                        s, e = readxlsx.mk_df(UPLOAD_FOLDER + 'upload.xlsx')
                    except:
                        return json.dumps({'key': 'no_data'})
                    for key in s.keys():
                        properties[key] = mymath.s_s_prop(
                            e[key], s[key], 100, 200)
                    print(properties.keys())
        return json.dumps({'properties': properties, 'status': 'uploaded'})
    elif request.form['key'] == 'request_data':
        properties[request.form['sample']] = mymath.s_s_prop(
            e[request.form['sample']], s[request.form['sample']],
            int(request.form['begin']), int(request.form['end']))
        stress = readxlsx.less_lenght(s[request.form['sample']], 100)
        strain = readxlsx.less_lenght(e[request.form['sample']], 100)
        stress_reg = np.linspace(0, max(stress) * 1.1, 10)
        strain_reg = ((stress_reg - properties[request.form['sample']]['intercept']) \
                      / properties[request.form['sample']]['slope'])
        strain_reg = list(strain_reg)
        stress_reg = list(stress_reg)

        return json.dumps({
            'properties': properties,
            'strain': strain,
            'stress': stress,
            'strain_reg': strain_reg,
            'stress_reg': stress_reg,
            'key': 'data'
        })
    elif request.form['key'] == 'reload_data':
        for sample in s.keys():
            properties[sample] = mymath.s_s_prop(e[sample], s[sample],
                                                 int(request.form['begin']),
                                                 int(request.form['end']))
        return json.dumps({'properties': properties, 'key': 'properties'})
    elif request.form['key'] == 'stats':
        stats = {}
        props = {}
        for sample in properties.keys():
            for p in properties[sample]:
                if p in props.keys():
                    props[p].append(properties[sample][p])
                else:
                    props[p] = []
                    props[p].append(properties[sample][p])
        for prop in [
                'ultimate', 'modulus', 'proportional', 'yield', 'extension'
        ]:
            stats[prop] = {}
            stats[prop]['Макс'] = mymath.round_step(max(props[prop]), 0.1)
            stats[prop]['Мин'] = mymath.round_step(min(props[prop]), 0.1)
            stats[prop]['Сред.'] = mymath.round_step(mymath.mean(props[prop]),
                                                     0.1)
            stats[prop]['СКО'] = mymath.round_step(mymath.sko(props[prop]),
                                                   0.1)
            stats[prop]['CV, %'] = mymath.round_step(mymath.cv(props[prop]),
                                                     0.1)
        return json.dumps({'stats': stats, 'key': 'stats'})
Exemplo n.º 6
0
    file = open('maria.txt', 'r')
except FileNotFoundError:
    print('file not found!')
else:
    s = file.read()
    file.close()

#
from mymath import arithmetic

arithmetic.add(1, 3)

import mymath

mymath.add(1, 3)
mymath.mean([1, 2, 3, 4, 5])

from mymath import pi

pi

#
joinstr_list = ['^(N_)?(\(주\)|주식회사|\(?주\)한무쇼핑|주\)|한무쇼핑\(주\))?(.*)(매장|-)', \
                '^(N_)?(\(주\)|주식회사|\(?주\)한무쇼핑|주\)|한무쇼핑\(주\))?(.*)']

id_list = ['로라메르시에', '엘리자베스아덴', '르라보', '킬리안', '하이코스', '비디비치', \
           '숨', '산타마리아노벨라', '오리진스', '라메르', '달팡', '그라운드플랜', '데코르테', \
           '동인비', '톰포드뷰티', '에르메스퍼퓸', '라페르바', '불리1803', '끌레드뽀보떼', 'RMK', '구딸파리', \
           '시슬리화장품', '지방시뷰티', '라프레리']

complete_str_list = []