-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,841 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Project Tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
strategy: | ||
matrix: | ||
python-version: ["3.6"] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
miniconda-version: "latest" | ||
activate-environment: rec_to_binaries | ||
environment-file: environment.yml | ||
- run: mkdir -p ~/SpikeGadgets | ||
- run: python -m pytest rec_to_binaries/test/e2etests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
abc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# __init__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pytest | ||
import os | ||
|
||
CURRENT_DIRECTORY = os.getcwd() | ||
|
||
def _clear_file_content(file_path): | ||
if file_path is None or file_path.strip() == '': | ||
raise FileNotFoundError | ||
with open(file_path, 'r+') as file: | ||
file.truncate(0) | ||
|
||
@pytest.fixture | ||
def e2etests_directory_path(): | ||
return f'{CURRENT_DIRECTORY}/rec_to_binaries/test/e2etests/' | ||
|
||
@pytest.fixture | ||
def current_directory(): | ||
return CURRENT_DIRECTORY | ||
|
||
@pytest.fixture | ||
def clear_file_content(): | ||
return _clear_file_content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pytest | ||
import numpy as np | ||
from rec_to_binaries.adjust_timestamps import ( | ||
fix_timestamp_lag, | ||
) | ||
|
||
@pytest.mark.skip(reason='not implemented') | ||
def test_fix_timestamp_lag_check_if_data_is_written_no_systime(e2etests_directory_path, clear_file_content): | ||
# # arrange | ||
# file_path = f'{e2etests_directory_path}/test_data/fix_timestamp_lag_check_if_data_is_written_no_systime.txt' | ||
# clear_file_content(file_path) | ||
# fake_data = np.array([ | ||
# ('just', 1), | ||
# ('another', 2), | ||
# ('part', 3)], dtype=[('one', 'b1'), ('two', '<b1')] | ||
# ) | ||
# with open(file_path, "wb") as file: | ||
# file.write(bytes(b'<Start settings>')) | ||
# file.write(bytes(b'\n')) | ||
# file.write(b'data: ') | ||
# file.write(fake_data) | ||
# file.write(bytes(b'\n')) | ||
# file.write(bytes(b'<End settings>')) | ||
|
||
# fix_timestamp_lag(file_path) | ||
# # act | ||
|
||
# # assert | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import pytest | ||
from rec_to_binaries.binary_utils import ( | ||
TrodesBinaryFormatError, | ||
TrodesBinaryReader, | ||
TrodesLFPBinaryLoader, | ||
TrodesTimestampBinaryLoader, | ||
TrodesSpikeBinaryLoader, | ||
TrodesPosBinaryLoader, | ||
TrodesDIOBinaryLoader, | ||
) | ||
|
||
def test_TrodesBinaryReader_first_line_not_Start_settings_error(e2etests_directory_path): | ||
file_path = f'{e2etests_directory_path}/test_data/TrodesBinaryReader_test_first_line_exception.txt' | ||
|
||
with pytest.raises(TrodesBinaryFormatError) as ex: | ||
trodes_binary_reader = TrodesBinaryReader(file_path) | ||
|
||
|
||
def test_TrodesBinaryReader_more_than_1000_length_error(e2etests_directory_path): | ||
file_path = f'{e2etests_directory_path}/test_data/TrodesBinaryReader_test_more_than_1000_line_exception.txt' | ||
|
||
with pytest.raises(TrodesBinaryFormatError): | ||
trodes_binary_reader = TrodesBinaryReader(file_path) | ||
|
||
def test_TrodesBinaryReader_check_if_valid_file_is_read(e2etests_directory_path): | ||
file_path = f'{e2etests_directory_path}/test_data/TrodesBinaryReader_check_if_valid_file_is_read.txt' | ||
trodes_binary_reader = TrodesBinaryReader(file_path) | ||
|
||
assert trodes_binary_reader.data_start_byte == 43 | ||
assert trodes_binary_reader.header_params == {'a': '1', 'data': '2'} | ||
|
||
def test_TrodesLFPBinaryLoader_check_if_file_can_be_read(e2etests_directory_path): | ||
file_path = f'{e2etests_directory_path}/test_data/TrodesLFPBinaryLoader_test_file_read.txt' | ||
trodes_LFP_binary_loader = TrodesLFPBinaryLoader(file_path) | ||
|
||
assert trodes_LFP_binary_loader.header_params['Original_file'] == 'test_Original_file' | ||
assert trodes_LFP_binary_loader.header_params['Trode_ID'] == 'test_Trode_ID' | ||
assert trodes_LFP_binary_loader.header_params['Trode_channel'] == 'test_Trode_channel' | ||
assert trodes_LFP_binary_loader.header_params['Clock rate'] == 'test_Clock rate' | ||
assert trodes_LFP_binary_loader.header_params['Voltage_scaling'] == 'test_Voltage_scaling' | ||
assert trodes_LFP_binary_loader.header_params['Decimation'] == 'test_Decimation' | ||
assert trodes_LFP_binary_loader.header_params['First_timestamp'] == 'test_First_timestamp' | ||
assert trodes_LFP_binary_loader.header_params['Reference'] == 'test_Reference' | ||
assert trodes_LFP_binary_loader.header_params['Low_pass_filter'] == 'test_Low_pass_filter' | ||
assert trodes_LFP_binary_loader.header_params['Fields'] == 'test_Fields' | ||
|
||
def test_TrodesTimestampBinaryLoader_check_if_file_can_be_read(e2etests_directory_path): | ||
file_path = f'{e2etests_directory_path}/test_data/TrodesTimestampBinaryLoader_test_file_read.txt' | ||
trodes_timestamp_binary_loader = TrodesTimestampBinaryLoader(file_path) | ||
|
||
assert trodes_timestamp_binary_loader.header_params['Byte_order'] == 'test_Byte_order' | ||
assert trodes_timestamp_binary_loader.header_params['Original_file'] == 'test_Original_file' | ||
assert trodes_timestamp_binary_loader.header_params['Clock rate'] == 'test_Clock rate' | ||
assert trodes_timestamp_binary_loader.header_params['Decimation'] == 'test_Decimation' | ||
assert trodes_timestamp_binary_loader.header_params['Time_offset'] == 'test_Time_offset' | ||
assert trodes_timestamp_binary_loader.header_params['Fields'] == 'test_Fields' | ||
|
||
def test_TrodesSpikeBinaryLoader_check_if_data_file_is_read(e2etests_directory_path): | ||
file_path = f'{e2etests_directory_path}/test_data/TrodesSpikeBinaryLoader_test_file_read.txt' | ||
trodes_spike_binary_loader = TrodesSpikeBinaryLoader(file_path) | ||
|
||
|
||
assert trodes_spike_binary_loader.header_params['Original_file'] == 'test_Original_file' | ||
assert trodes_spike_binary_loader.header_params['nTrode_ID'] == '1' | ||
assert trodes_spike_binary_loader.num_channels == 10 | ||
assert trodes_spike_binary_loader.header_params['Clock rate'] == '3' | ||
assert trodes_spike_binary_loader.header_params['Voltage_scaling'] == 'v' | ||
assert trodes_spike_binary_loader.header_params['Time_offset'] == '4' | ||
assert trodes_spike_binary_loader.header_params['Threshold'] == '5' | ||
assert trodes_spike_binary_loader.header_params['Spike_invert'] == 't' | ||
assert trodes_spike_binary_loader.header_params['Reference'] == '6' | ||
assert trodes_spike_binary_loader.header_params['ReferenceNTrode'] == '7' | ||
assert trodes_spike_binary_loader.header_params['ReferenceChannel'] == '8' | ||
assert trodes_spike_binary_loader.header_params['Filter'] == 't' | ||
assert trodes_spike_binary_loader.header_params['lowPassFilter'] == 'y' | ||
assert trodes_spike_binary_loader.header_params['highPassFilter'] == 'n' | ||
assert trodes_spike_binary_loader.header_params['Fields'] == 'test_field' | ||
assert trodes_spike_binary_loader.spike_rec_size == 804 | ||
|
||
@pytest.mark.skip(reason="I have to figure out why pos_list stays empty") | ||
def test_TrodesPosBinaryLoader_check_if_data_file_is_read(e2etests_directory_path): | ||
file_path = f'{e2etests_directory_path}/test_data/TrodesPosBinaryLoader_check_if_data_file_is_read.txt' | ||
trodes_pos_binary_loader = TrodesPosBinaryLoader(file_path) | ||
|
||
breakpoint() | ||
|
||
assert trodes_pos_binary_loader.header_params['threshold'] == 'test_threshold' | ||
assert trodes_pos_binary_loader.header_params['dark'] == 'test_dark' | ||
assert trodes_pos_binary_loader.header_params['clockrate'] == 'test_clockrate' | ||
assert trodes_pos_binary_loader.header_params['field_str'] == 'test_Fields' | ||
assert trodes_pos_binary_loader.rec_size == 12 | ||
assert trodes_pos_binary_loader.unpack_format == 'IHHHH' | ||
|
||
@pytest.mark.skip(reason="I have to figure out why pos_list stays empty") | ||
def test_TrodesDIOBinaryLoader_check_if_data_file_is_read(e2etests_directory_path): | ||
file_path = f'{e2etests_directory_path}/test_data/TrodesPosBinaryLoader_check_if_data_file_is_read.txt' | ||
trodes_pos_binary_loader = TrodesDIOBinaryLoader(file_path) | ||
|
||
assert True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import pytest | ||
from rec_to_binaries.core import ( | ||
extract_trodes_rec_file, | ||
convert_binaries_to_hdf5, | ||
) | ||
|
||
@pytest.mark.skip(reason='Got to figure out the many cases') | ||
def extract_trodes_rec_file(): | ||
pass | ||
|
||
@pytest.mark.skip(reason='Got to figure out - type object \'object\' has no attribute \'dtype') | ||
def test_convert_binaries_to_hdf5_rec_file_write_to_file(e2etests_directory_path): | ||
data_dir = e2etests_directory_path | ||
animal = 'test_animal' | ||
convert_binaries_to_hdf5(data_dir, | ||
animal, | ||
out_dir=None, | ||
dates=None, | ||
parallel_instances=1, | ||
convert_dio=False, | ||
convert_lfp=False, | ||
convert_pos=False, | ||
convert_spike=False | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pytest | ||
|
||
@pytest.mark.skip(reason='not implemented') | ||
def test_infer_systime(): | ||
pass | ||
|
||
@pytest.mark.skip(reason='not implemented') | ||
def test_create_systime(): | ||
pass |
4 changes: 4 additions & 0 deletions
4
rec_to_binaries/test/e2etests/test_data/TrodesBinaryReader_check_if_valid_file_is_read.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<Start settings> | ||
a:1 | ||
data:2 | ||
<End settings> |
1 change: 1 addition & 0 deletions
1
rec_to_binaries/test/e2etests/test_data/TrodesBinaryReader_test_first_line_exception.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<test> |
Oops, something went wrong.