Skip to content

Commit

Permalink
test: update extend_input_by_R tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmineortega committed May 17, 2022
1 parent 426b7e6 commit 539b386
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions tests/test_emgdecompy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@

def test_extend_input_by_R():
"""
Run unit tests on extend_input_by_R function from EMGdecomPy.
Run unit tests on extend_input_by_R function from emg-decomPy
"""
R_one = 5
R_two = 10
x = np.array([1, 2, 3, 4, 5, 6, 7])

assert emg.extend_input_by_R(x, R_one)[0][0] == x[0]
assert emg.extend_input_by_R(x, R_one)[0][-1] == 0
assert emg.extend_input_by_R(x, R_one).shape == (len(x), R_one + 1)
assert emg.extend_input_by_R(x, R_one)[-1][0] == x[-1]
assert emg.extend_input_by_R(x, R_one)[0][0] == emg.extend_input_by_R(x, R_one)[1][1]

assert emg.extend_input_by_R(x, R_two)[0][0] == x[0]
assert emg.extend_input_by_R(x, R_two)[0][-1] == 0
assert emg.extend_input_by_R(x, R_two).shape == (len(x), R_two + 1)
assert emg.extend_input_by_R(x, R_two)[-1][0] == x[-1]
assert emg.extend_input_by_R(x, R_two)[0][0] == emg.extend_input_by_R(x, R_two)[1][1]

for i in range(0, 15):
R = np.random.randint(1, 100) # to extend

assert R % 1 == 0, "Value of R is not an integer."
assert R > 0 , "Value of R must be greater than zero."

# length of input array
if R == 1:
q = 1

else:
q = np.random.randint(1, R)

middle = round(q/2)
x = np.random.rand(q) # create input array

testing = emg.extend_input_by_R(x, R)

assert testing[1][0] == 0, "Array not extended properly." # check first value
assert testing[middle][middle] == x[0] # check middle value
assert testing[q-1][q-1] == x[0], "Array not extended properly." # check end value
assert testing.shape == (R+1, x.shape[0]), "Shape of extended array incorrect"


def test_extend_all_channels():
"""
Expand Down

0 comments on commit 539b386

Please sign in to comment.