Add matrix multiplication function with validation - #13934
ArsiyaTasleem90250 wants to merge 3 commits into
Conversation
Implement matrix multiplication function with validation.
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| if not _is_valid_matrix(A) or not _is_valid_matrix(B): | ||
| raise ValueError("Invalid matrix structure") | ||
|
|
||
| rows_A = len(A) |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: rows_A
| raise ValueError("Invalid matrix structure") | ||
|
|
||
| rows_A = len(A) | ||
| cols_A = len(A[0]) |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: cols_A
|
|
||
| rows_A = len(A) | ||
| cols_A = len(A[0]) | ||
| rows_B = len(B) |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: rows_B
| rows_A = len(A) | ||
| cols_A = len(A[0]) | ||
| rows_B = len(B) | ||
| cols_B = len(B[0]) |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: cols_B
| from typing import List | ||
|
|
||
|
|
||
| def matrix_multiply(A: List[List[float]], B: List[List[float]]) -> List[List[float]]: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: A
Please provide descriptive name for the parameter: B
| return result | ||
|
|
||
|
|
||
| def _is_valid_matrix(M: List[List[float]]) -> bool: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: M
|
@priya-sundaram-dev Filename is matrix/matrix_diagonal_sum.py, but the algorithm is matrix multiplication. |
|
@cclauss you're right — they're mismatched. The file is named @ArsiyaTasleem90250 two things to sort out before this can go in:
Happy to re-review once it's pointed at a non-duplicate algorithm. Thanks for the PR! |
|
@cclauss good catch — yes, these look like two different things. The file is named And matrix multiplication is already in the repo, so as written this is a duplicate:
Two ways forward for @-the author:
Two smaller style notes for whichever direction is taken (both will trip the ruff CI here):
|
Implement matrix multiplication function with validation.
Describe your change:
Checklist: