Skip to content

Commit

Permalink
isort + black
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-S-Rosen committed Sep 20, 2023
1 parent 0d5bad5 commit aa475b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 6 additions & 4 deletions src/template/sample.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations

import numpy as np


Expand All @@ -12,15 +13,16 @@ def add(a: float, b: float) -> float:
First number to add.
b
Second number to add.
Returns
-------
float
The sum of a and b.
"""
return a + b


def make_array(val: float | float, length: int = 3) -> np.ndarray:
"""
A function to transform a number into a numpy array.
Expand All @@ -31,10 +33,10 @@ def make_array(val: float | float, length: int = 3) -> np.ndarray:
Number to turn into an array.
length
The length of the array.
Returns
-------
np.ndarray
An array composed of `val`.
"""
return np.array([val]*length)
return np.array([val] * length)
11 changes: 6 additions & 5 deletions tests/sample/test_sample.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import pytest
import numpy as np
import pytest
from numpy.testing import assert_allclose

from template.sample import add, make_array


def test_add():
assert add(1, 2) == 3
assert add(1.5, 2.0) == pytest.approx(3.5)
assert add(1, 2) == 3
assert add(1.5, 2.0) == pytest.approx(3.5)


def test_make_array():
assert_allclose(make_array(3), np.array([3, 3, 3]))
assert_allclose(make_array(3, 4), np.array([3, 3, 3, 3]))
assert_allclose(make_array(3), np.array([3, 3, 3]))
assert_allclose(make_array(3, 4), np.array([3, 3, 3, 3]))

0 comments on commit aa475b9

Please sign in to comment.