-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[WIP] add matrix checking function for quiver input #7461
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
Changes from 1 commit
d8841a8
bba1ea6
4bdcac3
22655b6
73a69a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1014,6 +1014,7 @@ def mkdirs(newdir, mode=0o777): | |
if exception.errno != errno.EEXIST: | ||
raise | ||
|
||
|
||
class GetRealpathAndStat(object): | ||
def __init__(self): | ||
self._cache = {} | ||
|
@@ -1734,7 +1735,7 @@ def recursive_remove(path): | |
os.removedirs(fname) | ||
else: | ||
os.remove(fname) | ||
#os.removedirs(path) | ||
# os.removedirs(path) | ||
else: | ||
os.remove(path) | ||
|
||
|
@@ -2701,3 +2702,15 @@ def __exit__(self, exc_type, exc_value, traceback): | |
os.rmdir(path) | ||
except OSError: | ||
pass | ||
|
||
|
||
def is_matrix(obj): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my point of view any There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd indeed rename this |
||
''' | ||
This is a test for whether the input is a matrix. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please use triple double quotes The docstring is also very unclear on what this function does. |
||
If the input is a matrix, raise an error. Otherwise, | ||
return the object as it is. | ||
''' | ||
cast_result = np.asanyarray(obj) | ||
if type(cast_result) == np.matrix: | ||
raise ValueError("The input cannot be matrix") | ||
return obj | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'd want to return the cast objects. Ie, if X is a list, you want the returned object to be an array. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then should I raise the error in this function or just return false and raise the error inside the function who calls check_array? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you really want to touch this function, I'd just alias
recursive_remove
toshutil.rmtree
(withonerror
set to remove files) :-) Otherwise this is kind of pointless.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just changed the comment part according to the pep8 style. Nothing is changed within the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I don't think that's really in the scope of this PR.