Skip to content

Conversation

@jorenham
Copy link
Member

Closes #987

This also adds a couple of hand-verified regression tests for the other multivariate distribution rvs return dtypes.

@github-actions
Copy link

github-actions bot commented Nov 21, 2025

mypy_primer results

No ecosystem changes detected ✅

@jorenham jorenham requested a review from Copilot November 21, 2025 00:43
Copilot finished reviewing on behalf of jorenham November 21, 2025 00:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the return dtype for stats.unitary_group.rvs to correctly return np.complex128 instead of the default np.float64. The fix is implemented by adding generic type parameters to the internal group random variable mixin classes and specializing unitary_group to use np.complex128.

  • Added comprehensive regression tests for rvs return dtypes across all multivariate distributions
  • Introduced _ScalarT_co covariant type variable to parameterize the scalar dtype in group RV mixins
  • Specialized unitary_group_gen and unitary_group_frozen to use np.complex128

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/stats/test_multivariate.pyi New test file with dtype assertions for all multivariate distribution rvs methods
scipy-stubs/stats/_multivariate.pyi Added generic type parameters to group RV mixins and specialized unitary_group to return complex128 arrays

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jorenham jorenham merged commit 7d3fa21 into master Nov 21, 2025
24 checks passed
@jorenham jorenham deleted the gh-987 branch November 21, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stats.unitary_group.rvs is typed as returning ndarray[float64] but returns ndarray[complex128]

2 participants