Skip to content

Commit

Permalink
Add a basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
AuguB committed Dec 8, 2023
1 parent a0a1594 commit 94a3a63
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pcntoolkit/normative.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def load_response_vars(datafile, maskfile=None, vol=True):
:returns Y: Response variables
:returns volmask: Mask file (nifti only)
"""

if fileio.file_type(datafile) == 'nifti':
dat = fileio.load_nifti(datafile, vol=vol)
volmask = fileio.create_mask(dat, mask=maskfile)
Expand All @@ -73,7 +72,7 @@ def load_response_vars(datafile, maskfile=None, vol=True):
if fileio.file_type(datafile) == 'cifti':
Y = Y.T

return Y, volmask
return Y, volmask,'test'


def get_args(*args):
Expand Down
Empty file added pytest/__init__.py
Empty file.
37 changes: 37 additions & 0 deletions pytest/test_normative.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import pytest
from pcntoolkit.normative import load_response_vars
from pcntoolkit.dataio import fileio
# from dataio import fileio

import numpy as np

def create_dummy_data():
# Create a dummy 3D array for the datafile
data = np.random.rand(10, 10, 10)

# Create a dummy 3D array for the maskfile
mask = np.ones((10, 10, 10))

return data, mask

# Use the function to create the dummy data
data, mask = create_dummy_data()

# Store the dummy data on disk
datafile = 'test_data.nii.gz'
maskfile = 'test_mask.nii.gz'
fileio.save_nifti(data, datafile)
fileio.save_nifti(mask, maskfile)


def test_load_response_vars():

# Call the function with the test inputs
Y, volmask,my_str = load_response_vars(datafile, maskfile, vol=True)

# Assert that the function returns the expected results
# This will depend on what you expect the function to return
# For example, you might check that Y and volmask are not None
assert Y is not None
assert volmask is not None
assert my_str == 'test'

0 comments on commit 94a3a63

Please sign in to comment.