def test_zeros(self): zero = [ [0, 1, [0]], [1, [1]], ] expect = zero result = rational.SUB_QQ_Q(zero, zero) self.assertEqual(result, expect)
def test_zero(self): number = [ [0, 3, [5, 6, 3]], [2, [3, 1]], ] zero = [ [0, 1, [0]], [1, [1]], ] expect = number result = rational.SUB_QQ_Q(number, zero) self.assertEqual(result, expect)
def on_btn_q_sub_released(self): try: q1 = self.get_q_q(1) q2 = self.get_q_q(2) result = rational.SUB_QQ_Q(q1, q2) self.add_history_record('%s - %s = %s' % ( pretty.rational(q1), pretty.rational(q2), pretty.rational(result), )) except Exception as e: self.on_exception(e) pass
def test_negative_both(self): number1 = [ [1, 1, [5]], [1, [3]], ] number2 = [ [1, 1, [2]], [1, [7]], ] expect = [ [1, 2, [9, 2]], [2, [1, 2]], ] result = rational.SUB_QQ_Q(number1, number2) self.assertEqual(result, expect)
def open_window_rat_sub(): layout = [[sg.Text('Enter two rationals')], [sg.Input(key='dig1')], [sg.Button('-', key='start')], [sg.Input(key='dig2')], [sg.Text(size=(400, 10), key='out')]] window = sg.Window('The subtraction of rational numbers', layout, size=(460, 260), resizable=True) while True: event, values = window.read() if event == "start": window['out'].update( RatToStr( rat.TRANS_Q_Z( rat.SUB_QQ_Q(StrToRat(values['dig1']), StrToRat(values['dig2']))))) if event == sg.WINDOW_CLOSED: break