Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Bug when the efficiency of my program is computed

gabriel.bustamante (2540 points)
3 6 20
in HW2 by (2.5k points)
reshown by

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? 

381 views
closed

3 Answers

Best answer
andrea.sterbini (207920 points)
750 1267 2373
by (208k points)
selected by
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 (207920 points)
750 1267 2373
by (208k points)
Found.

You should NOT change destructively the content of the matches list.
Luigi Pizza (6120 points)
14 20 65
by (6.1k 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 6 20
by (2.5k 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)
14 20 65
by (6.1k 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 6 20
by (2.5k 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
by (7.8k 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.