Skip to content

Commit

Permalink
code style update
Browse files Browse the repository at this point in the history
  • Loading branch information
anilbey committed Feb 28, 2024
1 parent c170a39 commit 80bbd6c
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/legalcode or send a letter to Creative Commons, 171
Second Street, Suite 300, San Francisco, California, 94105, USA.
"""

from neuron import h
if hasattr(h, 'nrnunit_use_legacy'):

if hasattr(h, "nrnunit_use_legacy"):
h.nrnunit_use_legacy(True)
from . import evaluator
from . import template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,16 @@ def define_protocols(
"type" in protocol_definition
and protocol_definition["type"] == "RatSSCxThresholdDetectionProtocol"
):
protocols_dict[
"ThresholdDetection"
] = protocols.RatSSCxThresholdDetectionProtocol(
"IDRest",
step_protocol_template=read_step_protocol(
"Threshold", protocol_definition["step_template"], recordings
),
prefix=prefix,
protocols_dict["ThresholdDetection"] = (
protocols.RatSSCxThresholdDetectionProtocol(
"IDRest",
step_protocol_template=read_step_protocol(
"Threshold",
protocol_definition["step_template"],
recordings,
),
prefix=prefix,
)
)
else:
stimuli = []
Expand Down Expand Up @@ -488,7 +490,6 @@ def calculate_score(self, responses, trace_check=False):


class eFELFeatureExtra(eFELFeature):

"""eFEL feature extra"""

SERIALIZED_FIELDS = (
Expand Down Expand Up @@ -647,7 +648,6 @@ def calculate_score(self, responses, trace_check=False):


class SingletonWeightObjective(EFeatureObjective):

"""Single EPhys feature"""

def __init__(self, name, feature, weight):
Expand Down Expand Up @@ -775,7 +775,6 @@ def define_fitness_calculator(


class MultiEvaluator(bpopt.evaluators.Evaluator):

"""Multiple cell evaluator"""

def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@


class RatSSCxMainProtocol(ephys.protocols.Protocol):

"""Main protocol to fit RatSSCx neuron ephys parameters.
Pseudo code:
Expand Down Expand Up @@ -193,7 +192,6 @@ def run(self, cell_model, param_values, sim=None, isolate=None):


class RatSSCxRinHoldcurrentProtocol(ephys.protocols.Protocol):

"""IDRest protocol to fit RatSSCx neuron ephys parameters"""

def __init__(
Expand Down Expand Up @@ -385,7 +383,6 @@ def voltage_base(self, current, cell_model, param_values, sim=None, short=False)


class RatSSCxThresholdDetectionProtocol(ephys.protocols.Protocol):

"""IDRest protocol to fit RatSSCx neuron ephys parameters"""

def __init__(
Expand Down Expand Up @@ -641,7 +638,6 @@ def search_spike_threshold(


class StepProtocol(ephys.protocols.SweepProtocol):

"""Protocol consisting of step and holding current"""

def __init__(
Expand All @@ -665,9 +661,11 @@ def __init__(

super(StepProtocol, self).__init__(
name,
stimuli=step_stimuli + [holding_stimulus]
if holding_stimulus is not None
else step_stimuli,
stimuli=(
step_stimuli + [holding_stimulus]
if holding_stimulus is not None
else step_stimuli
),
recordings=recordings,
cvode_active=cvode_active,
)
Expand Down Expand Up @@ -752,7 +750,6 @@ def step_amplitude(self):


class StepThresholdProtocol(StepProtocol):

"""Step protocol based on threshold"""

def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ def define_parameters(params_filename, stage=None, past_params=None):
dist_param_names = definition["parameters"]
else:
dist_param_names = None
distributions[
distribution
] = ephys.parameterscalers.NrnSegmentSomaDistanceScaler(
name=distribution,
distribution=definition["fun"],
dist_param_names=dist_param_names,
distributions[distribution] = (
ephys.parameterscalers.NrnSegmentSomaDistanceScaler(
name=distribution,
distribution=definition["fun"],
dist_param_names=dist_param_names,
)
)

params_definitions = definitions["parameters"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
Second Street, Suite 300, San Francisco, California, 94105, USA.
"""


"""Test to validate the model management output."""

from pathlib import Path
Expand Down
4 changes: 3 additions & 1 deletion optimization/opt_module/setup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/legalcode or send a letter to Creative Commons, 171
Second Street, Suite 300, San Francisco, California, 94105, USA.
"""

from neuron import h
if hasattr(h, 'nrnunit_use_legacy'):

if hasattr(h, "nrnunit_use_legacy"):
h.nrnunit_use_legacy(True)

from . import evaluator
Expand Down
21 changes: 10 additions & 11 deletions optimization/opt_module/setup/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,16 @@ def define_protocols(
"type" in protocol_definition
and protocol_definition["type"] == "RatSSCxThresholdDetectionProtocol"
):
protocols_dict[
"ThresholdDetection"
] = protocols.RatSSCxThresholdDetectionProtocol(
"IDRest",
step_protocol_template=read_step_protocol(
"Threshold", protocol_definition["step_template"], recordings
),
prefix=prefix,
protocols_dict["ThresholdDetection"] = (
protocols.RatSSCxThresholdDetectionProtocol(
"IDRest",
step_protocol_template=read_step_protocol(
"Threshold",
protocol_definition["step_template"],
recordings,
),
prefix=prefix,
)
)
else:
stimuli = []
Expand Down Expand Up @@ -491,7 +493,6 @@ def calculate_score(self, responses, trace_check=False):


class eFELFeatureExtra(eFELFeature):

"""eFEL feature extra"""

SERIALIZED_FIELDS = (
Expand Down Expand Up @@ -666,7 +667,6 @@ def calculate_score(self, responses, trace_check=False):


class SingletonWeightObjective(EFeatureObjective):

"""Single EPhys feature"""

def __init__(self, name, feature, weight):
Expand Down Expand Up @@ -794,7 +794,6 @@ def define_fitness_calculator(


class MultiEvaluator(bpopt.evaluators.Evaluator):

"""Multiple cell evaluator"""

def __init__(
Expand Down
14 changes: 5 additions & 9 deletions optimization/opt_module/setup/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
Second Street, Suite 300, San Francisco, California, 94105, USA.
"""


"""Protocols involved in fitting of RatSSCx neuron ephys parameters"""

import numpy
Expand All @@ -45,7 +44,6 @@


class RatSSCxMainProtocol(ephys.protocols.Protocol):

"""Main protocol to fit RatSSCx neuron ephys parameters.
Pseudo code:
Expand Down Expand Up @@ -220,7 +218,6 @@ def run(self, cell_model, param_values, sim=None, isolate=None):


class RatSSCxRinHoldcurrentProtocol(ephys.protocols.Protocol):

"""IDRest protocol to fit RatSSCx neuron ephys parameters"""

def __init__(
Expand Down Expand Up @@ -424,7 +421,6 @@ def voltage_base(self, current, cell_model, param_values, sim=None, short=False)


class RatSSCxThresholdDetectionProtocol(ephys.protocols.Protocol):

"""IDRest protocol to fit RatSSCx neuron ephys parameters"""

def __init__(
Expand Down Expand Up @@ -704,7 +700,6 @@ def search_spike_threshold(


class StepProtocol(ephys.protocols.SweepProtocol):

"""Protocol consisting of step and holding current"""

def __init__(
Expand All @@ -728,9 +723,11 @@ def __init__(

super(StepProtocol, self).__init__(
name,
stimuli=step_stimuli + [holding_stimulus]
if holding_stimulus is not None
else step_stimuli,
stimuli=(
step_stimuli + [holding_stimulus]
if holding_stimulus is not None
else step_stimuli
),
recordings=recordings,
cvode_active=cvode_active,
)
Expand Down Expand Up @@ -815,7 +812,6 @@ def step_amplitude(self):


class StepThresholdProtocol(StepProtocol):

"""Step protocol based on threshold"""

def __init__(
Expand Down
12 changes: 6 additions & 6 deletions optimization/opt_module/setup/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ def define_parameters(params_filename, stage=None, past_params=None):
dist_param_names = definition["parameters"]
else:
dist_param_names = None
distributions[
distribution
] = ephys.parameterscalers.NrnSegmentSomaDistanceScaler(
name=distribution,
distribution=definition["fun"],
dist_param_names=dist_param_names,
distributions[distribution] = (
ephys.parameterscalers.NrnSegmentSomaDistanceScaler(
name=distribution,
distribution=definition["fun"],
dist_param_names=dist_param_names,
)
)

params_definitions = definitions["parameters"]
Expand Down
1 change: 0 additions & 1 deletion optimization/opt_module/tools/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
Second Street, Suite 300, San Francisco, California, 94105, USA.
"""


import numpy
import seaborn as sns
import pandas as pd
Expand Down
1 change: 0 additions & 1 deletion optimization/opt_module/tools/plottools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
Second Street, Suite 300, San Francisco, California, 94105, USA.
"""


import matplotlib
import matplotlib.pyplot as plt

Expand Down
13 changes: 6 additions & 7 deletions somatic_validation/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
Second Street, Suite 300, San Francisco, California, 94105, USA.
"""


import os
import collections
import json
Expand Down Expand Up @@ -110,12 +109,12 @@ def define_parameters(path_params):
dist_param_names = definition["parameters"]
else:
dist_param_names = None
distributions[
distribution
] = ephys.parameterscalers.NrnSegmentSomaDistanceScaler(
name=distribution,
distribution=definition["fun"],
dist_param_names=dist_param_names,
distributions[distribution] = (
ephys.parameterscalers.NrnSegmentSomaDistanceScaler(
name=distribution,
distribution=definition["fun"],
dist_param_names=dist_param_names,
)
)

params_definitions = definitions["parameters"]
Expand Down
2 changes: 0 additions & 2 deletions somatic_validation/stimuli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@


class Stimulus(object):

"""Stimulus protocol"""

pass


class NrnHDPulse(Stimulus):

"""Square pulse current clamp injection"""

def __init__(
Expand Down
1 change: 0 additions & 1 deletion validation/lib/attenuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,6 @@ def EPSP(evaluator, emodels_path, points):


class NrnSynStim(ephys.stimuli.Stimulus):

"""Square pulse current clamp injection"""

def __init__(
Expand Down
1 change: 0 additions & 1 deletion validation/lib/plottools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
Second Street, Suite 300, San Francisco, California, 94105, USA.
"""


import matplotlib
import matplotlib.pyplot as plt

Expand Down
1 change: 1 addition & 0 deletions validation/lib/setup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/legalcode or send a letter to Creative Commons, 171
Second Street, Suite 300, San Francisco, California, 94105, USA.
"""

from . import evaluator
Loading

0 comments on commit 80bbd6c

Please sign in to comment.