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

Update pytest and rm pytest-pep8 dependency. #40

Merged
merged 8 commits into from
Feb 2, 2023
Merged

Conversation

rossbar
Copy link
Contributor

@rossbar rossbar commented Jan 3, 2023

pytest-pep8 is no longer supported, and pytest<6 is likely the source of the issues with coveralls.

I will re-add some form of linting to CI to replace pytest-pep8 in the near future (this applies to all the deepcell-* libraries). See also vanvalenlab/deepcell-toolbox#128.

@rossbar rossbar marked this pull request as ready for review January 4, 2023 00:46
Copy link
Contributor Author

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

Okay this should be ready for review now. This PR includes a couple maintenance items to get the CI system working again and fixing some of the more disruptive problems related to changes in underlying dependencies (e.g. numpy). It is by no means comprehensive and there's still more maintenance work to do, but this is a minimal set of patches to make CI green again.

See inline comments for details (or ignore them - I mostly included them only to explain changes in more detail).

.github/workflows/tests.yaml Show resolved Hide resolved
.github/workflows/tests.yaml Show resolved Hide resolved
@@ -58,9 +58,9 @@ def slice_image(X, reshape_size, overlap=0):
L_y = reshape_size[1] # y length of each slice

# number of slices along x axis
n_x = np.int(np.ceil((image_size_x - 2 * L_x + overlap) / (L_x - overlap)) + 2)
n_x = np.int_(np.ceil((image_size_x - 2 * L_x + overlap) / (L_x - overlap)) + 2)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NumPy 1.24 removed the np.int, np.int_ is the preferred way to do this and behaves the same; though whether this really needs to be a platform integer is up for debate. If the only intent here is to get an integer scalar out then its even better to replace np.int_ with just int.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, I think changing to int would be fine.

pytest.ini Show resolved Hide resolved
np.ceil((image_size_x - 2 * L_x + overlap) / (L_x - overlap)) + 2)

new_batch_size = X.shape[0] * n_y * n_x # number of images in output

new_X_shape = (new_batch_size, L_y, L_x, X.shape[3])
new_X = np.zeros(new_X_shape, dtype=K.floatx())

new_y = [None] * new_batch_size
new_y = np.array([None] * new_batch_size, dtype=object)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This explicitly creates an object array, which is the only way in numpy to create a "ragged" array; i.e. one where the shape may change along a given dimension.

Note that object arrays are often not desirable, and there may be a better data structure for this particular object - let's earmark that for future discussion.

Copy link
Member

Choose a reason for hiding this comment

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

I have been wanting to update this data structure from a ragged list of lists for awhile, but didn't have the time to invest in making the change. I would love to hear your thoughts on better solutions!

requirements-test.txt Show resolved Hide resolved
@rossbar
Copy link
Contributor Author

rossbar commented Feb 1, 2023

While looking at #41 I noticed new failures in CI from networkx - this is due to the removal of the from_numpy_matrix function in NX 3.0, which was released a few weeks ago. Fortunately it's an easy fix - just replace with from_numpy_array.

I'm personally responsible for that change in NX, so at least you know where to lodge complaints 🙃

@elaubsch elaubsch self-requested a review February 2, 2023 00:52
@elaubsch elaubsch added the fix Fixes a bug label Feb 2, 2023
@elaubsch elaubsch merged commit 8a15184 into master Feb 2, 2023
@elaubsch elaubsch deleted the update-pytest branch February 2, 2023 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants