What type is the Test expecting for the length if not interger?

When creating a post, please add:

  • Week # must be added in the tags option of the post.
  • Link to the classroom item you are referring to:
  • Description (include relevant info but please do not post solution code or your entire notebook)

The result of my implementation of the max_length function correctly gives the result 51, but the tests complains about the object type. Here you can see my result and the test result. On both, I added a print line right after calculating the length in the function, showing max length and max_len type. What seems to be wrong?

max length = 51 | type = <class ‘numpy.int64’>
The length of the longest tweet is 51 tokens.
Expected output:

The length of the longest tweet is 51 tokens.

Test your max_len function

w1_unittest.test_max_length(max_length)
max length = 2 | type = <class ‘numpy.int64’>
Output object does not have the correct type.
Expected: 2.
Got: 2.
max length = 3 | type = <class ‘numpy.int64’>
Output object does not have the correct type.
Expected: 3.
Got: 3.
2 Tests passed
2 Tests failed

Hi @FranciscoMoreno

Your result is probably a numpy array with a single element. What the test expects is the actual Python int.

Cheers

@arvyzukai , thanks a lot for the prompt reply.

The type is ‘numpy.int64’, not numpy array.

Nevertheless, I found a way to make it pass, which I won’t write here :slight_smile: