Skip to content

Commit

Permalink
Merge 0b8aec2 into c691cf1
Browse files Browse the repository at this point in the history
  • Loading branch information
mstimberg committed May 5, 2022
2 parents c691cf1 + 0b8aec2 commit 3580256
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion brian2/core/variables.py
@@ -1,4 +1,3 @@

"""
Classes used to specify the type of a function, variable or common
sub-expression.
Expand Down Expand Up @@ -1091,6 +1090,16 @@ def get_with_index_array(self, item):
elif (isinstance(item, slice) and item == slice(None)
and self.index_var == '_idx'):
indices = slice(None)
# Quick fix for matplotlib calling 1-d variables as var[:, np.newaxis]
# The test is a bit verbose, but we need to avoid comparisons that raise errors
# (e.g. comparing an array to slice(None))
elif (isinstance(item, tuple) and
len(item) == 2 and
isinstance(item[0], slice) and
item[0] == slice(None) and
item[1] is None and
self.index_var == '_idx'):
return variable.get_value()[item]
else:
indices = self.indexing(item, self.index_var)

Expand Down Expand Up @@ -1400,6 +1409,10 @@ def __repr__(self):
def shape(self):
return self.get_item(slice(None), level=1).shape

@property
def ndim(self):
return self.get_item(slice(None), level=1).ndim

@property
def dtype(self):
return self.get_item(slice(None), level=1).dtype
Expand Down

0 comments on commit 3580256

Please sign in to comment.