Skip to content

[math] Add new module linalg and more numpy methods (diag_indices_from & det & norm)#64

Merged
chaoming0625 merged 6 commits intomainfrom
more-methods
Nov 21, 2024
Merged

[math] Add new module linalg and more numpy methods (diag_indices_from & det & norm)#64
chaoming0625 merged 6 commits intomainfrom
more-methods

Conversation

@Routhleck
Copy link
Collaborator

@Routhleck Routhleck commented Nov 21, 2024

This pull request introduces new functions and updates to existing ones in the brainunit library, specifically focusing on linear algebra and mathematical operations. The changes include adding new functions for computing determinants, norms, and diagonal indices, along with corresponding unit tests to ensure correctness.

New Functions:

  • Added det function to compute the determinant of an array in brainunit.math (brainunit/math/_fun_change_unit.py).
  • Added norm function to compute the norm of a matrix or vector in brainunit.math (brainunit/math/_fun_keep_unit.py).
  • Added diag_indices_from function to return indices for accessing the main diagonal of a given array in brainunit.math (brainunit/math/_fun_remove_unit.py).

Updates to Existing Functions:

  • Included det in the list of linear algebra functions in brainunit.math (brainunit/math/_fun_change_unit.py).
  • Included norm in the list of mathematical functions that keep units in brainunit.math (brainunit/math/_fun_keep_unit.py).
  • Included diag_indices_from in the list of indexing functions in brainunit.math (brainunit/math/_fun_remove_unit.py).

Unit Tests:

  • Added tests for the det function in brainunit/math/_fun_change_unit_test.py to verify the correctness of determinant calculations with and without units.
  • Added tests for the norm function in brainunit/math/_fun_keep_unit_test.py to ensure the norm calculations are accurate and maintain units when necessary.
  • Added tests for the diag_indices_from function in brainunit/math/_fun_remove_unit_test.py to validate the correct indices are returned for accessing the main diagonal of arrays.

@Routhleck Routhleck added the enhancement New feature or request label Nov 21, 2024
@Routhleck Routhleck marked this pull request as ready for review November 21, 2024 06:42
@Routhleck Routhleck changed the title [math] More numpy methods (diag_indices_from & det) [math] More numpy methods (diag_indices_from & det & norm) Nov 21, 2024
@Routhleck Routhleck changed the title [math] More numpy methods (diag_indices_from & det & norm) [math] Add new module linalg and more numpy methods (diag_indices_from & det & norm) Nov 21, 2024
Copy link
Member

@chaoming0625 chaoming0625 left a comment

Choose a reason for hiding this comment

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

Geat work.

@chaoming0625 chaoming0625 merged commit caf419d into main Nov 21, 2024
@chaoming0625 chaoming0625 deleted the more-methods branch November 21, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants