Skip to content

Commit

Permalink
Merge pull request #41 from neurolib-dev/fix/python3.6_imports
Browse files Browse the repository at this point in the history
Fix/python3.6 imports
  • Loading branch information
caglorithm authored Feb 25, 2020
2 parents 860b534 + 4296234 commit 409ce43
Show file tree
Hide file tree
Showing 34 changed files with 202 additions and 203 deletions.
34 changes: 33 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
language: python

os:
- linux

python:
- "3.6"
- "3.7"
- "3.8"

install:
- pip install -r requirements.txt
- pip install pytest flake8 codecov pytest-cov
- pip install pytest flake8 codecov pytest-cov wheel setuptools
- pip install jupyterlab nbconvert nbformat matplotlib seaborn mne
- python setup.py sdist bdist_wheel
- pip install --upgrade dist/*
Expand All @@ -16,3 +21,30 @@ script:

after_success:
- codecov

jobs:
allow_failures:
- os: osx
- os: windows

include:
- stage: test
os: osx
language: sh
addons:
homebrew:
update: false
packages: python3
before_install:
- pip install virtualenv
- virtualenv -p python3 ~/venv
- source ~/venv/bin/activate

# - stage: test
# os: windows
# language: sh
# env:
# - PATH="/c/Python37:/c/Python37/Scripts:$PATH"
# before_install:
# - choco install python --version 3.7.3
# - python -m pip install --upgrade pip
90 changes: 56 additions & 34 deletions README.md

Large diffs are not rendered by default.

96 changes: 0 additions & 96 deletions README_pypi.md

This file was deleted.

2 changes: 1 addition & 1 deletion examples/example-1.1-custom-parameter-exploration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"source": [
"parameters = ParameterSpace({\"x\": np.linspace(-2, 2, 2), \"y\": np.linspace(-2, 2, 2)})\n",
"# info: chose np.linspace(-2, 2, 40) or more, values here are low for testing\n",
"search = BoxSearch(evalFunction = explore_me, exploreParameters = parameters)"
"search = BoxSearch(evalFunction = explore_me, parameterSpace = parameters)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/example-1.2-brain-network-exploration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"source": [
"parameters = ParameterSpace({\"mue_ext_mean\": np.linspace(0, 3.0, 2), \"mui_ext_mean\": np.linspace(0, 3.0, 2)})\n",
"# info: chose np.linspace(0, 3, 21) or more, values here are low for testing\n",
"search = BoxSearch(evalFunction = evaluateSimulation, model=aln, exploreParameters=parameters)"
"search = BoxSearch(evalFunction = evaluateSimulation, model=aln, parameterSpace=parameters)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion neurolib/models/aln/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from neurolib.models.aln.model import ALNModel
from .model import ALNModel
2 changes: 1 addition & 1 deletion neurolib/models/aln/loadDefaultParams.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import h5py

from neurolib.utils.collections import dotdict
from ...utils.collections import dotdict


def loadDefaultParams(Cmat=None, Dmat=None, lookupTableFileName=None, seed=None):
Expand Down
6 changes: 3 additions & 3 deletions neurolib/models/aln/model.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np

import neurolib.models.aln.loadDefaultParams as dp
import neurolib.models.aln.timeIntegration as ti
from neurolib.models.model import Model
from . import loadDefaultParams as dp
from . import timeIntegration as ti
from ..model import Model


class ALNModel(Model):
Expand Down
2 changes: 1 addition & 1 deletion neurolib/models/aln/timeIntegration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import numba

import neurolib.models.aln.loadDefaultParams as dp
from . import loadDefaultParams as dp


def timeIntegration(params):
Expand Down
4 changes: 2 additions & 2 deletions neurolib/models/bold/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from neurolib.models.bold.model import BOLDModel
from neurolib.models.bold.timeIntegration import simulateBOLD
from .model import BOLDModel
from .timeIntegration import simulateBOLD
2 changes: 1 addition & 1 deletion neurolib/models/bold/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from neurolib.models.bold.timeIntegration import simulateBOLD
from .timeIntegration import simulateBOLD


class BOLDModel:
Expand Down
5 changes: 2 additions & 3 deletions neurolib/models/bold/timeIntegration.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ def simulateBOLD(Z, dt, voxelCounts, X=None, F=None, Q=None, V=None):

N = np.shape(Z)[0]

if not "voxelCounts" in globals():
if "voxelCounts" not in globals():
voxelCounts = np.ones((N,))

voxelCountsSqrtInv = 1 / np.sqrt(voxelCounts)

# Balloon-Windkessel model parameters (Deco 2013, Friston 2003):
# Note: the distribution of each Balloon-Windkessel models parameters are given per voxel
# Since we usually average the empirical fMRI of each voxel for a given area, the standard
# deviation of the gaussian distribution should be divided by the number of voxels in each area
# voxelCountsSqrtInv = 1 / np.sqrt(voxelCounts)
#
# rho = np.random.normal(0.34, np.sqrt(0.0024) / np.sqrt( sum(voxelCounts) ) ) # Capillary resting net oxygen extraction
# alpha = np.random.normal(0.32, np.sqrt(0.0015) / np.sqrt( sum(voxelCounts) ) ) # Grubb's vessel stiffness exponent
Expand Down
2 changes: 1 addition & 1 deletion neurolib/models/fhn/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from neurolib.models.fhn.model import FHNModel
from .model import FHNModel
2 changes: 1 addition & 1 deletion neurolib/models/fhn/loadDefaultParams.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from neurolib.utils.collections import dotdict
from ...utils.collections import dotdict


def loadDefaultParams(Cmat=None, Dmat=None, seed=None):
Expand Down
6 changes: 3 additions & 3 deletions neurolib/models/fhn/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import neurolib.models.fhn.loadDefaultParams as dp
import neurolib.models.fhn.timeIntegration as ti
from neurolib.models.model import Model
from . import loadDefaultParams as dp
from . import timeIntegration as ti
from ..model import Model


class FHNModel(Model):
Expand Down
2 changes: 1 addition & 1 deletion neurolib/models/fhn/timeIntegration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import numba

import neurolib.models.hopf.loadDefaultParams as dp
from . import loadDefaultParams as dp


def timeIntegration(params):
Expand Down
2 changes: 1 addition & 1 deletion neurolib/models/hopf/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from neurolib.models.hopf.model import HopfModel
from .model import HopfModel
2 changes: 1 addition & 1 deletion neurolib/models/hopf/loadDefaultParams.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from neurolib.utils.collections import dotdict
from ...utils.collections import dotdict


def loadDefaultParams(Cmat=None, Dmat=None, seed=None):
Expand Down
6 changes: 3 additions & 3 deletions neurolib/models/hopf/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import neurolib.models.hopf.loadDefaultParams as dp
import neurolib.models.hopf.timeIntegration as ti
from neurolib.models.model import Model
from . import loadDefaultParams as dp
from . import timeIntegration as ti
from ..model import Model


class HopfModel(Model):
Expand Down
2 changes: 1 addition & 1 deletion neurolib/models/hopf/timeIntegration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import numba

import neurolib.models.hopf.loadDefaultParams as dp
from . import loadDefaultParams as dp


def timeIntegration(params):
Expand Down
4 changes: 2 additions & 2 deletions neurolib/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import xarray as xr
import numpy as np

from neurolib.models import bold
from ..models import bold

from neurolib.utils.collections import dotdict
from ..utils.collections import dotdict


class Model:
Expand Down
2 changes: 1 addition & 1 deletion neurolib/optimize/evolution/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from neurolib.optimize.evolution.evolution import Evolution
from .evolution import Evolution
8 changes: 4 additions & 4 deletions neurolib/optimize/evolution/evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import pypet as pp
import pandas as pd

import neurolib.utils.paths as paths
from ...utils import paths as paths
from ...utils import pypetUtils as pu

import neurolib.optimize.evolution.evolutionaryUtils as eu
import neurolib.optimize.evolution.deapUtils as du
import neurolib.utils.pypetUtils as pu
from . import evolutionaryUtils as eu
from . import deapUtils as du


class Evolution:
Expand Down
9 changes: 2 additions & 7 deletions neurolib/optimize/evolution/evolutionaryUtils.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import logging
import datetime
import os
import random
import copy

import deap
import numpy as np
import pypet as pp
import pandas as pd

import neurolib.utils.paths as paths
import neurolib.optimize.evolution.deapUtils as du
from ...utils import paths as paths
from . import deapUtils as du


def saveToPypet(traj, pop, gIdx):
Expand Down
2 changes: 1 addition & 1 deletion neurolib/optimize/exploration/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from neurolib.optimize.exploration.exploration import BoxSearch
from .exploration import BoxSearch
18 changes: 9 additions & 9 deletions neurolib/optimize/exploration/exploration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
import pandas as pd
import tqdm

import neurolib.utils.paths as paths
import neurolib.utils.pypetUtils as pu
from ...utils import paths
from ...utils import pypetUtils as pu

from neurolib.utils.collections import dotdict
from ...utils.collections import dotdict


class BoxSearch:
"""
Paremter box search for a given model and a range of parameters.
"""

def __init__(self, model=None, exploreParameters=None, evalFunction=None):
def __init__(self, model=None, parameterSpace=None, evalFunction=None):
"""Either a model has to be passed, or an evalFunction. If an evalFunction
is passed, then the evalFunction will be called and the model is accessible to the
evalFunction via `self.getModelFromTraj(traj)`. The parameters of the current
Expand All @@ -31,8 +31,8 @@ def __init__(self, model=None, exploreParameters=None, evalFunction=None):
:param model: Model to run for each parameter (or model to pass to the evaluation funciton if an evaluation function is used), defaults to None
:type model: `neurolib.models.model.Model`, optional
:param exploreParameters: Parameter space to explore, defaults to None
:type exploreParameters: `neurolib.utils.parameterSpace.ParameterSpace`, optional
:param parameterSpace: Parameter space to explore, defaults to None
:type parameterSpace: `neurolib.utils.parameterSpace.ParameterSpace`, optional
:param evalFunction: Evaluation function to call for each run., defaults to None
:type evalFunction: function, optional
"""
Expand All @@ -46,10 +46,10 @@ def __init__(self, model=None, exploreParameters=None, evalFunction=None):
model is not None
), "Either a model has to be specified or an evalFunction."

assert exploreParameters is not None, "No parameters to explore."
assert parameterSpace is not None, "No parameters to explore."

self.parameterSpace = exploreParameters
self.exploreParameters = exploreParameters.dict()
self.parameterSpace = parameterSpace
self.exploreParameters = parameterSpace.dict()

# todo: use random ICs for every explored point or rather reuse the ones that are generated at model initialization
self.useRandomICs = False
Expand Down
4 changes: 2 additions & 2 deletions neurolib/utils/loadData.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import h5py
import scipy.io

import neurolib.utils.functions as func
from neurolib.utils.collections import dotdict
from . import functions as func
from .collections import dotdict


class Dataset:
Expand Down
Loading

0 comments on commit 409ce43

Please sign in to comment.