-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor test modules #66
Conversation
test/dataform/test_sparse.py
Outdated
[2, 2, 0, 0], | ||
[3, 3, 3, 0]]) | ||
|
||
testdata = load_array('data/array_jl_dense_v1.mat', key='a') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the test code that assumes the existence of some mat files, which are not included in this repository. Do you know what type of dataset we need? > @ShuntaroAoki
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ref. to the original code:
bdpy/test/test_dataform_sparse.py
Lines 65 to 74 in 4e87ee1
def test_load_array_jl(self): | |
data = np.array([[1, 0, 0, 0], | |
[2, 2, 0, 0], | |
[3, 3, 3, 0]]) | |
testdata = load_array('data/array_jl_dense_v1.mat', key='a') | |
np.testing.assert_array_equal(data, testdata) | |
testdata = load_array('data/array_jl_sparse_v1.mat', key='a') | |
np.testing.assert_array_equal(data, testdata) |
Moved Current problem |
I have used the script as follows to prepare model parameter files: import os
import numpy as np
from sklearn.linear_model import LinearRegression
from fastl2lir import FastL2LiR
from bdpy.ml import ModelTraining
X = np.random.rand(100, 500)
Y1dim = np.random.rand(100, 50)
Y4dim = np.random.rand(100, 8, 4, 4)
def run(model_type, format_, chunked):
key = f'{model_type}-{"chunk" if chunked else "nochunk"}-{format_}'
if model_type == 'lir':
model = LinearRegression()
elif model_type == 'fastl2lir':
model = FastL2LiR()
else:
raise ValueError(f'Unknown model type: {model_type}')
Y = Y4dim if chunked else Y1dim
train = ModelTraining(model, X, Y)
train.id = key
if model_type == 'fastl2lir':
train.model_parameters = {'alpha': 100, 'n_feat': 100}
train.dtype = np.float32
if chunked:
train.chunk_axis = 1
train.save_format = 'bdmodel' if format_ == 'bd' else 'pickle'
train.save_path = os.path.join('test/data/test_models', key)
train.run()
run('lir', 'pkl', False)
model_formats = ['pkl', 'bd']
chunked_options = [False, True]
for model_format in model_formats:
for chunked in chunked_options:
run('fastl2lir', model_format, chunked) |
QuestionThe following four files were not found in the current bdpy repository.
@ShuntaroAoki Could you commit them to this branch (or could you tell me how to create these files)? I can handle the modifications to make the current test codes work with the files you commit. Log of the testing==================================================================== short test summary info =====================================================================
FAILED tests/dataform/test_sparse.py::TestSparse::test_load_array_jl - FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = 'data/array_jl_dense_v1.mat', errno = 2, error message = 'No such file or direc...
FAILED tests/evals/test_metrics.py::TestMetrics::test_2d - FileNotFoundError: [Errno 2] No such file or directory: 'data/testdata-2d.pkl.gz'
FAILED tests/evals/test_metrics.py::TestMetrics::test_2d_nan - FileNotFoundError: [Errno 2] No such file or directory: 'data/testdata-2d-nan.pkl.gz'
ERROR tests/test_mri.py::TestMri::test_add_load_epi_pass0001 - FileNotFoundError: [Errno 2] No such file or directory: './data/mri/epi.mat'
ERROR tests/test_mri.py::TestMri::test_get_roiflag_pass0001 - FileNotFoundError: [Errno 2] No such file or directory: './data/mri/epi.mat'
ERROR tests/test_mri.py::TestMri::test_get_roiflag_pass0002 - FileNotFoundError: [Errno 2] No such file or directory: './data/mri/epi.mat'
===================================================== 3 failed, 104 passed, 70 warnings, 3 errors in 32.52s ====================================================== |
Working log on 6/27
|
@ShuntaroAoki I've finished all of the refactoring of the test modules except the epi files. I would appreciate a review when you have time. Thank you. |
Summary
model.pkl
->model.pkl.gz
)reduce the file size-> leave files uncommitted due to lack of timeepi.mat
test
totests
tests/path/to/test_<src>.py
) are now responsible for their corresponding source file (bdpy/path/to/<src>.py
).