def __init__(self, add_tomorrow): super().__init__() self.path = None self.columns = [] self.v = Values() self.t = Tasks() self.l = Locks() self.ts = TimeSheet() self.table = self.compare_goal_actual(add_tomorrow)
def test_median(self): values = Values([1, 10, 1]) self.assertEqual(1, values.median()) # Returns the average of the two middle values when len(values()) is even. values.add(20) self.assertEqual(5.5, values.median()) values.add(20) self.assertEqual(10, values.median())
def setup_teardown_method(driver): locale.setlocale(locale.LC_ALL, '') self.driver = driver self.logging = logging.basicConfig(filename='exersice1.log', filemode='w') value_end_point = EndPoints.get("base_end_point") + EndPoints.get( "values_end_point") driver.get(value_end_point) self.values_obj = Values(driver, logging) slef.lable_text_dict = self.values.dict_lable_text() yield driver.close()
def test_add(self): values = Values() self.assertEqual([], values.values()) values.add(4.2) values.add(2.3) self.assertEqual([4.2, 2.3], values.values())
def __init__(self): self.values = Values(50, None, None, 8192) self.Values = { 'CurrentValue': self.values.CurrentValue, 'DefaultValue': self.values.DefaultValue } self.ExposureAuto = { 'Value': self.Values, 'Category': 'ByDefault', 'Group': 'GrupoBrightness' }
def __init__(self): self.values = Values(10, 0, 256, -8193) self.Values = { 'CurrentValue': self.values.CurrentValue, 'MinValue': self.values.MinValue, 'MaxValue': self.values.MaxValue, 'DefaultValue': self.values.DefaultValue } self.Saturation = { 'Value': self.Values, 'Category': 'ByDefault', 'Group': 'GrupoSaturation' }
def __init__(self): self.values = Values(200, 0, 359, -8193) self.Values = { 'CurrentValue': self.values.CurrentValue, 'MinValue': self.values.MinValue, 'MaxValue': self.values.MaxValue, 'DefaultValue': self.values.DefaultValue } self.Hue = { 'Value': self.Values, 'Category': 'ByDefault', 'Group': 'GrupoGain' }
def __init__(self): self.values = Values(50, 0, 100, 8192) self.Values = { 'CurrentValue': self.values.CurrentValue, 'MinValue': self.values.MinValue, 'MaxValue': self.values.MaxValue, 'DefaultValue': self.values.DefaultValue } self.Brightness = { 'Value': self.Values, 'Category': 'ByDefault', 'Group': 'GrupoBrightness' }
def __init__(self): self.values = Values(500, 260, 1023, 32768) self.Values = { 'CurrentValue': self.values.CurrentValue, 'MinValue': self.values.MinValue, 'MaxValue': self.values.MaxValue, 'DefaultValue': self.values.DefaultValue } self.Gain = { 'Value': self.Values, 'Category': 'ByDefault', 'Group': 'GrupoGain' }
def __init__(self): self.values = Values(8, 0, 95, 32) self.Values = { 'CurrentValue': self.values.CurrentValue, 'MinValue': self.values.MinValue, 'MaxValue': self.values.MaxValue, 'DefaultValue': self.values.DefaultValue } self.WhiteBalanceBlue = { 'Value': self.Values, 'Category': 'ByDefault', 'Group': 'GrupoGain' }
def __init__(self): self.values = Values(250, 1, 500, 16384) self.Values = { 'CurrentValue': self.values.CurrentValue, 'MinValue': self.values.MinValue, 'MaxValue': self.values.MaxValue, 'DefaultValue': self.values.DefaultValue } self.Gamma = { 'Value': self.Values, 'Category': 'ByDefault', 'Group': 'GrupoGamma' }
def twoSAT(link): rules = Cases(link) answer = Values(rules.size) for i in range(int(math.log(answer.n, 2))): answer.generate() for j in range(int((answer.n**2) * 2)): print(i, j) result = rules.test_all_cases(answer.values) if (result == -1): return True answer.flip(int(random.choice(rules.cases[result]))) return False
def new(args): def parse_custom_values(s): result = {} values = [v for v in s.split(',') if v] for pair in values: try: key, val = pair.split('=') result[key] = val except ValueError: print( '--values got an invalid format. Wants key=value pairs, separated by ,' ) sys.exit(1) return result name = args['<name>'] dest = args['<dir>'] or '.' values = args['--values'] or '' """Create new template. To be used by cli.py""" try: pre_main() main(name, Values(**parse_custom_values(values)), dest=dest) except KeyboardInterrupt: shutil.rmtree(os.path.join(WORKDIR, name))
def test_initialize(self): values = Values() self.assertEqual([], values.values()) values = Values([2.3, 4.2]) self.assertEqual([2.3, 4.2], values.values())
def select(self, board): values = Values(board, self.minimax, self.color) pos = choice(values.get_best_pos()) return pos
def test_stddev(self): values = Values([1, 10, 1]) self.assertAlmostEqual(4.24, values.stddev(), places=2)
def test_mean(self): values = Values([1, 10, 1]) self.assertEqual(4, values.mean())
def update_records(self): name_to_search = input("Enter name to update: ") new_ip = input("Enter new ip :") v = Values(name_to_search, new_ip) Table.change_target(self, *v.get_value())
<br> Incall only! <br> Serious & Discreet clients only <br> No blocked calls! <br> <br> <a target="_blank" href="mailto:"></a> <br> *82 <br> <br> XOXO, Tessa""" ad_data2 = """<b></b><i>My name is Dream & I am an exotic Armenian, German<br> woman, standing 5'7, 150lbs, all natural busty 36c-28-38,<br> with light blonde hair & blue eyes.<br> <br> I offer incall or outcall & I am available 24hrs a day so feel free to<br> contact me at anytime!<br> <br> <br> If for some reason I dont answer, please leave a message.<br> No blocked calls will be answered!<br> No text messages either boys!<br> <br> <u><b>Ready for pleasure<br></b></u> <br> CALL ME!!!<br> <br></i> """ v1 = Values(ad_data, path, all_names) v2 = Values(ad_data2, path, all_names) f = Features(v1, v2) print f.extract_feats(False)
def insert_records(self): name = input("Enter name: ") ip = input("Enter ip: ") v = Values(name, ip) print('Input values :', *v.get_value()) Table.insert_in_table(self, *v.get_value())
def test_pval_identical(self): identical_list = [1, 10, 1] values = Values(identical_list) self.assertEqual(0, values.pval(identical_list))
def test_pval_significant(self): values = Values([1, 1, 1, 1, 1]) self.assertAlmostEqual(0.992, values.pval([10, 10, 10, 10, 10]), places=3)
class Advice(Table): def __init__(self, add_tomorrow): super().__init__() self.path = None self.columns = [] self.v = Values() self.t = Tasks() self.l = Locks() self.ts = TimeSheet() self.table = self.compare_goal_actual(add_tomorrow) @staticmethod def _get_week(add_tomorrow): if add_tomorrow: last_date = (datetime.today() + timedelta(days=1)).date() else: last_date = datetime.today().date() first_date = last_date - timedelta(days=7) return str(first_date), str(last_date) @staticmethod def _add_deficit(actuals): actuals = actuals.copy() actuals.loc[:, 'deficit'] = (actuals.goal_min - actuals.entry).apply(lambda x: max(0, x)) return actuals @staticmethod def _add_excess(actuals): actuals = actuals.copy() actuals.loc[:, 'excess'] = (actuals.entry - actuals.goal_max).apply(lambda x: max(0, x)) return actuals @staticmethod def _add_opportunity(actuals): actuals = actuals.copy() actuals.loc[:, 'opportunity'] = (actuals.goal_max - actuals.entry).apply(lambda x: max(0, x)) return actuals @staticmethod def _add_points(actuals): actuals = actuals.copy() actuals.loc[:, 'deficit_points'] = actuals.points * actuals.deficit actuals.loc[:, 'excess_points'] = actuals.points * actuals.excess actuals.loc[:, 'opportunity_points'] = actuals.points * actuals.opportunity return actuals def compare_goal_actual(self, add_tomorrow=False): relevant = self.ts.between(*self._get_week(add_tomorrow)) # print(relevant) actuals = relevant.groupby(['value_id', 'task']).entry.sum().reset_index() actuals = actuals.merge(self.t.table, on=['value_id', 'task'], how='right').fillna(0) return (actuals.pipe(self._add_deficit).pipe(self._add_excess).pipe( self._add_opportunity).pipe(self._add_points)).sort_values( ['deficit_points', 'opportunity_points'], ascending=[False, False]) def _get_ith_candidate(self, i): return self.table.sort_values(['deficit_points', 'opportunity_points'], ascending=[False, False]).iloc[i] def propose_next(self): for i in range(self.table.shape[0]): top_choice = self._get_ith_candidate(i) has_lock = self._has_lock(top_choice['value_id'], top_choice['task']) if not has_lock: answer = input(self._format_proposal(top_choice)) if_stop, till_when = interpret_answer(answer) if if_stop: print("Okay. Let's do it!") break else: self.lock(top_choice['value_id'], top_choice['task'], till_when) else: continue else: print('out of options wanna repeat?') def print_deficits(self, sort_variable='deficit_points'): deficits = self.table[(~self.table[['value_id', 'task']].apply( lambda x: self._has_lock(*x), axis=1)) & (self.table.deficit > 0)].sort_values( sort_variable, ascending=False) display(deficits) print('total deficit:', deficits.deficit.sum()) def _format_proposal(self, entry): vn = self.v.get_value_name(entry['value_id']) return ''' Should you do {vn}. {t} perhaps? Deficit: {dp} ({d} hours), Opportunity: {op} ({o} hours) '''.format(vn=vn, t=entry['task'], dp=entry['deficit_points'], d=entry['deficit'], op=entry['opportunity_points'], o=entry['opportunity']) def _has_lock(self, value_id, task): disturb_times = self.l.table.groupby(['value_id', 'task']).disturb_again_on.max() try: max_time = disturb_times[value_id, task] except KeyError: return False if datetime.now() > max_time: return False else: return True def lock(self, value_id, task_id, till_when): self.l.add_new_lock(value_id, task_id, till_when)
from flask import Flask, request, abort from mail import Mail_Handler from values import Values from datetime import datetime import json import sys import threading app = Flask(__name__) SERVER_IP = '192.168.1.15' values = Values() mailClient = Mail_Handler() warningTemp = 40 @app.route('/setTemp', methods=['POST']) def setTemp(): try: if (request.form['temp'] != 'Sensor error' or 'Sensor error' != request.form['humid']): f = open("./../frontend/src/data/tempData.json", "r") data = json.load(f) write = "[\n" + json.dumps( data[0]).split('}')[0] + ', "' + datetime.today().strftime( '%Y-%m-%d:%H%M' ) + '" : ' + request.form['temp'] + "}}" + ",\n" + json.dumps( data[1]).split('}')[0] + ', "' + datetime.today().strftime( '%Y-%m-%d:%H%M' ) + '" : ' + request.form['humid'] + "}}" + "\n]" originalStdout = sys.stdout f = open("./../frontend/src/data/tempData.json", "w")