Skip to content

Commit

Permalink
Merge pull request #195 from esi-neuroscience/dev
Browse files Browse the repository at this point in the history
Name Space Acrobatics
  • Loading branch information
pantaray authored Jan 28, 2022
2 parents f52d8d6 + 46bfd6a commit 91d81bf
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 80 deletions.
6 changes: 5 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ intellinux:
GIT_FETCH_EXTRA_FLAGS: --tags
NO_SLURM: "true"
script:
- rm -rf ~/.spy
- source $HOME/miniconda/etc/profile.d/conda.sh
- conda env update -f syncopy.yml --prune
- conda activate syncopy
- tox
- tox -p 0

powerlinux:
stage: tox
Expand All @@ -34,6 +35,7 @@ powerlinux:
PYTEST_ADDOPTS: "--color=yes --tb=short --verbose"
GIT_FETCH_EXTRA_FLAGS: --tags
script:
- rm -rf ~/.spy
- source /opt/conda/etc/profile.d/conda.sh
- conda env update -f syncopy.yml --prune
- conda activate syncopy
Expand Down Expand Up @@ -67,6 +69,8 @@ m1macos:
PYTEST_ADDOPTS: "--color=yes --tb=short --verbose"
GIT_FETCH_EXTRA_FLAGS: --tags
script:
- ulimit -n 25000
- rm -rf ~/.spy
- source /opt/conda/etc/profile.d/conda.sh
- conda env update -f syncopy.yml --prune
- conda activate syncopy
Expand Down
6 changes: 3 additions & 3 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ authors:
Planck Society
family-names: Fries
given-names: Pascal
orcid: https://orcid.org/0000-0002-4270-1468
orcid: https://orcid.org/0000-0002-4270-1468
license: BSD-3-Clause
keywords:
- large-scale electrophysiology
Expand All @@ -37,5 +37,5 @@ keywords:
- spectral-methods
- brain
repository-code: https://github.com/esi-neuroscience/syncopy
version: 0.1b3.dev1+g7bd5bf1.d20210118
date-released: '2021-01-18'
version: 0.1b3.dev287
date-released: '2022-01-19'
2 changes: 1 addition & 1 deletion syncopy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- numpy >= 1.10, < 2.0
- scipy >= 1.5
- h5py >= 2.9, < 3
- matplotlib >= 3.3, < 3.5
- matplotlib >= 3.3, <= 3.5
- tqdm >= 4.31
- natsort
# Optional packages required for running the test-suite and building the HTML docs
Expand Down
8 changes: 7 additions & 1 deletion syncopy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,16 @@
__checksum_algorithm__ = sha1

# Fill up namespace
from . import shared, io, datatype, specest, statistics, plotting
from . import (
shared,
io,
datatype)

from .shared import *
from .io import *
from .datatype import *
from .specest import *
from .nwanalysis import *
from .statistics import *
from .plotting import *

Expand All @@ -111,5 +116,6 @@
__all__.extend(io.__all__)
__all__.extend(shared.__all__)
__all__.extend(specest.__all__)
__all__.extend(nwanalysis.__all__)
__all__.extend(statistics.__all__)
__all__.extend(plotting.__all__)
12 changes: 0 additions & 12 deletions syncopy/connectivity/__init__.py

This file was deleted.

File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions syncopy/nwanalysis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
#
# Populate namespace with user exposed
# connectivity methods
#

from .connectivity_analysis import connectivityanalysis

# Populate local __all__ namespace
# with the user-exposed frontend
__all__ = ['connectivityanalysis']
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
from .ST_compRoutines import ST_CrossSpectra, ST_CrossCovariance
from .AV_compRoutines import NormalizeCrossSpectra, NormalizeCrossCov, GrangerCausality

__all__ = ["connectivity"]

availableMethods = ("coh", "corr", "granger")


@unwrap_cfg
@unwrap_select
@detect_parallel_client
def connectivity(data, method="coh", keeptrials=False, output="abs",
foi=None, foilim=None, pad_to_length=None,
polyremoval=None, taper="hann", tapsmofrq=None,
nTaper=None, out=None, **kwargs):
def connectivityanalysis(data, method="coh", keeptrials=False, output="abs",
foi=None, foilim=None, pad_to_length=None,
polyremoval=None, taper="hann", tapsmofrq=None,
nTaper=None, out=None, **kwargs):

"""
Perform connectivity analysis of Syncopy :class:`~syncopy.AnalogData` objects
Expand Down Expand Up @@ -139,7 +139,7 @@ def connectivity(data, method="coh", keeptrials=False, output="abs",
timeAxis = data.dimord.index("time")

# Get everything of interest in local namespace
defaults = get_defaults(connectivity)
defaults = get_defaults(connectivityanalysis)
lcls = locals()
# check for ineffective additional kwargs
check_passed_kwargs(lcls, defaults, frontend_name="connectivity")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 3 additions & 5 deletions syncopy/specest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
#

# Import __all__ routines from local modules
from .freqanalysis import *
from .freqanalysis import __all__ as _all_
from .freqanalysis import freqanalysis

# Populate local __all__ namespace
__all__ = []
__all__.extend(_all_)

# with the user-exposed frontend
__all__ = ['freqanalysis']
2 changes: 0 additions & 2 deletions syncopy/specest/freqanalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
MultiTaperFFTConvol
)

__all__ = ["freqanalysis"]


@unwrap_cfg
@unwrap_select
Expand Down
8 changes: 4 additions & 4 deletions syncopy/tests/backend/test_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import matplotlib.pyplot as ppl

from syncopy.tests import synth_data
from syncopy.connectivity import csd
from syncopy.connectivity import ST_compRoutines as stCR
from syncopy.connectivity.wilson_sf import wilson_sf, regularize_csd
from syncopy.connectivity.granger import granger
from syncopy.nwanalysis import csd
from syncopy.nwanalysis import ST_compRoutines as stCR
from syncopy.nwanalysis.wilson_sf import wilson_sf, regularize_csd
from syncopy.nwanalysis.granger import granger


def test_coherence():
Expand Down
2 changes: 1 addition & 1 deletion syncopy/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"the limit using, e.g., `ulimit -Sn 1024`"
raise ValueError(msg)
if is_slurm_node():
cluster = esi_cluster_setup(partition="8GBS", n_jobs=10,
cluster = esi_cluster_setup(partition="8GB", n_jobs=10,
timeout=360, interactive=False,
start_client=False)
else:
Expand Down
13 changes: 0 additions & 13 deletions syncopy/tests/local_spy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@
from syncopy.tests import synth_data


def call_con(data, method, **kwargs):

res = spy.connectivity(data=data,
method=method,
**kwargs)
return res


def call_freq(data, method, **kwargs):
res = spy.freqanalysis(data=data, method=method, **kwargs)

return res


# Prepare code to be executed using, e.g., iPython's `%run` magic command
if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions syncopy/tests/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ def figs_equal(fig1, fig2, tol=None):
True
"""
plt.draw_all(force=True)
with tempfile.NamedTemporaryFile(suffix='.png') as img1:
with tempfile.NamedTemporaryFile(suffix='.png') as img2:
with tempfile.NamedTemporaryFile(suffix=".png", mode="w") as img1:
with tempfile.NamedTemporaryFile(suffix=".png", mode="w") as img2:
fig1.savefig(img1.name)
fig2.savefig(img2.name)
if tol is None:
Expand Down
Empty file modified syncopy/tests/no_slurm.sh
100644 → 100755
Empty file.
55 changes: 28 additions & 27 deletions syncopy/tests/test_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
from syncopy import __acme__
if __acme__:
import dask.distributed as dd
from syncopy.datatype import AnalogData
from syncopy.connectivity import connectivity

from syncopy import AnalogData
from syncopy import connectivityanalysis as ca
import syncopy.tests.synth_data as synth_data
from syncopy.shared.errors import SPYValueError, SPYTypeError
from syncopy.shared.tools import get_defaults
Expand Down Expand Up @@ -65,8 +66,8 @@ class TestGranger:

def test_gr_solution(self, **kwargs):

Gcaus = connectivity(self.data, method='granger', taper='dpss',
tapsmofrq=3, foi=self.foi, **kwargs)
Gcaus = ca(self.data, method='granger', taper='dpss',
tapsmofrq=3, foi=self.foi, **kwargs)

# check all channel combinations with coupling
for i, j in zip(*self.cpl_idx):
Expand Down Expand Up @@ -96,24 +97,24 @@ def test_gr_selections(self):

for sel_dct in selections:

Gcaus = connectivity(self.data, method='granger', select=sel_dct)
Gcaus = ca(self.data, method='granger', select=sel_dct)

# check here just for finiteness and positivity
assert np.all(np.isfinite(Gcaus.data))
assert np.all(Gcaus.data[0, ...] >= -1e-10)

def test_gr_foi(self):

call = lambda foi, foilim: connectivity(self.data,
method='granger',
foi=foi,
foilim=foilim)
call = lambda foi, foilim: ca(self.data,
method='granger',
foi=foi,
foilim=foilim)

run_foi_test(call, foilim=[0, 70])

def test_gr_cfg(self):

call = lambda cfg: connectivity(self.data, cfg)
call = lambda cfg: ca(self.data, cfg)
run_cfg_test(call, method='granger')

@skip_without_acme
Expand Down Expand Up @@ -175,13 +176,13 @@ class TestCoherence:

def test_coh_solution(self, **kwargs):

res = connectivity(data=self.data,
method='coh',
foilim=[5, 60],
output='pow',
taper='dpss',
tapsmofrq=1.5,
**kwargs)
res = ca(data=self.data,
method='coh',
foilim=[5, 60],
output='pow',
taper='dpss',
tapsmofrq=1.5,
**kwargs)

# coherence at the harmonic frequencies
idx_f1 = np.argmin(res.freq < self.f1)
Expand Down Expand Up @@ -209,24 +210,24 @@ def test_coh_selections(self):

for sel_dct in selections:

result = connectivity(self.data, method='coh', select=sel_dct)
result = ca(self.data, method='coh', select=sel_dct)

# check here just for finiteness and positivity
assert np.all(np.isfinite(result.data))
assert np.all(result.data[0, ...] >= -1e-10)

def test_coh_foi(self):

call = lambda foi, foilim: connectivity(self.data,
method='coh',
foi=foi,
foilim=foilim)
call = lambda foi, foilim: ca(self.data,
method='coh',
foi=foi,
foilim=foilim)

run_foi_test(call, foilim=[0, 70])

def test_coh_cfg(self):

call = lambda cfg: connectivity(self.data, cfg)
call = lambda cfg: ca(self.data, cfg)
run_cfg_test(call, method='coh')

@skip_without_acme
Expand Down Expand Up @@ -285,7 +286,7 @@ class TestCorrelation:

def test_corr_solution(self, **kwargs):

corr = connectivity(data=self.data, method='corr', **kwargs)
corr = ca(data=self.data, method='corr', **kwargs)

# test 0-lag autocorr is 1 for all channels
assert np.all(corr.data[0, 0].diagonal() > .99)
Expand Down Expand Up @@ -366,14 +367,14 @@ def test_corr_selections(self):

for sel_dct in selections:

result = connectivity(self.data, method='corr', select=sel_dct)
result = ca(self.data, method='corr', select=sel_dct)

# check here just for finiteness and positivity
assert np.all(np.isfinite(result.data))

def test_corr_cfg(self):

call = lambda cfg: connectivity(self.data, cfg)
call = lambda cfg: ca(self.data, cfg)
run_cfg_test(call, method='corr', positivity=False)

@skip_without_acme
Expand Down Expand Up @@ -459,7 +460,7 @@ def run_polyremoval_test(call):

def run_cfg_test(call, method, positivity=True):

cfg = get_defaults(connectivity)
cfg = get_defaults(ca)

cfg.method = method
cfg.foilim = [0, 70]
Expand Down
1 change: 1 addition & 0 deletions syncopy/tests/test_packagesetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def test_cleanup():

# now kill 2nd instance and wipe `tmpDir`
process2.kill()
time.sleep(1)
shutil.rmtree(tmpDir)
del os.environ["SPYTMPDIR"]
time.sleep(1)
2 changes: 1 addition & 1 deletion syncopy/tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

@skip_without_plt
@skip_with_acme
@pytest.mark.xfail(reason="figure comparison breaks sometimes", strict=False)
class TestAnalogDataPlotting():

nChannels = 16
Expand Down Expand Up @@ -61,7 +62,6 @@ class TestAnalogDataPlotting():
channels = ["all", [14, 13, 12, 12, 15]]
toilim = [None, [1.9, 2.5], [2.1, np.inf]]

# trlToilim = lambda self, trl, tlim: None if trl is None else tlim

def test_singlepanelplot(self):

Expand Down
2 changes: 1 addition & 1 deletion syncopy/tests/test_specest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# Local imports
from syncopy.tests.misc import generate_artificial_data, flush_local_cluster
from syncopy.specest.freqanalysis import freqanalysis
from syncopy import freqanalysis
from syncopy.shared.errors import SPYValueError
from syncopy.datatype.base_data import VirtualData, Selector
from syncopy.datatype import AnalogData, SpectralData
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ deps =
conda_deps=
scipy15: scipy >= 1.5
acme: esi-acme
matplotlib >= 3.3, < 3.5
conda_channels=
defaults
conda-forge
Expand Down

0 comments on commit 91d81bf

Please sign in to comment.