From 4148974fe3273270f3b7b74577b43c2b7fb5aa12 Mon Sep 17 00:00:00 2001 From: Lukas Drescher Date: Tue, 25 Oct 2022 20:21:36 +0200 Subject: [PATCH] Renaming Arbor iexpr module, adding docstring --- .../{arbor_dsl.py => acc_iexpr.py} | 16 +++++++++++++--- .../ephys/parameterscalers/parameterscalers.py | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) rename bluepyopt/ephys/parameterscalers/{arbor_dsl.py => acc_iexpr.py} (93%) diff --git a/bluepyopt/ephys/parameterscalers/arbor_dsl.py b/bluepyopt/ephys/parameterscalers/acc_iexpr.py similarity index 93% rename from bluepyopt/ephys/parameterscalers/arbor_dsl.py rename to bluepyopt/ephys/parameterscalers/acc_iexpr.py index 5db3ba81..5d3d20b2 100644 --- a/bluepyopt/ephys/parameterscalers/arbor_dsl.py +++ b/bluepyopt/ephys/parameterscalers/acc_iexpr.py @@ -1,4 +1,4 @@ -"""Module that generates Arbor's iexpr expression language.""" +"""Translate spatially varying parameter-scaler expressions to Arbor iexprs""" """ Copyright (c) 2016-2022, EPFL/Blue Brain Project @@ -218,8 +218,18 @@ def visit_Name(self, node): ' No valid substitution for %s.' % node.id) -def generate_arbor_iexpr(iexpr, variables, constant_formatter): - """Generate Arbor iexpr from parameter-scaler python expression""" +def generate_acc_scale_iexpr(iexpr, variables, constant_formatter): + """Translate parameter-scaler python arithmetic expression to Arbor iexpr + + Args: + iexpr (str): Python arithmetic expression (instantiated distribution) + variables (): Mapping of variable name (referenced in the iexpr + argument) to Arbor iexpr representation + + Returns: + The Arbor iexpr corresponding to the python arithmetic expression + with the variables substituted by their value. + """ if 'value' not in variables: raise ValueError('Arbor iexpr generation failed for %s:' % iexpr + diff --git a/bluepyopt/ephys/parameterscalers/parameterscalers.py b/bluepyopt/ephys/parameterscalers/parameterscalers.py index f8561af1..bab4f2a7 100644 --- a/bluepyopt/ephys/parameterscalers/parameterscalers.py +++ b/bluepyopt/ephys/parameterscalers/parameterscalers.py @@ -24,7 +24,7 @@ import string from bluepyopt.ephys.base import BaseEPhys -from bluepyopt.ephys.parameterscalers.arbor_dsl import generate_arbor_iexpr +from bluepyopt.ephys.parameterscalers.acc_iexpr import generate_acc_scale_iexpr from bluepyopt.ephys.serializer import DictMixin from bluepyopt.ephys.morphologies import ArbFileMorphology @@ -190,7 +190,7 @@ def acc_scale_iexpr(self, value, constant_formatter=format_float): distance='(distance %s)' % # could be a ctor param if required ArbFileMorphology.region_labels['somatic'].ref ) - return generate_arbor_iexpr(iexpr, variables, constant_formatter) + return generate_acc_scale_iexpr(iexpr, variables, constant_formatter) def __str__(self): """String representation"""