Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions brian2tools/mdexport/expander.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,9 @@ def expand_initializer(self, initializer):
(initializer['index'] != 'True' and initializer['index'] != 'False')):
init_str += ' if ' + self.render_expression(initializer['index'])
elif (isinstance(initializer['index'], bool) or
(initializer['index'] == 'True' or
initializer['index'] == 'False')):
(isinstance(initializer['index'], str) and
(initializer['index'] == 'True' or
initializer['index'] == 'False'))):
if initializer['index'] is True or initializer['index'] == 'True':
init_str += '' # "to all members" implied
else:
Expand Down Expand Up @@ -796,10 +797,10 @@ def expand_connector(self, connector):
self.expand_identifiers(connector['identifiers']))
return con_str + '.' + endll








def expand_pathway(self, pathway):
"""
Expand `SynapticPathway`
Expand Down Expand Up @@ -864,7 +865,7 @@ def expand_summed_variables(self, sum_variables):
sum_var_str += self.expand_summed_variable(sum_var)
return sum_var_str



def expand_runregularly(self, run_reg):
"""
Expand All @@ -880,4 +881,4 @@ def expand_runregularly(self, run_reg):
' code: ' +
self.prepare_math_statements(run_reg['code'], separate=True) +
' will be executed' + endll)
return md_str
return md_str
16 changes: 8 additions & 8 deletions brian2tools/plotting/morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ def _plot_morphology2D(morpho, axes, colors,
color = colors[color_counter % len(colors)]

if isinstance(morpho, Soma):
x, y = morpho.x/um, morpho.y/um
radius = morpho.diameter/um/2
x, y = float(morpho.x[0]/um), float(morpho.y[0]/um)
radius = float(morpho.diameter[0]/um/2)
circle = Circle((x, y), radius=radius, color=color)
axes.add_patch(circle)


else:
coords = morpho.coordinates/um

if show_diameter:
coords_2d = coords[:, :2]
directions = np.diff(coords_2d, axis=0)
Expand All @@ -56,7 +56,7 @@ def _plot_morphology2D(morpho, axes, colors,
(coords_2d - orthogonal*radius[:, np.newaxis])[::-1]])
patch = Polygon(points, color=color)
axes.add_patch(patch)

else:
axes.plot(coords[:, 0], coords[:, 1], color=color, lw=2)
if show_compartments:
Expand All @@ -74,7 +74,7 @@ def _plot_morphology2D(morpho, axes, colors,
show_compartments=show_compartments,
show_diameter=show_diameter,
colors=colors, color_counter=color_counter+1)

def _plot_morphology3D(morpho, figure, colors, values, value_norm,
value_colormap,
show_diameters=True,
Expand Down Expand Up @@ -439,4 +439,4 @@ def plot_dendrogram(morphology, axes=None):
axes.set_xticks([])
axes.set_ylabel('distance from root (um)')
axes.set_xlim(-1, terminal_counter)
return axes
return axes
25 changes: 14 additions & 11 deletions brian2tools/tests/test_baseexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
PopulationRateMonitor, EventMonitor, set_device,
run, device, Network, Synapses, PoissonInput, TimedArray,
Function)
from brian2.core.base import BrianObject
from brian2.core.namespace import get_local_namespace
from brian2.equations.equations import (DIFFERENTIAL_EQUATION,
FLOAT, SUBEXPRESSION,
Expand Down Expand Up @@ -236,7 +237,7 @@ def test_spikegenerator():
assert spike_gen_dict['indices'] == [0]
assert spike_gen_dict['indices'].dtype == int

assert float(spike_gen_dict['times']) == float(time)
assert float(spike_gen_dict['times'][0]) == float(time[0])
assert spike_gen_dict['times'][:].dimensions == second
assert spike_gen_dict['times'].dtype == float

Expand Down Expand Up @@ -898,14 +899,16 @@ def test_ExportDevice_unsupported():
"""
start_scope()
set_device('exporter')
eqn = '''
v = 1 :1
g :1
'''
G = NeuronGroup(1, eqn)
_ = PoissonInput(G, 'g', 1, 1 * Hz, 1)
# with pytest.raises(NotImplementedError):
run(10 * ms)

class UnsupportedObject(BrianObject):
def __init__(self):
super().__init__(name='unsupported*')

obj = UnsupportedObject()
net = Network(obj)
with pytest.raises(NotImplementedError):
net.run(10 * ms)
device.reinit()


if __name__ == '__main__':
Expand All @@ -926,8 +929,8 @@ def test_ExportDevice_unsupported():
test_Synapses()
test_ExportDevice_options()
test_ExportDevice_basic()
test_ExportDevice_unsupported() # TODO: not checking anything
test_ExportDevice_unsupported()
test_synapse_init()
test_synapse_connect_cond()
test_synapse_connect_generator()
test_synapse_connect_ij()
test_synapse_connect_ij()