-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into base-hamiltonian-class
- Loading branch information
Showing
8 changed files
with
299 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# For most projects, this workflow file will not need changing; you simply need | ||
# to commit it to your repository. | ||
# | ||
# You may wish to alter this file to override the set of languages analyzed, | ||
# or to provide custom queries or build logic. | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [main] | ||
schedule: | ||
- cron: '0 16 * * 4' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# Override automatic language detection by changing the below list | ||
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] | ||
language: ['python'] | ||
# Learn more... | ||
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
# We must fetch at least the immediate parents so that if this is | ||
# a pull request then we can checkout the head. | ||
fetch-depth: 2 | ||
|
||
# If this run was triggered by a pull request event, then checkout | ||
# the head of the pull request instead of the merge commit. | ||
- run: git checkout HEAD^2 | ||
if: ${{ github.event_name == 'pull_request' }} | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ${{ matrix.language }} | ||
# If you wish to specify custom queries, you can do so here or in a config file. | ||
# By default, queries listed here will override any specified in a config file. | ||
# Prefix the list here with "+" to use these queries and those in the config file. | ||
queries: +security-and-quality | ||
|
||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | ||
# If this step fails, then you should remove it and run the build manually (see below) | ||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v2 | ||
|
||
# ℹ️ Command-line programs to run using the OS shell. | ||
# 📚 https://git.io/JvXDl | ||
|
||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines | ||
# and modify them (or add more) to build your code if your project | ||
# uses a compiled language | ||
|
||
#- run: | | ||
# make bootstrap | ||
# make release | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 |
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,29 @@ | ||
name: test python | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened] | ||
push: | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
python-version: [3.8, 3.9, '3.10', 3.11] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip wheel setuptools | ||
python -m pip install --upgrade .[dev] | ||
- name: Test with pytest | ||
run: | | ||
pytest --color=yes |
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 was deleted.
Oops, something went wrong.
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,88 @@ | ||
"""smokescreen checks of mixed domain default hamiltonian integration""" | ||
import WrightSim as ws | ||
import numpy as np | ||
import pytest | ||
|
||
|
||
dt = 20 | ||
nt = 21 | ||
wn_to_omega = 2 * np.pi * 3e-5 # cm / fs | ||
w_central = 3000 # wn | ||
coupling = 0 # wn | ||
|
||
ham = ws.hamiltonian.Hamiltonian( | ||
w_central=w_central, | ||
coupling=coupling, | ||
tau=100, | ||
) | ||
ham.recorded_elements = [7, 8] | ||
|
||
|
||
@pytest.mark.skip("this test currently fails; bugfix needed") | ||
def test_windowed(): | ||
exp = ws.experiment.builtin('trive') | ||
exp.w1.points = w_central # wn | ||
exp.w2.points = w_central # wn | ||
exp.d2.points = 50 # np.zeros((1,)) # fs | ||
exp.d1.points = 0 # fs | ||
exp.s1.points = exp.s2.points = dt # fs | ||
|
||
exp.d1.active = exp.d2.active = False | ||
|
||
# 400 time points | ||
exp.timestep = 1 | ||
exp.early_buffer = 100. | ||
exp.late_buffer = 300. | ||
|
||
scan = exp.run(ham, mp=False) | ||
data = scan.sig | ||
|
||
# shift delay so emission is timed differently | ||
exp2 = ws.experiment.builtin('trive') | ||
exp2.w1.points = w_central # wn | ||
exp2.w2.points = w_central # wn | ||
exp2.d2.points = 50 # np.zeros((1,)) # fs | ||
exp2.d1.points = 0 # fs | ||
exp2.s1.points = exp2.s2.points = dt # fs | ||
|
||
exp2.d1.active = exp2.d2.active = False | ||
|
||
exp2.timestep = 1 | ||
exp2.early_buffer = 100. | ||
exp2.late_buffer = 300. | ||
|
||
scan2 = exp2.run(ham, mp=False, windowed=True) | ||
data2 = scan2.sig | ||
|
||
assert data2.time.size == data.time.size | ||
assert data2.time.size == data2.channels[0].size | ||
assert np.all(np.isclose(data2.channels[0][:], data.channels[0][:])) | ||
|
||
|
||
def test_frequency(): | ||
|
||
exp = ws.experiment.builtin('trive') | ||
exp.w1.points = w_central # wn | ||
exp.w2.points = w_central # wn | ||
exp.d2.points = 0 # np.zeros((1,)) # fs | ||
exp.d1.points = 0 # fs | ||
exp.s1.points = exp.s2.points = dt # fs | ||
|
||
exp.d1.active = exp.d2.active = False | ||
|
||
# 400 time points | ||
exp.timestep = 1 | ||
exp.early_buffer = 100. | ||
exp.late_buffer = 300. | ||
|
||
scan = exp.run(ham, mp=False) | ||
data = scan.sig | ||
wn = np.fft.fftfreq(n=data.time.size, d=exp.timestep) / 3e-5 | ||
sig_fft = np.abs(np.fft.fft(data.channels[0][:])) | ||
|
||
assert np.abs(wn[np.argmax(sig_fft)] + w_central) < np.abs(wn[1] - wn[0]) | ||
|
||
|
||
if __name__ == "__main__": | ||
test_windowed() # fails atm | ||
test_frequency() |
Oops, something went wrong.