Bug when the efficiency of my program is computed

gabriel.bustamante (2540 points)
3 5 20
asked Oct 29, 2021 in HW2 by gabriel.bustamante (2,540 points)
reshown Nov 11, 2021 by gabriel.bustamante

I've just uploaded an updated version of my HW02. All tests pass but I was surprised when it reported that it executed in ~9ms, to say the least. 

For that reason I looked at the efficiency tab in the "Results" page and saw that nearly all tests failed the efficiency check because of an error raised by an expression that I also used in the previous version of my program in a similar, but not equal, context. The efficiency of the previous program computed fine.

Here is the same test as reported by the "Correctness" tab and the "Efficiency" tab:

Correctness tab

==Test==test_emoji_10_10_50_00001_test_emoji_10_10_50 PASSED

Efficiency tab

test_emoji_10_10_50_00001_test_emoji_10_10_50 (test_01.Test)
test_emoji_10_10_50_00001_test_emoji_10_10_50 ... ok

then, later in the efficiency tab

test_emoji_10_10_50_00001_test_emoji_10_10_50 (test_01.Test)
test_emoji_10_10_50_00001_test_emoji_10_10_50 ... ERROR

then, later in the efficiency tab

======================================================================
ERROR= test_emoji_10_10_50_00001_test_emoji_10_10_50 (test_01.Test)
test_emoji_10_10_50_00001_test_emoji_10_10_50
----------------------------------------------------------------------
Traceback (most recent call last)=
  File "/usr/lib/python3/dist-packages/ddt.py", line 145, in wrapper
    return func(self, *args, **kwargs)
  File "/home/andrea/AA21/repo/AA21-HW2-req-en/students/1983278/homework02/./test_01.py", line 90, in test_emoji_10_10_50
    return self.do_test(matches, k, expected)
  File "/home/andrea/AA21/repo/AA21-HW2-req-en/students/1983278/homework02/./test_01.py", line 32, in do_test
    result = program.ex(matches, k)
  File "/home/andrea/AA21/repo/AA21-HW2-req-en/students/1983278/homework02/./program01.py", line 86, in ex
    my_expression = foo.method()
AttributeError= 'list' object has no attribute 'method' 

Is my program okay to deliver or should I find a fix? 

190 views

3 Answers

Best answer
andrea.sterbini (172680 points)
511 927 1776
answered Oct 29, 2021 by andrea.sterbini (172,680 points)
selected Oct 29, 2021 by gabriel.bustamante
Thanks for letting me know about this problem.

Please disregard the time computed.

I will examine and fix the scripts as soon as reasonably possible
andrea.sterbini (172680 points)
511 927 1776
commented Oct 29, 2021 by andrea.sterbini (172,680 points)
Found.

You should NOT change destructively the content of the matches list.
Luigi Pizza (6120 points)
11 20 65
answered Oct 29, 2021 by Luigi Pizza (6,120 points)

You should find a fix, but it should be quite straightforward: You have written in line 86 of your code

my_expression = foo.method()

where foo is a list and method should be a method, but there are no methods called method. You have to change this line in something that makes sense. 

If you created a method (called method) from scratch before this line, you have to make it right.

gabriel.bustamante (2540 points)
3 5 20
commented Oct 29, 2021 by gabriel.bustamante (2,540 points)
I replaced the expression with a placeholder as it is the solution to a sub-problem of HW02. The thing is,  "foo" is a string, and "method" is a valid method for "foo". It works everywhere else and even passes the correctness tests without any errors
Luigi Pizza (6120 points)
11 20 65
commented Oct 29, 2021 by Luigi Pizza (6,120 points)
Well, If it says that foo is a list, it must be: have you done something that may have caused it to become a list? for example a .split()?
gabriel.bustamante (2540 points)
3 5 20
commented Oct 29, 2021 by gabriel.bustamante (2,540 points)
I've checked the type of "foo" before and after applying the method on the same inputs (I hope so, I'm using a test with the same name as the one that raises the error). It stays a String all the way through, I can only think of an issue on the VM's side
GabrielAlexandru (7760 points)
2 4 29
answered Oct 29, 2021 by GabrielAlexandru (7,760 points)
Since the tests for correctness all pass, I think it's an error of the Virtual Machine, so in my opinion you should wait for a professor to check the problem before doing anything.