Skip to content
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

Last minute update #398

Merged
merged 7 commits into from
Dec 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions syncopy/shared/input_processors.py
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ def process_foi(foi, foilim, samplerate):
else:
try:
array_parser(foi, varname="foi", hasinf=False, hasnan=False,
lims=[0, samplerate/2], dims=(None,))
lims=[0, samplerate / 2], dims=(None,))
except Exception as exc:
raise exc
foi = np.array(foi, dtype="float")
@@ -145,11 +145,12 @@ def process_foi(foi, foilim, samplerate):
raise SPYValueError(legal="'all' or `None` or `[fmin, fmax]`",
varname="foilim", actual=foilim)
else:
try:
array_parser(foilim, varname="foilim", hasinf=False, hasnan=False,
lims=[0, samplerate/2], dims=(2,))
except Exception as exc:
raise exc
array_parser(foilim, varname="foilim", hasinf=False, hasnan=False,
lims=[0, samplerate / 2], dims=(2,))

# QUICKFIX for #392
foilim = [float(f) for f in foilim]

# foilim is of shape (2,)
if foilim[0] > foilim[1]:
msg = "Sorting foilim low to high.."
@@ -174,7 +175,7 @@ def process_taper(taper,
For multi-tapering with slepian tapers the default is to max out
`nTaper` to achieve the desired frequency smoothing bandwidth.
For details about the Slepion settings see
For details about the Slepian settings see
"The Effective Bandwidth of a Multitaper Spectral Estimator,
A. T. Walden, E. J. McCoy and D. B. Percival"
@@ -299,7 +300,6 @@ def process_taper(taper,
maxBw = np.min([samplerate / 2 - 1 / nSamples,
samplerate * (nSamples + 1) / (2 * nSamples)])
# -----------------------------------


try:
scalar_parser(tapsmofrq, varname="tapsmofrq", lims=[0, np.inf])
@@ -316,12 +316,12 @@ def process_taper(taper,
msg = f'Setting tapsmofrq to the maximal attainable bandwidth of {maxBw:.2f}Hz'
SPYInfo(msg)
tapsmofrq = maxBw

# --------------------------------------------------------------
# set parameters for scipy.signal.windows.dpss
NW, Kmax = _get_dpss_pars(tapsmofrq, nSamples, samplerate)
# --------------------------------------------------------------

# tapsmofrq too large
# if Kmax > nSamples or NW > nSamples / 2:

1 change: 0 additions & 1 deletion syncopy/specest/freqanalysis.py
Original file line number Diff line number Diff line change
@@ -328,7 +328,6 @@ def freqanalysis(data, method='mtmfft', output='pow',
numpy.fft.fft : NumPy's reference FFT implementation
scipy.signal.stft : SciPy's Short Time Fourier Transform
"""

# Make sure our one mandatory input object can be processed
try:
data_parser(data, varname="data", dataclass="AnalogData",
10 changes: 8 additions & 2 deletions syncopy/tests/test_connectivity.py
Original file line number Diff line number Diff line change
@@ -446,7 +446,6 @@ def test_coh_selections(self):
result_spec = cafunc(self.spec, method='coh', select=selections[0])
assert np.allclose(result_ad.trials[0], result_spec.trials[0], atol=1e-3)


def test_coh_foi(self):

# 2 frequencies
@@ -457,10 +456,17 @@ def test_coh_foi(self):
assert np.all(np.isfinite(result.data))
assert np.all(result.data[0, ...] >= -1e-10)

# make sure out-of-range foi selections are detected
# make sure out-of-range foilim are detected
with pytest.raises(SPYValueError, match='foilim'):
result = cafunc(self.data, method='coh', foilim=[-1, 70])

# make sure invalid foilim are detected
with pytest.raises(SPYValueError, match='foilim'):
result = cafunc(self.data, method='coh', foilim=[None, None])

with pytest.raises(SPYValueError, match='foilim'):
result = cafunc(self.data, method='coh', foilim='abc')

def test_coh_cfg(self):

call = lambda cfg: cafunc(self.data, cfg)