def test_capacitive_reactance(self): assert_approx_equal(capacitive_reactance("100 pF", "3.2 MHz"), 497.3592) assert_approx_equal(capacitive_reactance(100e-12, 3.2e6), 497.3592) assert_approx_equal(capacitive_reactance(100e-12, 3.2e6), 497.3592) assert_equal(autoFormat(capacitive_reactance, "100 pF", "3.2 MHz"), "497 Ω")
def test_computeBottomResistor(self): assert_approx_equal(computeBottomResistor(1000.0, 0.5), 1000.0) assert_approx_equal(computeBottomResistor(1000.0, 5/6.0), 200.0) assert_equal(autoFormat(computeBottomResistor, 1000.0, 0.5), "1000 Ω") assert_equal(autoFormat(computeBottomResistor, 1000.0, 5/6.0), "200 Ω")
def test_inductive_reactance(self): assert_approx_equal(inductive_reactance("100 µH", "3.2 MHz"), 2010.619) assert_approx_equal(inductive_reactance(100e-6, 3.2e6), 2010.619) assert_equal(autoFormat(inductive_reactance, "100 µH", "3.2 MHz"), "2.01 kΩ")
def test_capacitor_energy(self): assert_approx_equal(capacitor_energy("1.5 F", "5.0 V"), 18.75) assert_approx_equal(capacitor_energy("1.5 F", "0.0 V"), 0.0) assert_equal(autoFormat(capacitor_energy, "100 mF", "1.2 V"), "72.0 mJ")
def test_computeTopResistor(self): assert_approx_equal(computeTopResistor(1000.0, 0.5), 1000.0) assert_approx_equal(computeTopResistor(200.0, 5/6.0), 1000.0) assert_equal(autoFormat(computeTopResistor, 1000.0, 0.5), "1000 Ω") assert_equal(autoFormat(computeTopResistor, 400.0, 5/6.0), "2.00 kΩ")
def test_capacitor_charge(self): assert_approx_equal(capacitor_charge("1.5 F", "5.0 V"), 7.5) assert_approx_equal(capacitor_charge("1.5 F", "0.0 V"), 0.0) assert_equal(autoFormat(capacitor_charge, "1.5 F", "5.0 V"), "7.50 C")
def test_johnson_nyquist_noise_current(self): v = johnson_nyquist_noise_current("20 MΩ", "10000 ΔHz", "20 °C") assert_approx_equal(v, 2.84512e-12, significant=5) assert_equal(autoFormat(johnson_nyquist_noise_current, "20 MΩ", "10000 ΔHz", "20 °C"), "2.85 pA")
def test_johnson_nyquist_noise_voltage(self): v = johnson_nyquist_noise_voltage("20 MΩ", "10000 ΔHz", "20 °C") assert_equal(autoFormat(johnson_nyquist_noise_voltage, "20 MΩ", "10000 ΔHz", "20 °C"), "56.9 µV") assert_approx_equal(v, 56.9025e-6, significant=5)
def test_summing_amplifier_noninv(self): v = summing_amplifier_noninv("2.5V", "500mV", "1kΩ", "1kΩ", "1kΩ", "1kΩ") assert_approx_equal(v, 3.0) v = summing_amplifier_noninv(2.5, 0.5, 1e3, 1e3, 300, 1e3) assert_approx_equal(v, 6.5) assert_equal(autoFormat(summing_amplifier_noninv, 2.5, 0.5, 1e3, 1e3, 300, 1e3), "6.50 V")
def testAutoFormatTemperature(self): assert_equal(autoFormat(normalize_temperature, "-200°C"), "73.1 °K") assert_equal(autoFormat(normalize_temperature_celsius, "-200°C"), "-200.00 °C") assert_equal(autoFormat(normalize_temperature_celsius, "-111 °C"), "-111.00 °C") assert_equal(autoFormat(normalize_temperature_celsius, "0 °K"), "-273.15 °C")