コード例 #1
0
def test_electrical_calc_power_volts_ohms():
    test_obj_a = eb.Volt(110, 'V', 50, 'Hz')
    test_obj_b = eb.Ohm(complex(2, 2), 'Ohms', 50, 'Hz')
    test_obj_c = eb.ElectricalCalc(test_obj_b, test_obj_a)
    power_obj = test_obj_c.calc_power()
    result = ((3025 - 3025j), 'V^2/Ohms')
    assert (power_obj.power, power_obj.power_unit) == result
コード例 #2
0
def test_electrical_calc_voltage_amp_ohms():
    test_obj_a = eb.Amp(100, 'A', 50, 'Hz')
    test_obj_b = eb.Ohm(complex(2, 2), 'Ohms', 50, 'Hz')
    test_obj_c = eb.ElectricalCalc(test_obj_b, test_obj_a)
    current_obj = test_obj_c.calc_voltage()
    result = ((200 + 200j), 'Volts (A*Ohms)')
    assert (current_obj.volts, current_obj.volt_unit) == result
コード例 #3
0
def test_electrical_calc_current_volts_ohms():
    test_obj_a = eb.Volt(1000, 'V', 50, 'Hz')
    test_obj_b = eb.Ohm(complex(2, 2), 'Ohms', 50, 'Hz')
    test_obj_c = eb.ElectricalCalc(test_obj_b, test_obj_a)
    current_obj = test_obj_c.calc_current()
    result = ((250 - 250j), 'Amps (V/Ohms)')
    assert (current_obj.amps, current_obj.amp_unit) == result
コード例 #4
0
def test_electrical_calc_power_amp_ohms():
    test_obj_a = eb.Amp(10, 'A', 50, 'Hz')
    test_obj_b = eb.Ohm(complex(2, 2), 'Ohms', 50, 'Hz')
    test_obj_c = eb.ElectricalCalc(test_obj_b, test_obj_a)
    power_obj = test_obj_c.calc_power()
    result = ((200 + 200j), 'A^2*Ohms')
    assert (power_obj.power, power_obj.power_unit) == result
コード例 #5
0
def test_ohm_z():
    test_obj = eb.Ohm()
    test_obj.z = complex(0.3, 0.4)
    result = 0.5
    assert test_obj.z == result
コード例 #6
0
def test_ohm_x():
    test_obj = eb.Ohm()
    test_obj.x = 1.5
    result = 1.5
    assert test_obj.x == result
コード例 #7
0
def test_ohm_r():
    test_obj = eb.Ohm()
    test_obj.r = 0.6
    result = 0.6
    assert test_obj.r == result
コード例 #8
0
def test_ohm_scalar():
    test_obj = eb.Ohm()
    test_obj.magnitude = 275
    test_obj.scalar_unit = 'Turns per inch'
    result = (275, 'Turns per inch')
    assert tuple([test_obj.magnitude, test_obj.scalar_unit]) == result
コード例 #9
0
def test_ohm_freq_unit():
    test_obj = eb.Ohm(freq_unit='Hz')
    result = 'Hz'
    assert test_obj.freq_unit == result
コード例 #10
0
def test_ohm_freq():
    test_obj = eb.Ohm(freq=50)
    result = 50
    assert test_obj.frequency == result
コード例 #11
0
def test_ohm__sub__obj():
    test_obj_a = eb.Ohm(complex(3, 4), 'ohm', 50, 'hz')
    test_obj_b = eb.Ohm(complex(7, 6), 'ohm', 50, 'hz')
    result = (-4 - 2j)
    test_obj_c = test_obj_a - test_obj_b
    assert test_obj_c.ohm == result
コード例 #12
0
def test_ohm__truediv__int_float():
    test_obj_a = eb.Ohm(complex(3, 12), 'ohm', 50, 'hz')
    test_obj_b = 3
    result = complex(1, 4)
    test_obj_c = test_obj_a / test_obj_b
    assert test_obj_c.ohm == result
コード例 #13
0
def test_ohm__truediv__obj():
    test_obj_a = eb.Ohm(complex(3, 4), 'ohm', 50, 'hz')
    test_obj_b = eb.Ohm(complex(1, 1), 'ohm', 50, 'hz')
    result = (3.5 + 0.5j)
    test_obj_c = test_obj_a / test_obj_b
    assert test_obj_c.ohm == result
コード例 #14
0
def test_ohm__mul__complex():
    test_obj_a = eb.Ohm(complex(1, 4), 'ohm', 50, 'hz')
    test_obj_b = complex(3, 3)
    result = complex(-9, 15)
    test_obj_c = test_obj_a * test_obj_b
    assert test_obj_c.ohm == result
コード例 #15
0
def test_ohm__mul__obj():
    test_obj_a = eb.Ohm(complex(1, 2), 'ohm', 50, 'hz')
    test_obj_b = eb.Ohm(complex(3, 4), 'ohm', 50, 'hz')
    result = (-5 + 10j)
    test_obj_c = test_obj_a * test_obj_b
    assert test_obj_c.ohm == result
コード例 #16
0
def test_ohm__sub__int_float():
    test_obj_a = eb.Ohm(complex(3, 4), 'ohm', 50, 'hz')
    test_obj_b = complex(1.7, 1.6)
    result = (1.3 + 2.4j)
    test_obj_c = test_obj_a - test_obj_b
    assert test_obj_c.ohm == result
コード例 #17
0
def test_ohm__add__obj():
    test_obj_a = eb.Ohm(complex(0.3, 0.4), 'ohm', 50, 'hz')
    test_obj_b = eb.Ohm(complex(0.7, 0.6), 'ohm', 50, 'hz')
    result = (1 + 1j)
    test_obj_c = test_obj_a + test_obj_b
    assert test_obj_c.ohm == result
コード例 #18
0
def test_ohm__truediv__complex():
    test_obj_a = eb.Ohm(complex(3, 4), 'ohm', 50, 'hz')
    test_obj_b = complex(2, 2)
    result = complex(1.75, 0.25)
    test_obj_c = test_obj_a / test_obj_b
    assert test_obj_c.ohm == result
コード例 #19
0
def test_ohm__add__int_float():
    test_obj_a = eb.Ohm(complex(0.3, 0.4), 'ohm', 50, 'hz')
    test_obj_b = complex(1.7, 1.6)
    result = (2 + 2j)
    test_obj_c = test_obj_a + test_obj_b
    assert test_obj_c.ohm == result
コード例 #20
0
def test_ohm_scalar_unit():
    test_obj = eb.Ohm()
    test_obj.ohm_unit = 'ohm'
    result = 'ohm'
    assert test_obj.ohm_unit == result
コード例 #21
0
def test_ohm__init__():
    test_obj = eb.Ohm(complex(0.3, 0.4), 'ohm', 50, 'hz')
    result = ((0.3 + 0.4j), 'ohm', 50, 'hz')
    assert tuple([
        test_obj.ohm, test_obj.ohm_unit, test_obj.frequency, test_obj.freq_unit
    ]) == result