diff --git a/brian2tools/mdexport/expander.py b/brian2tools/mdexport/expander.py index 75085d43..500ae746 100644 --- a/brian2tools/mdexport/expander.py +++ b/brian2tools/mdexport/expander.py @@ -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: @@ -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` @@ -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): """ @@ -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 \ No newline at end of file diff --git a/brian2tools/plotting/morphology.py b/brian2tools/plotting/morphology.py index 4cf6b5c9..3bba0bab 100644 --- a/brian2tools/plotting/morphology.py +++ b/brian2tools/plotting/morphology.py @@ -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) @@ -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: @@ -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, @@ -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 \ No newline at end of file diff --git a/brian2tools/tests/test_baseexport.py b/brian2tools/tests/test_baseexport.py index bc958e75..c0c73598 100644 --- a/brian2tools/tests/test_baseexport.py +++ b/brian2tools/tests/test_baseexport.py @@ -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, @@ -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 @@ -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__': @@ -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() \ No newline at end of file