From 89f2ff73d0954cf8930e96e15278984972ac1a48 Mon Sep 17 00:00:00 2001 From: fuchenxi <1256257282@qq.com> Date: Tue, 27 Aug 2024 10:02:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8F=82=E6=95=B0=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E5=8F=8A=E7=A7=BB=E5=85=A5test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +++- elec/__init__.py | 2 +- elec/ngspice.py | 2 +- elec/t1_create.py | 4 ++-- tct/tct_signal.py | 2 +- tct/tct_t1.py | 2 +- tests/__init__.py | 0 tests/test_draw.py | 13 +++++++++++++ tests/test_field.py | 13 +++++++++++++ 9 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/test_draw.py create mode 100644 tests/test_field.py diff --git a/.gitignore b/.gitignore index d5e4f15..7873152 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -**/__pycache__ \ No newline at end of file +**/__pycache__ +raser.egg-info +dist \ No newline at end of file diff --git a/elec/__init__.py b/elec/__init__.py index 71f35d1..d739f8f 100644 --- a/elec/__init__.py +++ b/elec/__init__.py @@ -9,7 +9,7 @@ def main(kwargs): subprocess.run(['ngspice -b -r t1.raw output/T1_tmp.cir'], shell=True) if label == 'drs4_get_analog': import subprocess - subprocess.run(['ngspice -b -r drs4_analog.raw paras/drs4_analog.cir'], shell=True) + subprocess.run(['ngspice -b -r drs4_analog.raw paras/circuitdrs4_analog.cir'], shell=True) if label == 'drs4_get_fig': from . import drs4_get_fig drs4_get_fig.main() diff --git a/elec/ngspice.py b/elec/ngspice.py index 51b093d..cf32376 100644 --- a/elec/ngspice.py +++ b/elec/ngspice.py @@ -1,5 +1,5 @@ def ngspice(input_c, input_p): - with open('./paras/T1.cir', 'r') as f: + with open('./paras/circuitT1.cir', 'r') as f: lines = f.readlines() lines[113] = 'I1 2 0 PWL('+str(input_c)+') \n' lines[140] = 'tran 0.1p ' + str((input_p[len(input_p) - 2])) + '\n' diff --git a/elec/t1_create.py b/elec/t1_create.py index caddb30..70df9e2 100644 --- a/elec/t1_create.py +++ b/elec/t1_create.py @@ -70,7 +70,7 @@ if number>=1: input_c.append(str(0)) input_p=','.join(input_c) - with open('/scratchfs/atlas/xingchenli/raser/paras/T1.cir', 'r') as f: + with open('/scratchfs/atlas/xingchenli/raser/paras/circuitT1.cir', 'r') as f: lines = f.readlines() lines[113] = 'I1 2 0 PWL('+str(input_p)+') \n' lines[140] = 'tran 0.1p ' + str((input_c[len(input_c) - 2])) + '\n' @@ -142,7 +142,7 @@ else: input_c.append(str(0)) input_p=','.join(input_c) - with open('/scratchfs/atlas/xingchenli/raser/paras/T1.cir', 'r') as f: + with open('/scratchfs/atlas/xingchenli/raser/paras/circuitT1.cir', 'r') as f: lines = f.readlines() lines[113] = 'I1 2 0 PWL('+str(input_p)+') \n' lines[140] = 'tran 0.1p ' + str((input_c[len(input_c) - 2])) + '\n' diff --git a/tct/tct_signal.py b/tct/tct_signal.py index c6f9a84..e08a73a 100644 --- a/tct/tct_signal.py +++ b/tct/tct_signal.py @@ -44,7 +44,7 @@ if "ngspice" in args: my_current.save_current(dset,my_d,my_l,my_f,"fx_rel") input_p=ngsip.set_input(dset,my_current,my_l,my_d,"fx_rel") input_c=','.join(input_p) - with open('paras/T1.cir', 'r') as f: + with open('paras/circuitT1.cir', 'r') as f: lines = f.readlines() lines[113] = 'I1 2 0 PWL('+str(input_c)+') \n' lines[140] = 'tran 0.1p ' + str((input_p[len(input_p) - 2])) + '\n' diff --git a/tct/tct_t1.py b/tct/tct_t1.py index 0d903c8..5701fd7 100644 --- a/tct/tct_t1.py +++ b/tct/tct_t1.py @@ -64,7 +64,7 @@ t_start = t1 t_rise = t2 - t1 t_fall = t3 - t2 -with open('paras/T1.cir', 'r') as f: +with open('paras/circuitT1.cir', 'r') as f: lines = f.readlines() lines[113] = 'I1 2 0 pulse(0 ' + str(c_max) + 'u ' + str(t_start) + 'n ' + str(t_rise) + 'n ' + str(t_fall) + 'n 0.00000001n ' + str((T_ele[len(T_ele) - 1])) + 'n 0)\n' lines[140] = 'tran 0.1p ' + str((T_ele[len(T_ele) - 1])) + 'n\n' diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_draw.py b/tests/test_draw.py new file mode 100644 index 0000000..553444b --- /dev/null +++ b/tests/test_draw.py @@ -0,0 +1,13 @@ +import unittest + +class TestSum(unittest.TestCase): + def test_draw(self): + """ + Test draw functions + """ + data = [1, 2, 3] + result = sum(data) + self.assertEqual(result, 6) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_field.py b/tests/test_field.py new file mode 100644 index 0000000..b3ce176 --- /dev/null +++ b/tests/test_field.py @@ -0,0 +1,13 @@ +import unittest + +class TestSum(unittest.TestCase): + def test_field_cal_gen_devsim_db(self): + """ + Test field cal gen_devsim_db + """ + data = [1, 2, 3] + result = sum(data) + self.assertEqual(result, 6) + +if __name__ == '__main__': + unittest.main() -- GitLab