diff --git a/bluecellulab/psegment.py b/bluecellulab/psegment.py index 66e0fb47..64663dc4 100644 --- a/bluecellulab/psegment.py +++ b/bluecellulab/psegment.py @@ -25,7 +25,7 @@ class PSegment: def __init__(self, hsegment, parentsection): # import matplotlib as plt - from matplotlib import cm + from matplotlib import colormaps self.hsegment = hsegment self.parentsection = parentsection @@ -35,7 +35,7 @@ def __init__(self, hsegment, parentsection): self.figure = None self.figX = None self.figY = None - self.color_map = cm.get_cmap("hot") + self.color_map = colormaps["hot"] self.ax = None self.patch = None self.plotvariable = None diff --git a/bluecellulab/synapse/synapse_factory.py b/bluecellulab/synapse/synapse_factory.py index aa1fa858..9c42083b 100644 --- a/bluecellulab/synapse/synapse_factory.py +++ b/bluecellulab/synapse/synapse_factory.py @@ -118,6 +118,10 @@ def determine_synapse_location(cls, syn_description: pd.Series, cell: bluecellul not np.isnan(syn_description[SynapseProperty.AFFERENT_SECTION_POS])): # position is pre computed in SONATA location = syn_description[SynapseProperty.AFFERENT_SECTION_POS] + if location == 0.0: + location = 0.0000001 + elif location >= 1.0: + location = 0.9999999 else: ipt = syn_description[SynapseProperty.POST_SEGMENT_ID] syn_offset = syn_description[SynapseProperty.POST_SEGMENT_OFFSET] diff --git a/tests/test_synapse/test_synapse_factory.py b/tests/test_synapse/test_synapse_factory.py index a7f2c037..c9dbb961 100644 --- a/tests/test_synapse/test_synapse_factory.py +++ b/tests/test_synapse/test_synapse_factory.py @@ -60,8 +60,11 @@ def test_determine_synapse_location(self): # set afferent_section_pos self.syn_description[SynapseProperty.AFFERENT_SECTION_POS] = 1.2 res = SynapseFactory.determine_synapse_location(self.syn_description, self.cell) - assert res.location == 1.2 + assert res.location == 0.9999999 assert res.section.L == pytest.approx(9.530376893488256) + self.syn_description[SynapseProperty.AFFERENT_SECTION_POS] = 0 + res = SynapseFactory.determine_synapse_location(self.syn_description, self.cell) + assert res.location == 0.0000001 def test_synlocation_to_segx(self): ipt = 13