Esempio n. 1
0
 def test_zero(self):
     zero = [
         [0, 1, [0]],
         [1, [1]],
     ]
     expect = [0, 1, [0]]
     result = rational.TRANS_Q_Z(zero)
     self.assertEqual(result, expect)
Esempio n. 2
0
 def test_negative(self):
     number = [
         [1, 3, [4, 6, 7]],
         [1, [1]],
     ]
     expect = [1, 3, [4, 6, 7]]
     result = rational.TRANS_Q_Z(number)
     self.assertEqual(result, expect)
Esempio n. 3
0
 def on_btn_q_transqz_released(self):
     try:
         q1 = self.get_q_q(1)
         result = rational.TRANS_Q_Z(q1)
         self.add_history_record('%s = %d' % (
             pretty.rational(q1),
             common.Z_to_num(result),
             ))
     except Exception as e:
         self.on_exception(e)
def open_window_rat_red():
    layout = [[sg.Text('Enter two rationals')], [sg.Input(key='dig1')],
              [sg.Button('', key='start')],
              [sg.Text(size=(400, 10), key='out')]]
    window = sg.Window('The fraction reduction 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.RED_Q_Q(StrToRat(values['dig1'])))))
        if event == sg.WINDOW_CLOSED:
            break