diff --git a/.github/actions/install_requirements/action.yml b/.github/actions/install_requirements/action.yml index 25a146d1..c553af22 100644 --- a/.github/actions/install_requirements/action.yml +++ b/.github/actions/install_requirements/action.yml @@ -36,9 +36,9 @@ runs: shell: bash - name: Upload lockfiles - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: lockfiles + name: lockfiles_${{ github.job }}_${{ matrix.python }} path: lockfiles # This eliminates the class of problems where the requirements being given no diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml index 8e440c67..84f84584 100644 --- a/.github/workflows/code.yml +++ b/.github/workflows/code.yml @@ -32,7 +32,7 @@ jobs: fail-fast: false matrix: os: ["ubuntu-latest"] # can add windows-latest, macos-latest - python: ["3.7", "3.9", "3.10"] + python: ["3.9", "3.10"] install: ["-e .[dev]"] # Make one version be non-editable to test both paths of version code include: @@ -88,9 +88,9 @@ jobs: pipx run build - name: Upload sdist and wheel as artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: dist + name: dist_${{ github.job }}_${{ matrix.python }} path: dist - name: Check for packaging errors @@ -124,7 +124,7 @@ jobs: run: echo IMAGE_REPOSITORY=ghcr.io/$(tr '[:upper:]' '[:lower:]' <<< "${{ github.repository }}") >> $GITHUB_ENV - name: Download wheel and lockfiles - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: artifacts/ @@ -153,7 +153,7 @@ jobs: uses: docker/build-push-action@v3 with: build-args: | - PIP_OPTIONS=-r lockfiles/requirements.txt dist/*.whl + PIP_OPTIONS=-r lockfiles_dist_/requirements.txt dist_dist_/*.whl push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} load: ${{ ! (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) }} tags: ${{ steps.meta.outputs.tags }} @@ -177,11 +177,11 @@ jobs: HAS_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN != '' }} steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 - name: Fixup blank lockfiles # Github release artifacts can't be blank - run: for f in lockfiles/*; do [ -s $f ] || echo '# No requirements' >> $f; done + run: for f in lockfiles_dist_/*; do [ -s $f ] || echo '# No requirements' >> $f; done - name: Github Release # We pin to the SHA, not the tag, for security reasons. @@ -190,8 +190,8 @@ jobs: with: prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }} files: | - dist/* - lockfiles/* + dist_dist_/* + lockfiles_dist_/* generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/src/pytac/data/DIAD/simple_devices.csv b/src/pytac/data/DIAD/simple_devices.csv index 82423fcf..5c07eb33 100644 --- a/src/pytac/data/DIAD/simple_devices.csv +++ b/src/pytac/data/DIAD/simple_devices.csv @@ -1,2 +1,2 @@ el_id,field,value,readonly -0,energy,3000000000,True +0,energy,3000,True diff --git a/src/pytac/data/DIAD/uc_poly_data.csv b/src/pytac/data/DIAD/uc_poly_data.csv index 26ebb12e..576523da 100644 --- a/src/pytac/data/DIAD/uc_poly_data.csv +++ b/src/pytac/data/DIAD/uc_poly_data.csv @@ -1,6 +1,6 @@ uc_id,coeff,val 1,0,0.000000 -1,1,1e-06 +1,1,1e06 2,0,0.000000 2,1,1e-09 3,0,0.000000 diff --git a/src/pytac/data/DIAD/unitconv.csv b/src/pytac/data/DIAD/unitconv.csv index e69a7f55..2017dae5 100644 --- a/src/pytac/data/DIAD/unitconv.csv +++ b/src/pytac/data/DIAD/unitconv.csv @@ -4,7 +4,7 @@ el_id,field,uc_type,uc_id,phys_units,eng_units,lower_lim,upper_lim 0,dispersion,null,0,m,m,, 0,beam_current,null,0,A,A,, 1492,f,null,0,Hz,Hz,, -0,energy,poly,1,Gev,Mev,, +0,energy,poly,1,eV,MeV,, 0,emittance_x,poly,2,m,nm,, 0,emittance_y,poly,3,m,pm,, 5,b1,pchip,4,m^-2,A,0,200 diff --git a/src/pytac/data/DIADSP/simple_devices.csv b/src/pytac/data/DIADSP/simple_devices.csv index 82423fcf..5c07eb33 100644 --- a/src/pytac/data/DIADSP/simple_devices.csv +++ b/src/pytac/data/DIADSP/simple_devices.csv @@ -1,2 +1,2 @@ el_id,field,value,readonly -0,energy,3000000000,True +0,energy,3000,True diff --git a/src/pytac/data/DIADSP/uc_poly_data.csv b/src/pytac/data/DIADSP/uc_poly_data.csv index 26ebb12e..576523da 100644 --- a/src/pytac/data/DIADSP/uc_poly_data.csv +++ b/src/pytac/data/DIADSP/uc_poly_data.csv @@ -1,6 +1,6 @@ uc_id,coeff,val 1,0,0.000000 -1,1,1e-06 +1,1,1e06 2,0,0.000000 2,1,1e-09 3,0,0.000000 diff --git a/src/pytac/data/DIADSP/unitconv.csv b/src/pytac/data/DIADSP/unitconv.csv index e69a7f55..2017dae5 100644 --- a/src/pytac/data/DIADSP/unitconv.csv +++ b/src/pytac/data/DIADSP/unitconv.csv @@ -4,7 +4,7 @@ el_id,field,uc_type,uc_id,phys_units,eng_units,lower_lim,upper_lim 0,dispersion,null,0,m,m,, 0,beam_current,null,0,A,A,, 1492,f,null,0,Hz,Hz,, -0,energy,poly,1,Gev,Mev,, +0,energy,poly,1,eV,MeV,, 0,emittance_x,poly,2,m,nm,, 0,emittance_y,poly,3,m,pm,, 5,b1,pchip,4,m^-2,A,0,200 diff --git a/src/pytac/data/DIADTHz/simple_devices.csv b/src/pytac/data/DIADTHz/simple_devices.csv index 82423fcf..5c07eb33 100644 --- a/src/pytac/data/DIADTHz/simple_devices.csv +++ b/src/pytac/data/DIADTHz/simple_devices.csv @@ -1,2 +1,2 @@ el_id,field,value,readonly -0,energy,3000000000,True +0,energy,3000,True diff --git a/src/pytac/data/DIADTHz/uc_poly_data.csv b/src/pytac/data/DIADTHz/uc_poly_data.csv index 26ebb12e..576523da 100644 --- a/src/pytac/data/DIADTHz/uc_poly_data.csv +++ b/src/pytac/data/DIADTHz/uc_poly_data.csv @@ -1,6 +1,6 @@ uc_id,coeff,val 1,0,0.000000 -1,1,1e-06 +1,1,1e06 2,0,0.000000 2,1,1e-09 3,0,0.000000 diff --git a/src/pytac/data/DIADTHz/unitconv.csv b/src/pytac/data/DIADTHz/unitconv.csv index e69a7f55..2017dae5 100644 --- a/src/pytac/data/DIADTHz/unitconv.csv +++ b/src/pytac/data/DIADTHz/unitconv.csv @@ -4,7 +4,7 @@ el_id,field,uc_type,uc_id,phys_units,eng_units,lower_lim,upper_lim 0,dispersion,null,0,m,m,, 0,beam_current,null,0,A,A,, 1492,f,null,0,Hz,Hz,, -0,energy,poly,1,Gev,Mev,, +0,energy,poly,1,eV,MeV,, 0,emittance_x,poly,2,m,nm,, 0,emittance_y,poly,3,m,pm,, 5,b1,pchip,4,m^-2,A,0,200 diff --git a/src/pytac/data/I04/simple_devices.csv b/src/pytac/data/I04/simple_devices.csv index 82423fcf..5c07eb33 100644 --- a/src/pytac/data/I04/simple_devices.csv +++ b/src/pytac/data/I04/simple_devices.csv @@ -1,2 +1,2 @@ el_id,field,value,readonly -0,energy,3000000000,True +0,energy,3000,True diff --git a/src/pytac/data/I04/uc_poly_data.csv b/src/pytac/data/I04/uc_poly_data.csv index 779c4447..79e2299a 100644 --- a/src/pytac/data/I04/uc_poly_data.csv +++ b/src/pytac/data/I04/uc_poly_data.csv @@ -1,6 +1,6 @@ uc_id,coeff,val 1,0,0.000000 -1,1,1e-06 +1,1,1e06 2,0,0.000000 2,1,1e-09 3,0,0.000000 diff --git a/src/pytac/data/I04/unitconv.csv b/src/pytac/data/I04/unitconv.csv index 748170a5..ab7a84c3 100644 --- a/src/pytac/data/I04/unitconv.csv +++ b/src/pytac/data/I04/unitconv.csv @@ -4,7 +4,7 @@ el_id,field,uc_type,uc_id,phys_units,eng_units,lower_lim,upper_lim 0,dispersion,null,0,m,m,, 0,beam_current,null,0,A,A,, 1510,f,null,0,Hz,Hz,, -0,energy,poly,1,Gev,Mev,, +0,energy,poly,1,eV,MeV,, 0,emittance_x,poly,2,m,nm,, 0,emittance_y,poly,3,m,pm,, 5,b1,pchip,4,m^-2,A,0,200 diff --git a/src/pytac/data/I04SP/simple_devices.csv b/src/pytac/data/I04SP/simple_devices.csv index 82423fcf..5c07eb33 100644 --- a/src/pytac/data/I04SP/simple_devices.csv +++ b/src/pytac/data/I04SP/simple_devices.csv @@ -1,2 +1,2 @@ el_id,field,value,readonly -0,energy,3000000000,True +0,energy,3000,True diff --git a/src/pytac/data/I04SP/uc_poly_data.csv b/src/pytac/data/I04SP/uc_poly_data.csv index 779c4447..79e2299a 100644 --- a/src/pytac/data/I04SP/uc_poly_data.csv +++ b/src/pytac/data/I04SP/uc_poly_data.csv @@ -1,6 +1,6 @@ uc_id,coeff,val 1,0,0.000000 -1,1,1e-06 +1,1,1e06 2,0,0.000000 2,1,1e-09 3,0,0.000000 diff --git a/src/pytac/data/I04SP/unitconv.csv b/src/pytac/data/I04SP/unitconv.csv index 748170a5..ab7a84c3 100644 --- a/src/pytac/data/I04SP/unitconv.csv +++ b/src/pytac/data/I04SP/unitconv.csv @@ -4,7 +4,7 @@ el_id,field,uc_type,uc_id,phys_units,eng_units,lower_lim,upper_lim 0,dispersion,null,0,m,m,, 0,beam_current,null,0,A,A,, 1510,f,null,0,Hz,Hz,, -0,energy,poly,1,Gev,Mev,, +0,energy,poly,1,eV,MeV,, 0,emittance_x,poly,2,m,nm,, 0,emittance_y,poly,3,m,pm,, 5,b1,pchip,4,m^-2,A,0,200 diff --git a/src/pytac/data/I04THz/simple_devices.csv b/src/pytac/data/I04THz/simple_devices.csv index 82423fcf..5c07eb33 100644 --- a/src/pytac/data/I04THz/simple_devices.csv +++ b/src/pytac/data/I04THz/simple_devices.csv @@ -1,2 +1,2 @@ el_id,field,value,readonly -0,energy,3000000000,True +0,energy,3000,True diff --git a/src/pytac/data/I04THz/uc_poly_data.csv b/src/pytac/data/I04THz/uc_poly_data.csv index 779c4447..79e2299a 100644 --- a/src/pytac/data/I04THz/uc_poly_data.csv +++ b/src/pytac/data/I04THz/uc_poly_data.csv @@ -1,6 +1,6 @@ uc_id,coeff,val 1,0,0.000000 -1,1,1e-06 +1,1,1e06 2,0,0.000000 2,1,1e-09 3,0,0.000000 diff --git a/src/pytac/data/I04THz/unitconv.csv b/src/pytac/data/I04THz/unitconv.csv index 748170a5..ab7a84c3 100644 --- a/src/pytac/data/I04THz/unitconv.csv +++ b/src/pytac/data/I04THz/unitconv.csv @@ -4,7 +4,7 @@ el_id,field,uc_type,uc_id,phys_units,eng_units,lower_lim,upper_lim 0,dispersion,null,0,m,m,, 0,beam_current,null,0,A,A,, 1510,f,null,0,Hz,Hz,, -0,energy,poly,1,Gev,Mev,, +0,energy,poly,1,eV,MeV,, 0,emittance_x,poly,2,m,nm,, 0,emittance_y,poly,3,m,pm,, 5,b1,pchip,4,m^-2,A,0,200 diff --git a/src/pytac/data/SRI0913_MOGA/simple_devices.csv b/src/pytac/data/SRI0913_MOGA/simple_devices.csv index 82423fcf..5c07eb33 100644 --- a/src/pytac/data/SRI0913_MOGA/simple_devices.csv +++ b/src/pytac/data/SRI0913_MOGA/simple_devices.csv @@ -1,2 +1,2 @@ el_id,field,value,readonly -0,energy,3000000000,True +0,energy,3000,True diff --git a/src/pytac/data/SRI0913_MOGA/uc_poly_data.csv b/src/pytac/data/SRI0913_MOGA/uc_poly_data.csv index 26ebb12e..576523da 100644 --- a/src/pytac/data/SRI0913_MOGA/uc_poly_data.csv +++ b/src/pytac/data/SRI0913_MOGA/uc_poly_data.csv @@ -1,6 +1,6 @@ uc_id,coeff,val 1,0,0.000000 -1,1,1e-06 +1,1,1e06 2,0,0.000000 2,1,1e-09 3,0,0.000000 diff --git a/src/pytac/data/SRI0913_MOGA/unitconv.csv b/src/pytac/data/SRI0913_MOGA/unitconv.csv index e69a7f55..2017dae5 100644 --- a/src/pytac/data/SRI0913_MOGA/unitconv.csv +++ b/src/pytac/data/SRI0913_MOGA/unitconv.csv @@ -4,7 +4,7 @@ el_id,field,uc_type,uc_id,phys_units,eng_units,lower_lim,upper_lim 0,dispersion,null,0,m,m,, 0,beam_current,null,0,A,A,, 1492,f,null,0,Hz,Hz,, -0,energy,poly,1,Gev,Mev,, +0,energy,poly,1,eV,MeV,, 0,emittance_x,poly,2,m,nm,, 0,emittance_y,poly,3,m,pm,, 5,b1,pchip,4,m^-2,A,0,200 diff --git a/src/pytac/data/VMX/simple_devices.csv b/src/pytac/data/VMX/simple_devices.csv index 82423fcf..5c07eb33 100644 --- a/src/pytac/data/VMX/simple_devices.csv +++ b/src/pytac/data/VMX/simple_devices.csv @@ -1,2 +1,2 @@ el_id,field,value,readonly -0,energy,3000000000,True +0,energy,3000,True diff --git a/src/pytac/data/VMX/uc_poly_data.csv b/src/pytac/data/VMX/uc_poly_data.csv index c1632fe0..eaf31e7a 100644 --- a/src/pytac/data/VMX/uc_poly_data.csv +++ b/src/pytac/data/VMX/uc_poly_data.csv @@ -1,6 +1,6 @@ uc_id,coeff,val 1,0,0.000000 -1,1,1e-06 +1,1,1e06 2,0,0.000000 2,1,1e-09 3,0,0.000000 diff --git a/src/pytac/data/VMX/unitconv.csv b/src/pytac/data/VMX/unitconv.csv index 559357cb..05397d82 100644 --- a/src/pytac/data/VMX/unitconv.csv +++ b/src/pytac/data/VMX/unitconv.csv @@ -4,7 +4,7 @@ el_id,field,uc_type,uc_id,phys_units,eng_units,lower_lim,upper_lim 0,dispersion,null,0,m,m,, 0,beam_current,null,0,A,A,, 1490,f,null,0,Hz,Hz,, -0,energy,poly,1,Gev,Mev,, +0,energy,poly,1,eV,MeV,, 0,emittance_x,poly,2,m,nm,, 0,emittance_y,poly,3,m,pm,, 5,b1,pchip,4,m^-2,A,0,200 diff --git a/src/pytac/data/VMXSP/simple_devices.csv b/src/pytac/data/VMXSP/simple_devices.csv index 82423fcf..5c07eb33 100644 --- a/src/pytac/data/VMXSP/simple_devices.csv +++ b/src/pytac/data/VMXSP/simple_devices.csv @@ -1,2 +1,2 @@ el_id,field,value,readonly -0,energy,3000000000,True +0,energy,3000,True diff --git a/src/pytac/data/VMXSP/uc_poly_data.csv b/src/pytac/data/VMXSP/uc_poly_data.csv index c1632fe0..eaf31e7a 100644 --- a/src/pytac/data/VMXSP/uc_poly_data.csv +++ b/src/pytac/data/VMXSP/uc_poly_data.csv @@ -1,6 +1,6 @@ uc_id,coeff,val 1,0,0.000000 -1,1,1e-06 +1,1,1e06 2,0,0.000000 2,1,1e-09 3,0,0.000000 diff --git a/src/pytac/data/VMXSP/unitconv.csv b/src/pytac/data/VMXSP/unitconv.csv index 559357cb..05397d82 100644 --- a/src/pytac/data/VMXSP/unitconv.csv +++ b/src/pytac/data/VMXSP/unitconv.csv @@ -4,7 +4,7 @@ el_id,field,uc_type,uc_id,phys_units,eng_units,lower_lim,upper_lim 0,dispersion,null,0,m,m,, 0,beam_current,null,0,A,A,, 1490,f,null,0,Hz,Hz,, -0,energy,poly,1,Gev,Mev,, +0,energy,poly,1,eV,MeV,, 0,emittance_x,poly,2,m,nm,, 0,emittance_y,poly,3,m,pm,, 5,b1,pchip,4,m^-2,A,0,200 diff --git a/src/pytac/data/VMXTHz/simple_devices.csv b/src/pytac/data/VMXTHz/simple_devices.csv index 82423fcf..5c07eb33 100644 --- a/src/pytac/data/VMXTHz/simple_devices.csv +++ b/src/pytac/data/VMXTHz/simple_devices.csv @@ -1,2 +1,2 @@ el_id,field,value,readonly -0,energy,3000000000,True +0,energy,3000,True diff --git a/src/pytac/data/VMXTHz/uc_poly_data.csv b/src/pytac/data/VMXTHz/uc_poly_data.csv index c1632fe0..eaf31e7a 100644 --- a/src/pytac/data/VMXTHz/uc_poly_data.csv +++ b/src/pytac/data/VMXTHz/uc_poly_data.csv @@ -1,6 +1,6 @@ uc_id,coeff,val 1,0,0.000000 -1,1,1e-06 +1,1,1e06 2,0,0.000000 2,1,1e-09 3,0,0.000000 diff --git a/src/pytac/data/VMXTHz/unitconv.csv b/src/pytac/data/VMXTHz/unitconv.csv index 559357cb..05397d82 100644 --- a/src/pytac/data/VMXTHz/unitconv.csv +++ b/src/pytac/data/VMXTHz/unitconv.csv @@ -4,7 +4,7 @@ el_id,field,uc_type,uc_id,phys_units,eng_units,lower_lim,upper_lim 0,dispersion,null,0,m,m,, 0,beam_current,null,0,A,A,, 1490,f,null,0,Hz,Hz,, -0,energy,poly,1,Gev,Mev,, +0,energy,poly,1,eV,MeV,, 0,emittance_x,poly,2,m,nm,, 0,emittance_y,poly,3,m,pm,, 5,b1,pchip,4,m^-2,A,0,200 diff --git a/src/pytac/data/utils/load_mml.m b/src/pytac/data/utils/load_mml.m index 0d5514a0..a1f82085 100644 --- a/src/pytac/data/utils/load_mml.m +++ b/src/pytac/data/utils/load_mml.m @@ -43,7 +43,7 @@ function load_mml(ringmode) ao = getao(); % Hard-coded beam energy value. - fprintf(f_simple_devices, '0,energy,3e9,True\n'); + fprintf(f_simple_devices, '0,energy,3000,True\n'); % The individual BPM PVs are not stored in middlelayer. BPMS = get_bpm_pvs(ao); diff --git a/src/pytac/data/utils/load_unitconv.m b/src/pytac/data/utils/load_unitconv.m index d201e0b0..3a71e86e 100644 --- a/src/pytac/data/utils/load_unitconv.m +++ b/src/pytac/data/utils/load_unitconv.m @@ -48,9 +48,9 @@ function load_unitconv(ringmode, renamedIndexes) % Unit conversions for lattice fields % the conversion limits are '' as these fields don't have a Setpoint field uc_id = uc_id + 1; -fprintf(f_units, '%d,%s,poly,%d,%s,%s,%s,%s\n', 0, 'energy', uc_id, 'Gev', 'Mev', '', ''); +fprintf(f_units, '%d,%s,poly,%d,%s,%s,%s,%s\n', 0, 'energy', uc_id, 'eV', 'MeV', '', ''); fprintf(f_poly, '%d,%d,%f\n', uc_id, 0, 0); -fprintf(f_poly, '%d,%d,%g\n', uc_id, 1, 1e-6); +fprintf(f_poly, '%d,%d,%g\n', uc_id, 1, 1e6); uc_id = uc_id + 1; fprintf(f_units, '%d,%s,poly,%d,%s,%s,%s,%s\n', 0, 'emittance_x', uc_id, 'm', 'nm', '', ''); fprintf(f_poly, '%d,%d,%f\n', uc_id, 0, 0); diff --git a/src/pytac/lattice.py b/src/pytac/lattice.py index 033ca142..bbd1bfbb 100644 --- a/src/pytac/lattice.py +++ b/src/pytac/lattice.py @@ -1,5 +1,5 @@ """Representation of a lattice object which contains all the elements of the - machine. +machine. """ import logging diff --git a/src/pytac/load_csv.py b/src/pytac/load_csv.py index 2bb8b4c9..0cb19055 100644 --- a/src/pytac/load_csv.py +++ b/src/pytac/load_csv.py @@ -16,8 +16,9 @@ import copy import csv import logging +import os from pathlib import Path -from typing import Dict, Iterator +from typing import Dict, Iterator, Set import pytac from pytac import data_source, element, utils @@ -166,7 +167,7 @@ def load_unitconv(mode_dir: Path, lattice: Lattice) -> None: # TODO: This should probably be moved into the .csv files somewhere. rigidity_families = {"hstr", "vstr", "quadrupole", "sextupole", "bend"} if item["uc_type"] != "null" and element._families & rigidity_families: - energy = lattice.get_value("energy", units=pytac.PHYS) + energy = lattice.get_value("energy", units=pytac.ENG) uc.set_post_eng_to_phys(utils.get_div_rigidity(energy)) uc.set_pre_phys_to_eng(utils.get_mult_rigidity(energy)) element.set_unitconv(item["field"], uc) @@ -263,3 +264,35 @@ def load(mode, control_system=None, directory=None, symmetry=None) -> EpicsLatti if unitconv_file.exists(): load_unitconv(mode_dir, lat) return lat + + +def available_ringmodes(directory=None) -> Set[str]: + """Return the possible ringmodes based on the subdirectories and files in + the given directory. + + .. Note:: It is not guaranteed that the modes returned will be able to be + successfully loaded due to errors, missing data, etc. I.e., any mode + that can be loaded will always be returned, but modes that can't be + loaded might also sometimes be returned. + + Args: + directory (str): The data directory to check inside. If no directory + is given the default data directory location is used. + + Returns: + set[str]: A set of possible ringmodes. + + Raises: + OSError: if no ringmodes can be found in the specified directory. + """ + if directory is None: + directory = Path(__file__).resolve().parent / "data" + modes = set() + for directory_object in os.scandir(directory): + if directory_object.is_dir(): + contents = os.listdir(directory_object.path) + if ELEMENTS_FILENAME in contents and FAMILIES_FILENAME in contents: + modes.add(directory_object.name) + if not modes: + raise OSError(f"No ringmodes found in {os.path.realpath(directory)}") + return modes diff --git a/tests/test_load.py b/tests/test_load.py index b7d91381..eb82bb1d 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -1,10 +1,11 @@ +from pathlib import Path from unittest.mock import patch import pytest from testfixtures import LogCapture import pytac -from pytac.load_csv import load, load_unitconv, resolve_unitconv +from pytac.load_csv import available_ringmodes, load, load_unitconv, resolve_unitconv @pytest.fixture @@ -130,3 +131,24 @@ def test_resolve_unitconv_raises_UnitsException_if_unrecognised_UnitConv_type( } with pytest.raises(pytac.exceptions.UnitsException): resolve_unitconv(uc_params, {}, polyconv_file, pchipconv_file) + + +def test_available_ringmodes(): + ringmodes = { + "SRI0913_MOGA", + "I04", + "VMX", + "DIAD", + "VMXSP", + "VMXTHz", + "DIADSP", + "DIADTHz", + "I04SP", + "I04THz", + } + assert available_ringmodes() == ringmodes + bad_path = Path(__file__).resolve().parent.parent + with pytest.raises(OSError): + available_ringmodes(bad_path) + good_path = bad_path / "src/pytac/data" + assert available_ringmodes(good_path) == ringmodes diff --git a/tests/test_machine.py b/tests/test_machine.py index 14b7c001..6581499d 100644 --- a/tests/test_machine.py +++ b/tests/test_machine.py @@ -1,6 +1,6 @@ -""" This file tests the entire loading of the DLS machine from the CSV - files in the data directory. These are more like integration tests, - and allows us to check that the pytac setup is working correctly. +"""This file tests the entire loading of the DLS machine from the CSV +files in the data directory. These are more like integration tests, +and allows us to check that the pytac setup is working correctly. """ import re