The Wayback Machine - https://web.archive.org/web/20201126012835/https://github.com/TheAlgorithms/Python/pull/3878
Skip to content
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

Added cross product to matrix class #3878

Open
wants to merge 8 commits into
base: master
from

Conversation

@JSamonig
Copy link

@JSamonig JSamonig commented Nov 11, 2020

Added cross product to matrix class

Cross product is a vector function used to find areas between two vectors
https://en.wikipedia.org/wiki/Cross_product

Added type hints and fixed spelling.

  • 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}.
JSamonig added 6 commits Nov 11, 2020
Cross product strictly applies to 3x1 vectors.
Spelling and formating improved.
Copy link
Contributor

@xcodz-dot xcodz-dot left a comment

Please add this line to starting of file to avoid any other errors with type hinting.

class Matrix:
    pass
matrix/matrix_class.py Show resolved Hide resolved
matrix/matrix_class.py Show resolved Hide resolved
matrix/matrix_class.py Show resolved Hide resolved
if self.num_rows == 0:
return "[]"
if self.num_rows == 1:
return "[[" + ". ".join(self.rows[0]) + "]]"
print(self.rows[0])

This comment has been minimized.

@xcodz-dot

xcodz-dot Nov 16, 2020
Contributor

I dont think using print is a good practise is algorithms.
If possible, please remove it.

This comment has been minimized.

@JSamonig

JSamonig Nov 18, 2020
Author

Removed it.

matrix/matrix_class.py Show resolved Hide resolved
matrix/matrix_class.py Show resolved Hide resolved
matrix/matrix_class.py Show resolved Hide resolved
matrix/matrix_class.py Show resolved Hide resolved
matrix/matrix_class.py Show resolved Hide resolved
matrix/matrix_class.py Show resolved Hide resolved
JSamonig and others added 2 commits Nov 18, 2020
Co-authored-by: xcodz-dot <[email protected]>
Added "Matrix" back as I was getting an error. Adding an empty pass statement did not solve it. Creating another class is just using the same class without using it.
@JSamonig
Copy link
Author

@JSamonig JSamonig commented Nov 18, 2020

Please add this line to starting of file to avoid any other errors with type hinting.

class Matrix:
    pass

Did not do this. Just left the "Matrix" in. I am quite reluctant to do so, as I would just be defining the class again without using it. Using -> "myclass" is correct. See this link. Removed the print.

Copy link
Contributor

@xcodz-dot xcodz-dot left a comment

Great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.