-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
4 changed files
with
144 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
import requests | ||
import json | ||
import sys | ||
import argparse | ||
from datetime import date | ||
|
||
def open_issue(token): | ||
url = "https://api.github.com/repos/qutip/qutip-jax/issues" | ||
data = json.dumps({ | ||
"title": f"Automated tests failed on {date.today()}", | ||
"labels": ["bug"], | ||
"body": "Scheduled test failed!" | ||
}) | ||
|
||
headers = { | ||
"Accept": "application/vnd.github.v3+json", | ||
"Authorization" : f"token {token}", | ||
} | ||
|
||
post_request = requests.post(url=url, data=data, headers=headers) | ||
|
||
if post_request.status_code == 201: | ||
print("Success") | ||
|
||
else: | ||
print( | ||
"Fail:", | ||
post_request.status_code, | ||
post_request.reason, | ||
post_request.content | ||
) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description="""Open an issue on failed tests.""" | ||
) | ||
parser.add_argument("token") | ||
args = parser.parse_args() | ||
print(args.token) | ||
open_issue(args.token) | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
jupyter: | ||
jupytext: | ||
text_representation: | ||
extension: .md | ||
format_name: markdown | ||
format_version: '1.3' | ||
jupytext_version: 1.13.8 | ||
kernelspec: | ||
display_name: Python 3 (ipykernel) | ||
language: python | ||
name: python3 | ||
--- | ||
|
||
# Using qutip.distributions | ||
|
||
Author: Mathis Beaudoin (2025) | ||
|
||
### Introduction | ||
|
||
This notebook shows how to use probability distributions inside QuTiP. We begin by importing the necessary packages. | ||
|
||
```python | ||
from qutip import fock, about | ||
from qutip.distributions import HarmonicOscillatorWaveFunction | ||
from qutip.distributions import HarmonicOscillatorProbabilityFunction | ||
import matplotlib.pyplot as plt | ||
``` | ||
|
||
### Harmonic Oscillator Wave Function | ||
|
||
Here, we display the spatial distribution of the wave function for the harmonic oscillator (n=0 to n=7) with the `HarmonicOscillatorWaveFunction()` class. | ||
|
||
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. | ||
|
||
```python | ||
M = 8 | ||
N = 20 | ||
|
||
fig, ax = plt.subplots(M, 1, figsize=(10, 12), sharex=True) | ||
|
||
for n in range(M): | ||
psi = fock(N, n) | ||
wf = HarmonicOscillatorWaveFunction(psi, 1.0, extent=[-10, 10]) | ||
wf.visualize(fig=fig, ax=ax[M-n-1], show_ylabel=False, show_xlabel=(n == 0)) | ||
``` | ||
|
||
### Harmonic Oscillator Probability Function | ||
|
||
The class `HarmonicOscillatorProbabilityFunction()` is the squared magnitude of the data that would normally be in `HarmonicOscillatorWaveFunction()`. We use the same example as before. | ||
|
||
```python | ||
M = 8 | ||
N = 20 | ||
|
||
fig, ax = plt.subplots(M, 1, figsize=(10, 12), sharex=True) | ||
|
||
for n in range(M): | ||
psi = fock(N, n) | ||
wf = HarmonicOscillatorProbabilityFunction(psi, 1.0, extent=[-10, 10]) | ||
wf.visualize(fig=fig, ax=ax[M-n-1], show_ylabel=False, show_xlabel=(n == 0)) | ||
``` | ||
|
||
### About | ||
|
||
```python | ||
about() | ||
``` |