Skip to content

Commit a5df6a5

Browse files
Merge branch 'qutip:main' into feature/ntbk_smesolve
2 parents 305e0da + 0d87e07 commit a5df6a5

File tree

4 files changed

+144
-17
lines changed

4 files changed

+144
-17
lines changed

Diff for: .github/workflows/nightly_ci.yaml

+23-8
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,28 @@ jobs:
2020
- qutip-version: '5'
2121
qutip-branch: 'master'
2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2424
- uses: gaurav-nelson/github-action-markdown-link-check@v1
2525
with:
2626
use-quiet-mode: 'yes'
2727
folder-path: tutorials-v${{ matrix.qutip-version }}
28-
#use config file to define 403 and 405 errors as valid links
28+
#use config file to define 403 and 405 errors as valid links
2929
#(APS blocks this link check)
3030
config-file: mlc_config.json
3131

32-
- name: Setup Mambaforge
33-
uses: conda-incubator/setup-miniconda@v2
32+
- name: Setup Conda
33+
uses: conda-incubator/setup-miniconda@v3
3434
with:
35-
miniforge-variant: Mambaforge
3635
miniforge-version: latest
3736
activate-environment: test-environment-v${{ matrix.qutip-version }}
38-
use-mamba: true
3937

4038
- name: Get Date
4139
id: get-date
4240
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')"
4341
shell: bash
4442

4543
- name: Cache Conda env
46-
uses: actions/cache@v2
44+
uses: actions/cache@v3
4745
with:
4846
path: ${{ env.CONDA }}/envs
4947
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('test_environment.yml') }}-${{ env.CACHE_NUMBER }}-qutip-${{ matrix.qutip-version }}
@@ -54,7 +52,7 @@ jobs:
5452

5553
- name: Install environment
5654
if: steps.cache.outputs.cache-hit != 'true'
57-
run: mamba env update -n test-environment-v${{ matrix.qutip-version }} -f test_environment-v${{ matrix.qutip-version }}.yml
55+
run: conda env update -n test-environment-v${{ matrix.qutip-version }} -f test_environment-v${{ matrix.qutip-version }}.yml
5856

5957
- name: Install QuTiP
6058
run: |
@@ -107,3 +105,20 @@ jobs:
107105
path: |
108106
notebooks/*.ipynb
109107
notebooks/**/*.ipynb
108+
109+
110+
finalise:
111+
needs: pytests
112+
if: failure()
113+
runs-on: ubuntu-latest
114+
steps:
115+
- uses: actions/checkout@v4
116+
- name: Open Issue on Failure
117+
env:
118+
GITHUB_TOKEN: ${{ github.token }}
119+
run: |
120+
if [[ -z "${{ inputs.open_issue }}" ]] || [[ "${{ inputs.open_issue }}" != "False" ]];
121+
then
122+
pip install requests
123+
python tools/report_failing_tests.py $GITHUB_TOKEN
124+
fi

Diff for: .github/workflows/notebook_ci.yaml

+7-9
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,29 @@ jobs:
2121
- qutip-version: '5'
2222
qutip-branch: 'master'
2323
steps:
24-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2525

2626
- uses: gaurav-nelson/github-action-markdown-link-check@v1
2727
with:
2828
use-quiet-mode: 'yes'
2929
folder-path: tutorials-v${{ matrix.qutip-version }}
30-
#use config file to define 403 and 405 errors as valid links
30+
#use config file to define 403 and 405 errors as valid links
3131
#(APS blocks this link check)
3232
config-file: mlc_config.json
3333

34-
- name: Setup Mambaforge
35-
uses: conda-incubator/setup-miniconda@v2
34+
- name: Setup Conda
35+
uses: conda-incubator/setup-miniconda@v3
3636
with:
37-
miniforge-variant: Mambaforge
3837
miniforge-version: latest
3938
activate-environment: test-environment-v${{ matrix.qutip-version }}
40-
use-mamba: true
4139

4240
- name: Get Date
4341
id: get-date
4442
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')"
4543
shell: bash
4644

4745
- name: Cache Conda env
48-
uses: actions/cache@v2
46+
uses: actions/cache@v3
4947
with:
5048
path: ${{ env.CONDA }}/envs
5149
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('test_environment.yml') }}-${{ env.CACHE_NUMBER }}-qutip-${{ matrix.qutip-version }}
@@ -56,7 +54,7 @@ jobs:
5654

5755
- name: Install environment
5856
if: steps.cache.outputs.cache-hit != 'true'
59-
run: mamba env update -n test-environment-v${{ matrix.qutip-version }} -f test_environment-v${{ matrix.qutip-version }}.yml
57+
run: conda env update -n test-environment-v${{ matrix.qutip-version }} -f test_environment-v${{ matrix.qutip-version }}.yml
6058

6159
- name: Install QuTiP
6260
run: |
@@ -114,7 +112,7 @@ jobs:
114112
runs-on: ubuntu-latest
115113
if: ${{ github.repository == 'qutip/qutip-tutorials' && github.ref == 'refs/heads/main' }}
116114
steps:
117-
- uses: actions/checkout@v3
115+
- uses: actions/checkout@v4
118116
- uses: actions/download-artifact@v4
119117
with:
120118
name: executed-notebooks-v4

Diff for: tools/report_failing_tests.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
import requests
3+
import json
4+
import sys
5+
import argparse
6+
from datetime import date
7+
8+
def open_issue(token):
9+
url = "https://api.github.com/repos/qutip/qutip-jax/issues"
10+
data = json.dumps({
11+
"title": f"Automated tests failed on {date.today()}",
12+
"labels": ["bug"],
13+
"body": "Scheduled test failed!"
14+
})
15+
16+
headers = {
17+
"Accept": "application/vnd.github.v3+json",
18+
"Authorization" : f"token {token}",
19+
}
20+
21+
post_request = requests.post(url=url, data=data, headers=headers)
22+
23+
if post_request.status_code == 201:
24+
print("Success")
25+
26+
else:
27+
print(
28+
"Fail:",
29+
post_request.status_code,
30+
post_request.reason,
31+
post_request.content
32+
)
33+
34+
35+
def main():
36+
parser = argparse.ArgumentParser(
37+
description="""Open an issue on failed tests."""
38+
)
39+
parser.add_argument("token")
40+
args = parser.parse_args()
41+
print(args.token)
42+
open_issue(args.token)
43+
44+
45+
if __name__ == "__main__":
46+
sys.exit(main())

Diff for: tutorials-v5/visualization/distributions.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
jupyter:
3+
jupytext:
4+
text_representation:
5+
extension: .md
6+
format_name: markdown
7+
format_version: '1.3'
8+
jupytext_version: 1.13.8
9+
kernelspec:
10+
display_name: Python 3 (ipykernel)
11+
language: python
12+
name: python3
13+
---
14+
15+
# Using qutip.distributions
16+
17+
Author: Mathis Beaudoin (2025)
18+
19+
### Introduction
20+
21+
This notebook shows how to use probability distributions inside QuTiP. We begin by importing the necessary packages.
22+
23+
```python
24+
from qutip import fock, about
25+
from qutip.distributions import HarmonicOscillatorWaveFunction
26+
from qutip.distributions import HarmonicOscillatorProbabilityFunction
27+
import matplotlib.pyplot as plt
28+
```
29+
30+
### Harmonic Oscillator Wave Function
31+
32+
Here, we display the spatial distribution of the wave function for the harmonic oscillator (n=0 to n=7) with the `HarmonicOscillatorWaveFunction()` class.
33+
34+
Optionally, define a range of values for each coordinate with the parameter called `extent`. Also, define a number of data points inside the given range with the optional parameter called `steps`. From this information, the distribution is generated and can be visualized with the `.visualize()` method.
35+
36+
```python
37+
M = 8
38+
N = 20
39+
40+
fig, ax = plt.subplots(M, 1, figsize=(10, 12), sharex=True)
41+
42+
for n in range(M):
43+
psi = fock(N, n)
44+
wf = HarmonicOscillatorWaveFunction(psi, 1.0, extent=[-10, 10])
45+
wf.visualize(fig=fig, ax=ax[M-n-1], show_ylabel=False, show_xlabel=(n == 0))
46+
```
47+
48+
### Harmonic Oscillator Probability Function
49+
50+
The class `HarmonicOscillatorProbabilityFunction()` is the squared magnitude of the data that would normally be in `HarmonicOscillatorWaveFunction()`. We use the same example as before.
51+
52+
```python
53+
M = 8
54+
N = 20
55+
56+
fig, ax = plt.subplots(M, 1, figsize=(10, 12), sharex=True)
57+
58+
for n in range(M):
59+
psi = fock(N, n)
60+
wf = HarmonicOscillatorProbabilityFunction(psi, 1.0, extent=[-10, 10])
61+
wf.visualize(fig=fig, ax=ax[M-n-1], show_ylabel=False, show_xlabel=(n == 0))
62+
```
63+
64+
### About
65+
66+
```python
67+
about()
68+
```

0 commit comments

Comments
 (0)