[Woking in Progress] Standarize code#627
Open
WaKeMaTTa wants to merge 10 commits intoSciRuby:masterfrom
Open
Conversation
dde1123 to
9a8c821
Compare
9a8c821 to
86e568d
Compare
f44f2c7 to
17bc088
Compare
48ae7fd to
fb504a0
Compare
developerfab
reviewed
Jun 9, 2019
| ['nmatrix_config.h', '$(archdir)'], | ||
| ['nm_memory.h' , '$(archdir)'], | ||
| ['ruby_constants.h', '$(archdir)'] | ||
| ["nmatrix.h", "$(archdir)"], |
There was a problem hiding this comment.
I think you should leave the single quote, because the double quote is use when you want to do an interpolation. WDYT? 🤔
Author
There was a problem hiding this comment.
Standard gem decides to use "double quotes" then we use "double quotes".
| Dir.mkdir("data") unless Dir.exists?("data") | ||
| Dir.mkdir("util") unless Dir.exists?("util") | ||
| Dir.mkdir("storage") unless Dir.exists?("storage") | ||
| Dir.mkdir("data") unless Dir.exist?("data") |
There was a problem hiding this comment.
directories = %w(data util storage yale list dense)
# if a directory not exist, it is create
directories.each do |directory|
Dir.mkdir(directory) unless Dir.exist?(directory)
endWDYT? 🤔
| raise(ArgumentError, 'Expected dense NMatrices as first two arguments.') \ | ||
| unless a.is_a?(NMatrix) and b.is_a? \ | ||
| (NMatrix) and a.stype == :dense and b.stype == :dense | ||
| raise(ArgumentError, "Expected dense NMatrices as first two arguments.") \ |
There was a problem hiding this comment.
I think you could separate these validations into multiple functions to make this function more readable:
def gemm(.....)
...
validate_argument?(a)
validate_argument?(b)
...
end
private
def validate_argument(matrix)
nmatrix?(matrix) && dense_stype?(matrix)
end
def nmatrix?(matrix)
message = 'Expected NMatrices object as first two arguments.'
raise(ArgumentError, message) unless matrix.is_a?(NMatrix)
end
def dense_stype?(matrix)
message = 'Expected dense NMatrices as first two arguments.'
raise(ArgumentError, message) unless (matrix.stype == :dense)
endWDYT? 🤔
|
This is why a project has to maintain maximum consistency. Ruby is very flexible but this can negatively affect productivity, It does not seem to really necessary to write code like this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this pull request?
✔️ Readability
✔️ Maintainability
✔️ Consistent syntax
✔️ More secure (because it helps to prevent usually bad practices)
Todo
standardgem (including it toRakefilealso)standard.ymltravis.ymlbundle exec rake standardin thescriptsectionbundle exec rake standard:fixFix this ones manually