Skip to content

Commit

Permalink
Merge branch 'qutip:master' into bosonic_fitting
Browse files Browse the repository at this point in the history
  • Loading branch information
gsuarezr authored Mar 14, 2024
2 parents d586a9d + 9f04c73 commit 421b475
Show file tree
Hide file tree
Showing 48 changed files with 623 additions and 256 deletions.
110 changes: 110 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,47 @@ Change Log

.. towncrier release notes start
QuTiP 5.0.0b1 (2024-03-04)
==========================

Features
--------

- Create a Dimension class (#1996)
- Add arguments of plot_wigner() and plot_wigner_fock_distribution() to specify parameters for wigner(). (#2057, by Kosuke Mizuno)
- Restore feedback to solvers (#2210)
- Added mpi_pmap, which uses the mpi4py module to run computations in parallel through the MPI interface. (#2296, by Paul)
- Only pre-compute density matrices if keep_runs_results is False (#2303, by Matt Ord)


Bug Fixes
---------

- Add the possibility to customize point colors as in V4 and fix point plot behavior for 'l' style (#1974, by Daniel Moreno Galán)
- Disabled broken "improved sampling" for `nm_mcsolve`. (#2234, by Paul)
- Fixed result objects storing a reference to the solver through options._feedback. (#2262, by Paul)
- Fixed simdiag not returning orthonormal eigenvectors. (#2269, by Sola85)
- Fix LaTeX display of Qobj state in Jupyter cell outputs (#2272, by Edward Thomas)
- Improved behavior of `parallel_map` and `loky_pmap` in the case of timeouts, errors or keyboard interrupts (#2280, by Paul)
- Ignore deprecation warnings from cython 0.29.X in tests. (#2288)
- Fixed two problems with the steady_state() solver in the HEOM method. (#2333)


Miscellaneous
-------------

- Improve fidelity doc-string (#2257)
- Improve documentation in guide/dynamics (#2271)
- Improve states and operator parameters documentation. (#2289)
- Rework `kraus_to_choi` making it faster (#2284, by Bogdan Reznychenko)
- Remove Bloch3D: redundant to Bloch (#2306)
- Allow tests to run without matplotlib and ipython. (#2311)
- Add too small step warnings in fixed dt SODE solver (#2313)
- Add `dtype` to `Qobj` and `QobjEvo` (#2325)
- Fix typos in `expect` documentation (#2331, by gabbence95)
- Allow measurement functions to support degenerate operators. (#2342)


QuTiP 5.0.0a2 (2023-09-06)
==========================

Expand Down Expand Up @@ -435,6 +476,75 @@ Feature removals
- The ``~/.qutip/qutiprc`` config file is no longer supported. It contained settings for the OpenMP support.


QuTiP 4.7.5 (2024-01-29)
========================

Patch release for QuTiP 4.7. It adds support for SciPy 1.12.

Bug Fixes
---------

- Remove use of scipy.<numpy-func> in parallel.py, incompatible with scipy==1.12 (#2305 by Evan McKinney)


QuTiP 4.7.4 (2024-01-15)
========================

Bug Fixes
---------

- Adapt to deprecation from matplotlib 3.8 (#2243, reported by Bogdan Reznychenko)
- Fix name of temp files for removal after use. (#2251, reported by Qile Su)
- Avoid integer overflow in Qobj creation. (#2252, reported by KianHwee-Lim)
- Ignore DeprecationWarning from pyximport (#2287)
- Add partial support and tests for python 3.12. (#2294)


Miscellaneous
-------------

- Rework `choi_to_kraus`, making it rely on an eigenstates solver that can choose `eigh` if the Choi matrix is Hermitian, as it is more numerically stable. (#2276, by Bogdan Reznychenko)
- Rework `kraus_to_choi`, making it faster (#2283, by Bogdan Reznychenko and Rafael Haenel)


QuTiP 4.7.3 (2023-08-22)
========================

Bug Fixes
---------

- Non-oper qobj + scalar raise an error. (#2208 reported by vikramkashyap)
- Fixed issue where `extract_states` did not preserve hermiticity.
Fixed issue where `rand_herm` did not set the private attribute _isherm to True. (#2214 by AGaliciaMartinez)
- ssesolve average states to density matrices (#2216 reported by BenjaminDAnjou)


Miscellaneous
-------------

- Exclude cython 3.0.0 from requirement (#2204)
- Run in no cython mode with cython >=3.0.0 (#2207)


QuTiP 4.7.2 (2023-06-28)
========================

This is a bugfix release for QuTiP 4.7.X. It adds support for
numpy 1.25 and scipy 1.11.

Bug Fixes
---------
- Fix setting of sso.m_ops in heterodyne smesolver and passing through of sc_ops to photocurrent solver. (#2081 by Bogdan Reznychenko and Simon Cross)
- Update calls to SciPy eigvalsh and eigsh to pass the range of eigenvalues to return using ``subset_by_index=``. (#2081 by Simon Cross)
- Fixed bug where some matrices were wrongly found to be hermitian. (#2082 by AGaliciaMartinez)

Miscellaneous
-------------
- Fixed typo in stochastic.py (#2049, by eltociear)
- `ptrace` always return density matrix (#2185, issue by udevd)
- `mesolve` can support mixed callable and Qobj for `e_ops` (#2184 issue by balopat)


Version 4.7.1 (December 11, 2022)
+++++++++++++++++++++++++++++++++

Expand Down
1 change: 0 additions & 1 deletion doc/changes/1974.bugfix

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/1996.feature

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2210.feature

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2234.bugfix

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2257.misc

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2262.bugfix

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2269.bugfix

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2271.misc

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2272.bugfix

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2280.bugfix

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2284.misc

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2288.bugfix

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2296.feature

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2303.feature

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2306.misc

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2311.misc

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2313.misc

This file was deleted.

1 change: 0 additions & 1 deletion doc/changes/2325.misc

This file was deleted.

2 changes: 1 addition & 1 deletion qutip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from .partial_transpose import *
from .continuous_variables import *
from .distributions import *

from . import measurement

# utilities
from .utilities import *
Expand Down
22 changes: 18 additions & 4 deletions qutip/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
plot_fock_distribution, plot_wigner, plot_spin_distribution,
plot_qubism, plot_schmidt)
from .solver import Result
from numpy import sqrt


def _result_state(obj):
Expand Down Expand Up @@ -346,9 +347,9 @@ def anim_fock_distribution(rhos, fock_numbers=None, color="green",
return fig, ani


def anim_wigner(rhos, xvec=None, yvec=None, method='clenshaw',
projection='2d', *, cmap=None, colorbar=False,
fig=None, ax=None):
def anim_wigner(rhos, xvec=None, yvec=None, method='clenshaw', projection='2d',
g=sqrt(2), sparse=False, parfor=False, *,
cmap=None, colorbar=False, fig=None, ax=None):
"""
Animation of the Wigner function for a density matrix (or ket)
that describes an oscillator mode.
Expand All @@ -373,6 +374,18 @@ def anim_wigner(rhos, xvec=None, yvec=None, method='clenshaw',
Specify whether the Wigner function is to be plotted as a
contour graph ('2d') or surface plot ('3d').
g : float
Scaling factor for `a = 0.5 * g * (x + iy)`, default `g = sqrt(2)`.
See the documentation for qutip.wigner for details.
sparse : bool {False, True}
Flag for sparse format.
See the documentation for qutip.wigner for details.
parfor : bool {False, True}
Flag for parallel calculation.
See the documentation for qutip.wigner for details.
cmap : a matplotlib cmap instance, optional
The colormap.
Expand All @@ -395,7 +408,8 @@ def anim_wigner(rhos, xvec=None, yvec=None, method='clenshaw',

rhos = _result_state(rhos)

fig, ani = plot_wigner(rhos, xvec, yvec, method, projection,
fig, ani = plot_wigner(rhos, xvec, yvec, method=method, g=g, sparse=sparse,
parfor=parfor, projection=projection,
cmap=cmap, colorbar=colorbar, fig=fig, ax=ax)

return fig, ani
Expand Down
2 changes: 1 addition & 1 deletion qutip/bloch.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def clear(self):
self.vector_alpha = []
self.annotations = []
self.vector_color = []
self.point_color = []
self.point_color = None
self._lines = []
self._arcs = []

Expand Down
4 changes: 2 additions & 2 deletions qutip/core/cy/qobjevo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,11 @@ cdef class QobjEvo:

def __imatmul__(QobjEvo self, other):
if isinstance(other, (Qobj, QobjEvo)):
if self.dims[1] != other.dims[0]:
if self._dims[1] != other._dims[0]:
raise TypeError("incompatible dimensions" +
str(self.dims[1]) + ", " +
str(other.dims[0]))
self._dims = Dimensions([self.dims[0], other.dims[1]])
self._dims = Dimensions([self._dims[0], other._dims[1]])
self.shape = (self.shape[0], other.shape[1])
if isinstance(other, Qobj):
other = _ConstantElement(other)
Expand Down
6 changes: 4 additions & 2 deletions qutip/core/data/matmul.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ cdef int _check_shape(Data left, Data right, Data out=None) except -1 nogil:
)
if (
out is not None
and out.shape[0] != left.shape[0]
and out.shape[1] != right.shape[1]
and (
out.shape[0] != left.shape[0]
or out.shape[1] != right.shape[1]
)
):
raise ValueError(
"incompatible output shape, got "
Expand Down
42 changes: 37 additions & 5 deletions qutip/core/dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Everything should be explicitly imported, not made available by default.

import numpy as np
import numbers
from operator import getitem
from functools import partial
from qutip.settings import settings
Expand All @@ -16,17 +17,28 @@
def flatten(l):
"""Flattens a list of lists to the first level.
Given a list containing a mix of scalars and lists,
flattens down to a list of the scalars within the original
list.
Given a list containing a mix of scalars and lists or a dimension object,
flattens it down to a list of the scalars within the original list.
Parameters
----------
l : scalar, list, Space, Dimension
Object to flatten.
Examples
--------
>>> flatten([[[0], 1], 2]) # doctest: +SKIP
[0, 1, 2]
Notes
-----
Any scalar will be returned wrapped in a list: ``flaten(1) == [1]``.
A non-list iterable will not be treated as a list by flatten. For example, flatten would treat a tuple
as a scalar.
"""
if isinstance(l, (Space, Dimensions)):
l = l.as_list()
if not isinstance(l, list):
return [l]
else:
Expand Down Expand Up @@ -459,12 +471,20 @@ def dims2idx(self, dims):
"""
Transform dimensions indices to full array indices.
"""
return dims
if not isinstance(dims, list) or len(dims) != 1:
raise ValueError("Dimensions must be a list of one element")
if not (0 <= dims[0] < self.size):
raise IndexError("Dimensions out of range")
if not isinstance(dims[0], numbers.Integral):
raise TypeError("Dimensions must be integers")
return dims[0]

def idx2dims(self, idx):
"""
Transform full array indices to dimensions indices.
"""
if not (0 <= idx < self.size):
raise IndexError("Index out of range")
return [idx]

def step(self):
Expand Down Expand Up @@ -503,6 +523,9 @@ def replace(self, idx, new):
def replace_superrep(self, super_rep):
return self

def scalar_like(self):
return Field()


class Field(Space):
field_instance = None
Expand Down Expand Up @@ -595,7 +618,7 @@ def dims2idx(self, dims):
pos = 0
step = 1
for space, dim in zip(self.spaces[::-1], dims[::-1]):
pos += space.dims2idx(dim) * step
pos += space.dims2idx([dim]) * step
step *= space.size
return pos

Expand Down Expand Up @@ -644,6 +667,9 @@ def replace_superrep(self, super_rep):
*[space.replace_superrep(super_rep) for space in self.spaces]
)

def scalar_like(self):
return [space.scalar_like() for space in self.spaces]


class SuperSpace(Space):
_stored_dims = {}
Expand Down Expand Up @@ -705,6 +731,9 @@ def replace(self, idx, new):
def replace_superrep(self, super_rep):
return SuperSpace(self.oper, rep=super_rep)

def scalar_like(self):
return self.oper.scalar_like()


class MetaDims(type):
def __call__(cls, *args, rep=None):
Expand Down Expand Up @@ -920,3 +949,6 @@ def replace_superrep(self, super_rep):
self.from_.replace_superrep(super_rep),
self.to_.replace_superrep(super_rep)
)

def scalar_like(self):
return [self.to_.scalar_like(), self.from_.scalar_like()]
6 changes: 3 additions & 3 deletions qutip/core/expect.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def expect(oper, state):
Parameters
----------
oper : qobj/array-like
A single or a `list` or operators for expectation value.
A single or a `list` of operators for expectation value.
state : qobj/array-like
A single or a `list` of quantum states or density matrices.
Expand All @@ -25,8 +25,8 @@ def expect(oper, state):
-------
expt : float/complex/array-like
Expectation value. ``real`` if ``oper`` is Hermitian, ``complex``
otherwise. A (nested) array of expectaction values of state or operator
are arrays.
otherwise. A (nested) array of expectaction values if ``state`` or
``oper`` are arrays.
Examples
--------
Expand Down
Loading

0 comments on commit 421b475

Please sign in to comment.