Skip to content

Update matrix_operation.py #2159

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

Merged
merged 19 commits into from
Jul 3, 2020
Merged

Update matrix_operation.py #2159

merged 19 commits into from
Jul 3, 2020

Conversation

asukaminato0721
Copy link
Contributor

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@TravisBuddy
Copy link

Hey @wuyudi,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 0371ccf0-bc1b-11ea-937a-75d40a178b7c

Copy link
Member

@ruppysuppy ruppysuppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please go through the logs and make sure that the flake8 style guidelines are followed

Copy link
Contributor Author

@asukaminato0721 asukaminato0721 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use yapf psf/black to format the code

@TravisBuddy
Copy link

Travis tests have failed

Hey @wuyudi,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: ca56e850-bc20-11ea-937a-75d40a178b7c

wuyudi and others added 4 commits July 2, 2020 14:39
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
@TravisBuddy
Copy link

Hey @wuyudi,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 4796c750-bc2f-11ea-937a-75d40a178b7c

Copy link
Contributor Author

@asukaminato0721 asukaminato0721 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add float doctest

[[2, 5, 7], [4, 8, 13], [9, 11, 15], [12, 17, 20]], 3, 3, 21)
Key 21 not found
'''
def search_in_a_sorted_matrix(mat, m, n, key):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wuyudi use static typing !!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
So I undo it, and would make another pr after this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i, j = m - 1, 0
while i >= 0 and j < n:
if key == mat[i][j]:
print(f"Key {key} found at row- {i + 1} column- {j + 1}")
print("Key {} found at row- {} column- {}".format(key, i + 1, j + 1))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f string is better than format

Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the f-string approach as discussed in CONTRIBUTING.md.

@TravisBuddy
Copy link

Hey @wuyudi,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 0f38c940-bc65-11ea-937a-75d40a178b7c

@TravisBuddy
Copy link

Hey @wuyudi,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 4b25f900-bc65-11ea-937a-75d40a178b7c

Co-authored-by: Christian Clauss <cclauss@me.com>
@cclauss
Copy link
Member

cclauss commented Jul 2, 2020

@itsvinayak Please review

@itsvinayak itsvinayak merged commit f70a0a2 into TheAlgorithms:master Jul 3, 2020
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
* Update matrix_operation.py

* Update matrix_operation.py

* Update matrix_operation.py

* use yapf to format the code

* recover the error check

* add typing hint

* Update matrix/matrix_operation.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update matrix/matrix_operation.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update matrix/matrix_operation.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update matrix/matrix_operation.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* add float doctest

* black formated

* Update searching_in_sorted_matrix.py

* recover this file

* f-string, typing hint , doctest

* Update matrix_operation.py

* Update searching_in_sorted_matrix.py

* Update matrix_operation.py

* Update matrix/matrix_operation.py

Co-authored-by: Christian Clauss <cclauss@me.com>

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: vinayak <itssvinayak@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants