physics-data / faq

实验物理的大数据方法 FAQ
16 stars 17 forks source link

求助:grover算法作业的检测程序grade.py出现问题 #4

Closed sunjy18 closed 4 years ago

sunjy18 commented 4 years ago

1、在终端中cd到grover-sunjy18 2、运行 python3 grade.py 3、报错 Testcase data/oracle_1.py: expect '2', but get '' Testcase data/oracle_2.py: expect '15', but get '' Testcase data/oracle_3.py: expect '63', but get '' Testcase data/oracle_4.py: expect '32', but get '' Testcase data/oracle_5.py: expect '0', but get '' Testcase data/oracle_6.py: expect '63', but get '' Testcase data/oracle_7.py: expect '144', but get '' Testcase data/oracle_8.py: expect '128', but get '' Total Points: 0/100 Traceback (most recent call last): File "grade.py", line 87, in shutil.rmtree('pycache') File "/home/sjy/miniconda3/lib/python3.8/shutil.py", line 706, in rmtree onerror(os.lstat, path, sys.exc_info()) File "/home/sjy/miniconda3/lib/python3.8/shutil.py", line 704, in rmtree orig_st = os.lstat(path) FileNotFoundError: [Errno 2] No such file or directory: 'pycache'

备注: 我的程序在别的同学计算机上运行没有出错 我自己重新克隆grover再重新拷贝代码运行依然报错 直接运行程序时存在有效输出

sunjy18 commented 4 years ago

情况更新: grade.py用vscode打开,在vscode终端中输入cd grover-sunjy18,在点击运行则可以正确输出结果。 但是在终端中输入 python3 grade.py 仍然报错同上

ZenithalHourlyRate commented 4 years ago

这应该是你的环境中不会生成pycache造成的,你可以在文件结尾(87行)处的

shutil.rmtree

改为

try:
    shutil.rmtree('__pycache__')
except:
    pass

不做修改,直接提交上来应该不会有问题

sunjy18 commented 4 years ago

修改后报错 Testcase data/oracle_1.py: expect '2', but get '' Testcase data/oracle_2.py: expect '15', but get '' Testcase data/oracle_3.py: expect '63', but get '' Testcase data/oracle_4.py: expect '32', but get '' Testcase data/oracle_5.py: expect '0', but get '' Testcase data/oracle_6.py: expect '63', but get '' Testcase data/oracle_7.py: expect '144', but get '' Testcase data/oracle_8.py: expect '128', but get '' Total Points: 0/100

LiiiHua commented 4 years ago

出现类似的问题,但很奇怪只有oracle_8出错。 如果把grover.py中的oracle改为data.oracle_8则可以print出正确的答案。 即使把grade.py中的testcase里的顺序改变,出错的还是只有oracle_8。 即使在grover.py最后改成print(128),oracle_8仍然报错说get '',但其他是报错get '128'。 尝试了助教的修改没有解决错误。

ZenithalHourlyRate commented 4 years ago

@sunjy18 @LiiiHua 本地环境可能比较玄学,你们可以尝试提交上来,检查一下你们两个的repo,你们过了 github actions 的检查,应该没有问题