W1 - Dinosaur Names Assignment - Ex 1 (Clip)

Dear all,

Having problems solving the problem. The error is:

UFuncTypeError: ufunc 'clip' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32'), dtype('<U32')) -> dtype('<U32')

Given that I cannot post my code, I cannot be more helpful.

Thanks for your help.

Well, it sounds like some sort of datatype error. Notice that the error message is talking about unsigned 32 bit integers. There shouldn’t be any of those hanging around here, right?

You have two fundamental ways to implement this:

  1. You can use np.clip with appropriate parameters.
  2. You can manually implement this by doing what is sometimes called “logical indexing” of the input gradient array.

As an example of method 2), suppose I have an array called myArray and I want to zero out any elements of it that happen to have the value 42., I could write this:

myArray[myArray == 42.] = 0.

Which general method did you use? Why is the interpreter complaining about unsigned integers?

Hi Paul,

I used np.clip with what I think are the appropriate parameters (I guess I cannot share it here).
In the for loop, I used the suggested list of parameters.

Hence, with only these two lines, I have no clue where I went wrong.

Thanks.

Hi Paul,

Your comment just made a click and solved the problem.

Thanks! It had to do in fact with unsigned integers.

That’s great news that you found the solution with just that minimalist hint. Nice work. Onward! :nerd_face: