Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Handle 3d empty numpy arrays #5662

Merged
merged 2 commits into from
Nov 6, 2017

Conversation

Prikers
Copy link
Contributor

@Prikers Prikers commented Nov 5, 2017

Fixes #5628

@@ -760,8 +760,11 @@ def change_active_widget(self, index):
stack_index = self.dim_indexes[self.last_dim].get(data_index)
if stack_index == None:
stack_index = self.stack.count()
self.stack.addWidget(ArrayEditorWidget(self,
self.data[slice_index]))
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ccordoba12 @Prikers isn't it better to check if it is empty instead of catching an index error?

NumPy's main object is the homogeneous multidimensional array. In Numpy dimensions are called axes. The number of axes is rank. Numpy's array class is called ndarray. It is also known by the alias array. The more important attributes of an ndarray object are:

ndarray.ndim
the number of axes (dimensions) of the array. In the Python world, the number of dimensions is referred to as rank.

ndarray.shape
the dimensions of the array. This is a tuple of integers indicating the size of the array in each dimension. For a matrix with n rows and m columns, shape will be (n,m). The length of the shape tuple is therefore the rank, or number of dimensions, ndim.

ndarray.size
the total number of elements of the array. This is equal to the product of the elements of shape.

@ccordoba12 ccordoba12 added this to the v3.2.5 milestone Nov 6, 2017
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what @Prikers did was the right thing to do.

Thanks @Prikers!

@ccordoba12
Copy link
Member

Note: The failure in Travis is unrelated to this PR.

@ccordoba12 ccordoba12 merged commit 07230f0 into spyder-ide:3.x Nov 6, 2017
ccordoba12 added a commit that referenced this pull request Nov 6, 2017
@Prikers Prikers deleted the empty_numpy_arrays branch November 6, 2017 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants