Skip to content

fix: create signal and waveform views with reshape - #1886

Merged
alejoe91 merged 1 commit into
NeuralEnsemble:masterfrom
stanbot8:fix/reshape-numpy-arrays
Jul 28, 2026
Merged

fix: create signal and waveform views with reshape#1886
alejoe91 merged 1 commit into
NeuralEnsemble:masterfrom
stanbot8:fix/reshape-numpy-arrays

Conversation

@stanbot8

@stanbot8 stanbot8 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Signal and waveform creation changes NumPy array dimensions through attribute assignment. Create 2D signal and 3D waveform views with reshape. This keeps both data paths on the supported NumPy array API and avoids the NumPy 2.5 deprecation. All tests pass.

@stanbot8
stanbot8 force-pushed the fix/reshape-numpy-arrays branch from c8cfcab to 45e1bc4 Compare July 27, 2026 05:43

@zm711 zm711 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems okay to me Andrew. Our previous strategy forces a reshape as a view rather than as a copy (the old behavior would error if a copy would be required for a particular reshape), but if NumPy is dropping support for using that trick I think it is fine to do just do the reshape and if a copy of the array is required then do it and take a computational hit. If you have a different idea feel free to suggest that.

@alejoe91

alejoe91 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

LGTM too, just a minor comment for @stanbot8

@alejoe91 alejoe91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @stanbot8

Just a minor comment with suggestion. We can remofe the pytest filter warings right?

logging.getLogger().setLevel(logging.INFO)


@pytest.mark.filterwarnings("error:Setting the shape on a NumPy array has been deprecated:DeprecationWarning")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these should not warn anymore, right?

Suggested change
@pytest.mark.filterwarnings("error:Setting the shape on a NumPy array has been deprecated:DeprecationWarning")

Comment thread neo/test/coretest/test_analogsignal.py Outdated
self.assertEqual(signal.t_stop, len(data) / rate)
self.assertEqual(signal[9, 0], 9000 * pq.uV)

@pytest.mark.filterwarnings("error:Setting the shape on a NumPy array has been deprecated:DeprecationWarning")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these should not warn anymore, right?

Suggested change
@pytest.mark.filterwarnings("error:Setting the shape on a NumPy array has been deprecated:DeprecationWarning")

@stanbot8

stanbot8 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@alejoe91 Right, they don't warn anymore. The error: filter is a regression guard that turns the shape-assignment DeprecationWarning into a test failure if it ever comes back, since the suite doesn't escalate warnings globally. I can drop both if you'd rather keep the tests clean.

@alejoe91

Copy link
Copy Markdown
Contributor

@alejoe91 Right, they don't warn anymore. The error: filter is a regression guard that turns the shape-assignment DeprecationWarning into a test failure if it ever comes back, since the suite doesn't escalate warnings globally. I can drop both if you'd rather keep the tests clean.

yes please!

@stanbot8
stanbot8 force-pushed the fix/reshape-numpy-arrays branch from 45e1bc4 to 90bda1f Compare July 28, 2026 15:33
@stanbot8

Copy link
Copy Markdown
Contributor Author

Done, dropped both.

@alejoe91
alejoe91 merged commit 35cbce7 into NeuralEnsemble:master Jul 28, 2026
75 checks passed
@zm711

zm711 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Thanks @stanbot8. We typically add people to our author list with an affiliation. If you'd like to be included in the next release could you provide the name and affiliation you'd like to include (if you have an academic/work affiliation that you feel should be included). Thanks!

@stanbot8

Copy link
Copy Markdown
Contributor Author

Thanks! I'd be happy to be included. Please list me as Stanley C., Independent Contributor.

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.

4 participants