-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
matrix: add tests for column matrix #1907
Conversation
Can you demonstrate a solution that passes the existing tests, but not the suggested ones? The existing test cases on a single-number matrix would seem to cover this already. |
If it is parsed into a generalized nested list based data structure, depending on the design of the data structure, The right direction is making the parsing always produce nested lists. But if instead trying to cope the problem via treating parsed flat list specially, then it is possible to reach a solution that passes the existing tests, but not the suggested ones. (Because the special treatment only deals with the flat list shape mismatch issue, not the indistinguishable column matrix issue.) numpy's array is such a data structure (roughly optimized implementation of nested list): from io import StringIO
import numpy as np
class Matrix(object):
def __init__(self, matrix_string):
self.value = np.loadtxt(StringIO(matrix_string), dtype="int", ndmin=1)
def row(self, index):
if self.value.ndim == 1:
return [self.value[index - 1]]
else:
return list(self.value[index - 1, ...])
def column(self, index):
if self.value.ndim == 1:
return [self.value[index - 1]]
else:
return list(self.value[..., index - 1]) The above code passed all existing test, but not one of the suggested test
|
OK, I see where you're coming from. Your suggestion has called to my attention that, while the tests only deal with square matrices the description never states that the user need only handle NxN matrices. One of the following needs to occur:
For the Python track, at least, this exercise occurs quite early in the core progression, so my vote would be for the first option above. I'm going to create an issue in exercism/problem-specifications to address this. @weakish, for this PR, I suggest we proceed as thus: Since this exercise is generated, adding test cases works a little differently (we are moving towards all exercises being generated; this procedure will be the new standard in this track). Please review the contributing guide for more information.
If you have any further questions, I will be more than happy to address them as quickly as I can! |
My vote is the same. :-) |
Since exercism/problem-specifications#1576 was merged, this test suite should be regenerated to include the added tests. |
This issue has been automatically marked as |
No description provided.