Add the sample_package folder to the project
The sample_package folder serves as an example in notebook 02 as to what a Python package looks like. Its contents actually belong to the chapter on object-orientation.
This commit is contained in:
parent
c3fc760e70
commit
ec3097e220
4 changed files with 414 additions and 0 deletions
14
sample_package/utils.py
Normal file
14
sample_package/utils.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
"""This module provides utility functions."""
|
||||
|
||||
|
||||
def norm(vector_or_matrix):
|
||||
"""Calculate the Frobenius or Euclidean norm of a matrix or vector.
|
||||
|
||||
Args:
|
||||
vector_or_matrix (Vector/Matrix): the entries whose squares
|
||||
are to be summed up
|
||||
|
||||
Returns:
|
||||
norm (float)
|
||||
"""
|
||||
return math.sqrt(sum(x ** 2 for x in vector_or_matrix))
|
||||
Loading…
Add table
Add a link
Reference in a new issue