Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ jobs:
run: python -m pip install --upgrade pip wheel setuptools Sphinx sphinx-rtd-theme
- name: Test the documentation
run: sphinx-build -W --keep-going -b html doc doc/_build/html
- name: Test building the documentation with "make"
run: cd doc && make html

style:
name: Style check
Expand Down
6 changes: 3 additions & 3 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXOPTS = --keep-going
# For macports, use the second line...
#SPHINXBUILD = sphinx-build
SPHINXBUILD = sphinx-build-2.7
SPHINXBUILD = sphinx-build
#SPHINXBUILD = sphinx-build-2.7
PAPER =
BUILDDIR = _build

Expand Down
9 changes: 9 additions & 0 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ desisim change log
0.39.0 (unreleased)
-------------------

Features:

* Support for more data releases on SurveyRelease/Quickquasars (PR `#590`_).

Test infrastructure:

* Remove DesiTest (PR `#582`_).
* Add numpy/2.x and scipy/1.16.x support. General cleanup. (PR `#589`_).
* Add astropy/7.x test support on GitHub (PR `#591`_).

.. _`#582`: https://github.com/desihub/desisim/pull/582
.. _`#589`: https://github.com/desihub/desisim/pull/589
.. _`#590`: https://github.com/desihub/desisim/pull/590
.. _`#591`: https://github.com/desihub/desisim/pull/591

0.38.2 (2024-12-17)
Expand Down
6 changes: 5 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@
# This value contains a list of modules to be mocked up. This is useful when
# some external dependencies are not met at build time and break the
# building process.
# Note: desitarget 3.2.0 removed desitarget.mock.mockmaker but this has not yet
# been removed from quickgalaxies and quicktransients, so we mock the submodules here for now.
autodoc_mock_imports = []
for missing in ('astropy', 'desimodel', 'desiutil', 'desispec', 'desisurvey', 'desitarget', 'fitsio',
for missing in ('astropy', 'desimodel', 'desiutil', 'desispec', 'desisurvey',
'desitarget', 'desitarget.mock', 'desitarget.mock.mockmaker',
'fitsio',
'healpy', 'matplotlib', 'numpy', 'scipy', 'simqso', 'speclite', 'specsim', 'yaml'):
try:
foo = import_module(missing)
Expand Down
1 change: 0 additions & 1 deletion py/desisim/qso_template/desi_qso_templ.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import numpy as np
import os
import imp
import pdb

from scipy.interpolate import interp1d
Expand Down
3 changes: 2 additions & 1 deletion py/desisim/scripts/quickgalaxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

from desisim.templates import BGS
from desisim.scripts.quickspectra import sim_spectra
from desitarget.mock.mockmaker import BGSMaker
from desitarget.mock.mockmaker import BGSMaker # requires desitarget<=3.2.0

from desitarget.cuts import isBGS_colors
from desiutil.log import get_logger, DEBUG

Expand Down
2 changes: 1 addition & 1 deletion py/desisim/scripts/quicktransients.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from desisim.templates import BGS, ELG, LRG
from desisim.transients import transients

from desitarget.mock.mockmaker import BGSMaker, ELGMaker, LRGMaker
from desitarget.mock.mockmaker import BGSMaker, ELGMaker, LRGMaker # requires desitarget<=3.2.0
from desitarget.cuts import isBGS_colors, isELG_colors, isLRG_colors

from desisim.simexp import reference_conditions
Expand Down
2 changes: 1 addition & 1 deletion py/desisim/spec_qa/redshifts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ def dz_summ(simz_tab, outfile=None, pdict=None, min_count=20):
if col > 0:
plt.setp([axis.get_yticklabels()], visible=False)
else:
axis.set_ylabel('Redshift fit residual $\Delta v$ [km/s]')
axis.set_ylabel(r'Redshift fit residual $\Delta v$ [km/s]')

#if row < nrows - 1:
# plt.setp([axis.get_xticklabels()], visible=False)
Expand Down
36 changes: 19 additions & 17 deletions py/desisim/test/test_batch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import tempfile
import unittest

from desisim.batch import calc_nodes
Expand All @@ -7,25 +8,26 @@
class TestBatch(unittest.TestCase):

def setUp(self):
self.batchfile = 'batch-d4ae52ada252.sh'
self._PIXPROD = os.getenv('PIXPROD')
self._DESI_SPECTRO_SIM = os.getenv('DESI_SPECTRO_SIM')
self.testdir = 'test-jkhasnqwezzcqhehadzx'
os.environ['PIXPROD'] = 'test'
os.environ['DESI_SPECTRO_SIM'] = self.testdir+'/sim'
os.environ['DESI_SPECTRO_DATA'] = self.testdir+'/sim/test'
self._tempdir = tempfile.TemporaryDirectory(prefix='desi_test_batch-')
self.testdir = self._tempdir.name
self.batchfile = os.path.join(self.testdir, 'batch.sh')
pixprod = os.path.basename(self.testdir)
self._origEnv = dict(
PIXPROD=os.getenv('PIXPROD'),
DESI_SPECTRO_SIM=os.getenv('DESI_SPECTRO_SIM'),
DESI_SPECTRO_DATA=os.getenv('DESI_SPECTRO_DATA'),
)
os.environ['PIXPROD'] = pixprod
os.environ['DESI_SPECTRO_SIM'] = os.path.join(self.testdir, 'sim')
os.environ['DESI_SPECTRO_DATA'] = os.path.join(self.testdir, 'sim', pixprod)

def tearDown(self):
if os.path.exists(self.batchfile):
os.remove(self.batchfile)
if self._PIXPROD is not None:
os.environ['PIXPROD'] = self._PIXPROD
if self._DESI_SPECTRO_SIM is not None:
os.environ['DESI_SPECTRO_SIM'] = os.getenv('DESI_SPECTRO_SIM')
if os.path.isdir(self.testdir):
import shutil
shutil.rmtree(self.testdir)
# os.removedirs(self.testdir)
for key, value in self._origEnv.items():
if value is None:
os.environ.pop(key, None)
else:
os.environ[key] = value
self._tempdir.cleanup()

def test_calc_nodes(self):
self.assertEqual(calc_nodes(10, 1.5, 10), 4)
Expand Down
47 changes: 20 additions & 27 deletions py/desisim/test/test_io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest, os
from uuid import uuid1
from shutil import rmtree
import tempfile

import numpy as np

Expand All @@ -14,36 +14,29 @@

class TestIO(unittest.TestCase):

#- Create unique test filename in a subdirectory
@classmethod
def setUpClass(cls):
cls.testfile = 'test-{uuid}/test-{uuid}.fits'.format(uuid=uuid1())
cls.testDir = os.path.join(os.environ['HOME'],'desi_test_io')
cls.origEnv = dict(PIXPROD = None, DESI_SPECTRO_SIM = None)
cls.testEnv = dict(
#- Create a unique test directory and filename for each test method
def setUp(self):
self._tempdir = tempfile.TemporaryDirectory(prefix='desi_test_io-')
self.testDir = self._tempdir.name
self.testfile = os.path.join(self.testDir, 'test-{uuid}.fits'.format(uuid=uuid1()))
self.origEnv = dict(PIXPROD = None, DESI_SPECTRO_SIM = None)
self.testEnv = dict(
PIXPROD = 'test',
DESI_SPECTRO_SIM = os.path.join(cls.testDir,'spectro','sim'),
DESI_SPECTRO_SIM = os.path.join(self.testDir,'spectro','sim'),
)
for e in cls.origEnv:
for e in self.origEnv:
if e in os.environ:
cls.origEnv[e] = os.environ[e]
os.environ[e] = cls.testEnv[e]

#- Cleanup test files if they exist
@classmethod
def tearDownClass(cls):
if os.path.exists(cls.testfile):
os.remove(cls.testfile)
testpath = os.path.normpath(os.path.dirname(cls.testfile))
if testpath != '.':
os.removedirs(testpath)
for e in cls.origEnv:
if cls.origEnv[e] is None:
del os.environ[e]
self.origEnv[e] = os.environ[e]
os.environ[e] = self.testEnv[e]

#- Cleanup test files and restore environment
def tearDown(self):
for e in self.origEnv:
if self.origEnv[e] is None:
os.environ.pop(e, None)
else:
os.environ[e] = cls.origEnv[e]
if os.path.exists(cls.testDir):
rmtree(cls.testDir)
os.environ[e] = self.origEnv[e]
self._tempdir.cleanup()

def test_simdir(self):
x = io.simdir()
Expand Down
53 changes: 18 additions & 35 deletions py/desisim/test/test_obs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import unittest, os
from uuid import uuid1
from shutil import rmtree
import tempfile
from importlib import resources

import numpy as np
Expand All @@ -15,45 +14,29 @@
desi_root_available = 'DESI_ROOT' in os.environ

class TestObs(unittest.TestCase):
#- Create test subdirectory
@classmethod
def setUpClass(cls):
cls.night = '20150101'
cls.testfile = 'test-{uuid}/test-{uuid}.fits'.format(uuid=uuid1())
cls.testDir = os.path.join(os.environ['HOME'],'desi_test_io')
cls.origEnv = dict(PIXPROD = None, DESI_SPECTRO_SIM = None)
cls.testEnv = dict(
#- Create isolated test directory and environment for each test method
def setUp(self):
self.night = '20150101'
self._tempdir = tempfile.TemporaryDirectory(prefix='desi_test_obs-')
self.testDir = self._tempdir.name
self.origEnv = dict(PIXPROD = None, DESI_SPECTRO_SIM = None)
self.testEnv = dict(
PIXPROD = 'test',
DESI_SPECTRO_SIM = os.path.join(cls.testDir,'spectro','sim'),
DESI_SPECTRO_SIM = os.path.join(self.testDir,'spectro','sim'),
)
for e in cls.origEnv:
for e in self.origEnv:
if e in os.environ:
cls.origEnv[e] = os.environ[e]
os.environ[e] = cls.testEnv[e]
self.origEnv[e] = os.environ[e]
os.environ[e] = self.testEnv[e]

#- Cleanup files but not directories after each test
#- Cleanup and restore environment after each test
def tearDown(self):
for expid in range(5):
for filetype in ['simspec', 'simfibermap']:
filename = io.findfile('simspec', self.night, expid)
if os.path.exists(filename):
os.remove(filename)

#- Cleanup test files if they exist
@classmethod
def tearDownClass(cls):
if os.path.exists(cls.testfile):
os.remove(cls.testfile)
testpath = os.path.normpath(os.path.dirname(cls.testfile))
if testpath != '.':
os.removedirs(testpath)
for e in cls.origEnv:
if cls.origEnv[e] is None:
del os.environ[e]
for e in self.origEnv:
if self.origEnv[e] is None:
os.environ.pop(e, None)
else:
os.environ[e] = cls.origEnv[e]
if os.path.exists(cls.testDir):
rmtree(cls.testDir)
os.environ[e] = self.origEnv[e]
self._tempdir.cleanup()

# def new_exposure(program, nspec=5000, night=None, expid=None, tileid=None, \
# airmass=1.0, exptime=None):
Expand Down
85 changes: 29 additions & 56 deletions py/desisim/test/test_pixsim.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import unittest, os, sys
import tempfile
from uuid import uuid1
from shutil import rmtree

import numpy as np
from astropy.io import fits
Expand All @@ -21,30 +19,9 @@
desi_root_available = 'DESI_ROOT' in os.environ

class TestPixsim(unittest.TestCase):
#- Create test subdirectory
#- Class-wide constants that do not write output
@classmethod
def setUpClass(cls):
global desi_templates_available
cls.testfile = 'test-{uuid}/test-{uuid}.fits'.format(uuid=uuid1())
cls.testdir = tempfile.mkdtemp()
cls.origEnv = dict(
PIXPROD = None,
SPECPROD = None,
DESI_SPECTRO_SIM = None,
DESI_SPECTRO_DATA = None,
DESI_SPECTRO_REDUX = None,
)
cls.testEnv = dict(
PIXPROD = 'test',
SPECPROD = 'test',
DESI_SPECTRO_SIM = os.path.join(cls.testdir,'spectro','sim'),
DESI_SPECTRO_DATA = os.path.join(cls.testdir,'spectro','sim', 'test'),
DESI_SPECTRO_REDUX = os.path.join(cls.testdir,'spectro','redux'),
)
for e in cls.origEnv:
if e in os.environ:
cls.origEnv[e] = os.environ[e]
os.environ[e] = cls.testEnv[e]
if desi_templates_available:
cls.cosmics = (os.environ['DESI_ROOT'] +
'/spectro/templates/cosmics/v0.3/cosmics-bias-r.fits')
Expand All @@ -54,23 +31,29 @@ def setUpClass(cls):
#- to save memory while testing
cls.ccdshape = (2000,2000)

#- Cleanup test files if they exist
@classmethod
def tearDownClass(cls):
if os.path.exists(cls.testfile):
os.remove(cls.testfile)
testpath = os.path.normpath(os.path.dirname(cls.testfile))
if testpath != '.':
os.removedirs(testpath)
for e in cls.origEnv:
if cls.origEnv[e] is None:
del os.environ[e]
else:
os.environ[e] = cls.origEnv[e]
if os.path.exists(cls.testdir):
rmtree(cls.testdir)

def setUp(self):
self._tempdir = tempfile.TemporaryDirectory(prefix='desi_test_pixsim-')
self.testdir = self._tempdir.name
pixprod = 'test-{}'.format(os.path.basename(self.testdir))
self.origEnv = dict(
PIXPROD = None,
SPECPROD = None,
DESI_SPECTRO_SIM = None,
DESI_SPECTRO_DATA = None,
DESI_SPECTRO_REDUX = None,
)
self.testEnv = dict(
PIXPROD = pixprod,
SPECPROD = pixprod,
DESI_SPECTRO_SIM = os.path.join(self.testdir,'spectro','sim'),
DESI_SPECTRO_DATA = os.path.join(self.testdir,'spectro','sim', pixprod),
DESI_SPECTRO_REDUX = os.path.join(self.testdir,'spectro','redux'),
)
for e in self.origEnv:
if e in os.environ:
self.origEnv[e] = os.environ[e]
os.environ[e] = self.testEnv[e]

self.night = '20150105'
self.expid = 124
for expid in (self.expid, self.expid+1):
Expand All @@ -80,22 +63,12 @@ def setUp(self):
os.makedirs(pixdir)

def tearDown(self):
rawfile = desispec.io.findfile('raw', self.night, self.expid)
if os.path.exists(rawfile):
os.remove(rawfile)
fibermap = desispec.io.findfile('fibermap', self.night, self.expid)
if os.path.exists(fibermap):
os.remove(fibermap)
simspecfile = io.findfile('simspec', self.night, self.expid)
if os.path.exists(simspecfile):
os.remove(simspecfile)
simpixfile = io.findfile('simpix', self.night, self.expid)
if os.path.exists(simpixfile):
os.remove(simpixfile)
for camera in ('b0', 'r0', 'z0'):
pixfile = desispec.io.findfile('preproc', self.night, self.expid, camera=camera)
if os.path.exists(pixfile):
os.remove(pixfile)
for e in self.origEnv:
if self.origEnv[e] is None:
os.environ.pop(e, None)
else:
os.environ[e] = self.origEnv[e]
self._tempdir.cleanup()


@unittest.skipUnless(desi_root_available, '$DESI_ROOT not set')
Expand Down
Loading
Loading