toqito Contributions
PR #1390
Parameterize random_psd_operator with Wishart Distribution Option
Merged Apr 2026
  • Added distribution: Literal["uniform", "wishart"] parameter to random_psd_operator with full backward compatibility
  • Implemented Wishart sampling with correct complex normalization (/sqrt(2)) following Goodman (1963)
  • Added optional scale (PSD scale matrix) and num_degrees (degrees of freedom) parameters for full Wishart parameterization
  • Added np.asarray coercion for scale to gracefully handle list/tuple input
  • Added validation for scale shape and positive semidefiniteness, and integer/positivity checks for num_degrees
  • Added UserWarning for rank-deficient Wishart matrices (num_degrees < dim) and ignored Wishart params on uniform path
  • Updated docstring with Raises section, Google-style format, and mkdocs-compatible examples
View Pull Request ↗
PR #1391
Ensure partial_trace Raises ValueError for Invalid Parameters
Merged Apr 2026
  • Added explicit square matrix check with clear ValueError: input_mat must be a 2D square matrix
  • Added np.prod(dim) != n validation to catch mismatched subsystem dimensions
  • Added out-of-bounds and negative index validation for sys subsystem indices
  • Broadened dim and sys type support to accept list, tuple, and np.ndarray using np.asarray
  • Updated type annotations and docstring Raises section to document all ValueError conditions
  • Replaced silent NumPy failures and cryptic IndexError crashes with actionable error messages
View Pull Request ↗