Skip to content

Commit

Permalink
Set LSB=1 only if dtype is integer
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Jul 18, 2022
1 parent 55d9572 commit eb54e8c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions MEArec/generators/recgensteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
Important:
When tmp_mode=='memmap' : theses functions must assign and add directly the buffer.
When tmp_mode is Noe : theses functions return the buffer and the assignament is done externally.
When tmp_mode=='memmap' : these functions must assign and add directly the buffer.
When tmp_mode is None : these functions return the buffer and the assignament is done externally.
Expand Down
4 changes: 1 addition & 3 deletions MEArec/generators/recordinggenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def generate_recordings(self, tmp_mode=None, tmp_folder=None, n_jobs=0, template
adc_bit_depth = params['recordings']['adc_bit_depth']
params['recordings']['lsb'] = rec_params.get('lsb', None)
lsb = params['recordings']['lsb']
if lsb is None:
if lsb is None and np.dtype(dtype).kind == "i":
lsb = 1
params['recordings']['gain'] = rec_params.get('gain', None)
gain = params['recordings']['gain']
Expand Down Expand Up @@ -1381,8 +1381,6 @@ def run_several_chunks(func, chunk_indexes, fs, lsb, args, n_jobs, tmp_mode, ass
or in paralell if n_jobs>1
The function can return
"""

# create task list
Expand Down
21 changes: 14 additions & 7 deletions MEArec/tests/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
else:
use_loader = False

LOCAL_TMP = True
DEBUG = False

if DEBUG:
import matplotlib.pyplot as plt
plt.ion()
plt.show()


class TestGenerators(unittest.TestCase):
Expand All @@ -36,7 +41,7 @@ def setUpClass(self):
# Set seed
np.random.seed(2308)

if not LOCAL_TMP:
if not DEBUG:
self.test_dir = Path(tempfile.mkdtemp())
else:
self.test_dir = Path('./tmp').absolute()
Expand Down Expand Up @@ -100,7 +105,7 @@ def setUpClass(self):
@classmethod
def tearDownClass(self):
# Remove the directory after the test
if not LOCAL_TMP:
if not DEBUG:
shutil.rmtree(self.test_dir)

def test_gen_templates(self):
Expand Down Expand Up @@ -693,28 +698,30 @@ def test_recordings_backend(self):
rec_params['spiketrains']['n_exc'] = ne
rec_params['spiketrains']['n_inh'] = ni
rec_params['spiketrains']['duration'] = duration
n_jitter = 2
n_jitter = 10
rec_params['templates']['n_jitters'] = n_jitter
rec_params['recordings']['modulation'] = 'none'
rec_params['recordings']['filter'] = False


rec_params['seeds']['templates'] = 0
rec_params['seeds']['spiketrains'] = 0
rec_params['seeds']['convolution'] = 0
rec_params['seeds']['noise'] = 0


n_jobs = [1, 2]
chunk_durations = [0, 1]

for n in n_jobs:
for ch in chunk_durations:
print('Test recording backend with', n, 'jobs - chunk', ch)
rec_params['chunk_duration'] = n
rec_params['recordings']['chunk_duration'] = ch

recgen_memmap = mr.gen_recordings(params=rec_params, tempgen=self.tempgen, tmp_mode='memmap',
verbose=False, n_jobs=n)
recgen_np = mr.gen_recordings(params=rec_params, tempgen=self.tempgen, tmp_mode=None, verbose=False,
n_jobs=n)

assert np.allclose(np.array(recgen_np.recordings), recgen_memmap.recordings.copy(), atol=1e-4)
del recgen_memmap, recgen_np

Expand Down Expand Up @@ -955,4 +962,4 @@ def test_simulate_cell(self):
TestGenerators().setUpClass()
# TestGenerators().test_gen_recordings_drift()
# TestGenerators().test_default_params()
TestGenerators().test_recording_custom_drifts()
TestGenerators().test_recordings_backend()
2 changes: 1 addition & 1 deletion MEArec/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '1.8.0.dev0'
version = '1.8.0'

0 comments on commit eb54e8c

Please sign in to comment.