last day (15 days later) » 

3:59 AM
0
A: Specifying a parameter (x) to be a multidimensional array that has a certain amount of columns?

John ZwinckYou need to inspect the shape. Something like this: assert len(x.shape) == 2, "input must be 2D" assert x.shape[1] == 16, "input must have 16 columns" assert np.issubdtype(x.dtype, np.integer), "input must be integers"

 
Can you explain that first line and what you mean by "input must be 20" ?
 
"Two Dee" not "Twenty." The first line checks that the input has two dimensions, not e.g. 1D or 3D etc.
 
Oh sorry lol. And yeah that makes sense. So I added that into my code, got rid of the len stuff I originally had, but when I run the program now with the test I had last mentioned in my original post, I'm getting AttributeError: 'list' object has no attribute 'shape'
 
@zainy: Then you have removed the x = np.asarray(x) which you had before. You need to do that first, otherwise you have a list-of-lists, which is not an array.
 
I just added that line back in, now when I run the program I get ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
 
3:59 AM
Which line gives you that error?
 
Hey, so the entire error message is `ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-1406-0175be5c8a9e> in <module>()
47 return values
48
---> 49 card_validate([[0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5],[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6]])
50
<ipython-input-1406-0175be5c8a9e> in card_validate(x)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-1406-0175be5c8a9e> in <module>()
47 return values
48
---> 49 card_validate([[0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5],[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6]])
50
<ipython-input-1406-0175be5c8a9e> in card_validate(x)
28 y //= 10
Maybe that's a little easier to read ^
 
so it's failing in while y? I guess you need to think about what's happening there--maybe you expected to have a single (scalar) value but got an array (vector)?
at the end of the day you just need to go step by step and debug your code
 
do you think the problem is having several functions within one big function?
 
I wouldn't put it in those terms
 
4:17 AM
I felt had to have that while y within that def getSingle(y) function because that function was needed to I could eventually use map which would apply that function throughout the xx I obtained prior to it.
I wasn't supposed to get a single scalar value though, because I was supposed to obtain a list/vector of sorts, add in the omitted checkDigit into that list/vector, and THEN get the sum of everything within that list/vector
** poor wording on my behalf, but by "of sorts" I just simply mean that the purpose of that while loop/that function was to add the sum of the digits of any of the new doubled numbers (the xx obtained prior to this function) which happen to be greater than 9
 

last day (15 days later) »