mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
uses: actions/checkout@v2 (#1779)
* uses: actions/checkout@v2 * fixup! Format Python code with psf/black push
This commit is contained in:
parent
cb4795616c
commit
59bf115aa1
2
.github/workflows/autoblack.yml
vendored
2
.github/workflows/autoblack.yml
vendored
|
@ -9,7 +9,7 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-python@v1
|
- uses: actions/setup-python@v1
|
||||||
- run: pip install black
|
- run: pip install black
|
||||||
- run: black --check .
|
- run: black --check .
|
||||||
|
|
|
@ -4,7 +4,7 @@ https://en.wikipedia.org/wiki/Rayleigh_quotient
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
def is_hermitian(matrix:np.matrix) -> bool:
|
def is_hermitian(matrix: np.matrix) -> bool:
|
||||||
"""
|
"""
|
||||||
Checks if a matrix is Hermitian.
|
Checks if a matrix is Hermitian.
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ def is_hermitian(matrix:np.matrix) -> bool:
|
||||||
return np.array_equal(matrix, matrix.H)
|
return np.array_equal(matrix, matrix.H)
|
||||||
|
|
||||||
|
|
||||||
def rayleigh_quotient(A:np.matrix, v:np.matrix) -> float:
|
def rayleigh_quotient(A: np.matrix, v: np.matrix) -> float:
|
||||||
"""
|
"""
|
||||||
Returns the Rayleigh quotient of a Hermitian matrix A and
|
Returns the Rayleigh quotient of a Hermitian matrix A and
|
||||||
vector v.
|
vector v.
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
"""Calculate Modular Exponential."""
|
"""Calculate Modular Exponential."""
|
||||||
def modular_exponential(base : int, power : int, mod : int):
|
|
||||||
|
|
||||||
|
def modular_exponential(base: int, power: int, mod: int):
|
||||||
"""
|
"""
|
||||||
>>> modular_exponential(5, 0, 10)
|
>>> modular_exponential(5, 0, 10)
|
||||||
1
|
1
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import random
|
import random
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
class Dice:
|
class Dice:
|
||||||
NUM_SIDES = 6
|
NUM_SIDES = 6
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ class Dice:
|
||||||
return "Fair Dice"
|
return "Fair Dice"
|
||||||
|
|
||||||
|
|
||||||
def throw_dice(num_throws: int, num_dice: int=2) -> List[float]:
|
def throw_dice(num_throws: int, num_dice: int = 2) -> List[float]:
|
||||||
"""
|
"""
|
||||||
Return probability list of all possible sums when throwing dice.
|
Return probability list of all possible sums when throwing dice.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user