Skip to content

Commit

Permalink
Merge pull request #1069 from aphearin/release_wheels
Browse files Browse the repository at this point in the history
Restore wheels.yml to build on release only
  • Loading branch information
aphearin committed Jun 30, 2023
2 parents 49fc413 + 1a7793d commit 305b75c
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 72 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Build wheels

on: [push, pull_request]
on:
workflow_dispatch:
release:
types:
- published

jobs:
build_wheels:
Expand Down
8 changes: 1 addition & 7 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
0.9 (unreleased)
----------------

- Add MBK10 model of non-Poisson satellite occupation statistics


0.8.2 (2023-09-30)
0.8.2 (unreleased)
------------------

- Add non-Poissonian occupation statistics for satellites (https://github.com/astropy/halotools/pull/1053)
Expand Down
28 changes: 13 additions & 15 deletions halotools/empirical_models/factories/tests/test_hod_mock_factory.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
"""
"""
from __future__ import absolute_import, division, print_function

from copy import deepcopy

import numpy as np
import pytest
from astropy.config.paths import _find_home
import numpy as np
from copy import deepcopy

from ....custom_exceptions import HalotoolsError
from ....empirical_models import (
AssembiasZheng07Cens,
AssembiasZheng07Sats,
HodModelFactory,
NFWPhaseSpace,
TrivialPhaseSpace,
)
from ....mock_observables import return_xyz_formatted_array, tpcf_one_two_halo_decomp


from ....empirical_models import AssembiasZheng07Cens
from ....empirical_models import TrivialPhaseSpace
from ....empirical_models import AssembiasZheng07Sats
from ....empirical_models import NFWPhaseSpace
from ....empirical_models import HodModelFactory

from ....sim_manager import FakeSim, CachedHaloCatalog
from ....sim_manager import CachedHaloCatalog, FakeSim
from ....sim_manager.fake_sim import FakeSimHalosNearBoundaries
from ..prebuilt_model_factory import PrebuiltHodModelFactory
from ....custom_exceptions import HalotoolsError

# Determine whether the machine is mine
# This will be used to select tests whose
Expand Down Expand Up @@ -54,7 +55,6 @@ def test_estimate_ngals1():


def test_estimate_ngals2():

model = PrebuiltHodModelFactory("tinker13")
halocat = FakeSim(seed=fixed_seed)
model.populate_mock(halocat, seed=fixed_seed)
Expand Down Expand Up @@ -235,7 +235,6 @@ def test_deterministic_mock_making():


def test_zero_satellite_edge_case():

model = PrebuiltHodModelFactory("zheng07", threshold=-18)
model.param_dict["logM0"] = 20

Expand All @@ -244,7 +243,6 @@ def test_zero_satellite_edge_case():


def test_zero_halo_edge_case():

model = PrebuiltHodModelFactory("zheng07", threshold=-18)
model.param_dict["logM0"] = 20

Expand Down
21 changes: 9 additions & 12 deletions halotools/sim_manager/tests/test_cached_halo_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"""
from __future__ import absolute_import, division, print_function

from unittest import TestCase
import os
import shutil
from unittest import TestCase

from astropy.config.paths import _find_home
from astropy.tests.helper import pytest
from astropy.table import Table
from astropy.tests.helper import pytest

try:
import h5py
Expand All @@ -19,17 +19,16 @@

import numpy as np

from . import helper_functions

from ..cached_halo_catalog import CachedHaloCatalog
from ..halo_table_cache import HaloTableCache
from ..ptcl_table_cache import PtclTableCache
from ..download_manager import DownloadManager
from ...custom_exceptions import HalotoolsError, InvalidCacheLogEntry
from ...utils.python_string_comparisons import (
compare_strings_py23_safe,
_passively_decode_string,
compare_strings_py23_safe,
)
from ...custom_exceptions import HalotoolsError, InvalidCacheLogEntry
from ..cached_halo_catalog import CachedHaloCatalog
from ..download_manager import DownloadManager
from ..halo_table_cache import HaloTableCache
from ..ptcl_table_cache import PtclTableCache
from . import helper_functions

# Determine whether the machine is mine
# This will be used to select tests whose
Expand Down Expand Up @@ -354,7 +353,6 @@ def test_acceptable_arguments6(self):

@pytest.mark.skipif("not APH_MACHINE")
def test_relocate_simulation_data(self):

dman = DownloadManager()
cache = HaloTableCache()

Expand Down Expand Up @@ -495,7 +493,6 @@ def test_relocate_simulation_data(self):
@pytest.mark.skipif("not HAS_H5PY")
@pytest.mark.skipif("not APH_MACHINE")
def test_user_supplied_ptcl_consistency(self):

from ..user_supplied_ptcl_catalog import UserSuppliedPtclCatalog

halocat = CachedHaloCatalog()
Expand Down
16 changes: 5 additions & 11 deletions halotools/sim_manager/tests/test_download_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@

import os
import shutil
from unittest import TestCase

import numpy as np
from astropy.config.paths import _find_home
from astropy.tests.helper import pytest
from astropy.table import Table
from unittest import TestCase
from astropy.tests.helper import pytest

from ...custom_exceptions import HalotoolsError
from .. import sim_defaults
from ..download_manager import DownloadManager
from ..halo_table_cache import HaloTableCache
from .. import sim_defaults
from ...custom_exceptions import HalotoolsError

# Determine whether the machine is mine
# This will be used to select tests whose
Expand All @@ -31,13 +32,11 @@

class TestDownloadManager(TestCase):
def setUp(self):

homedir = _find_home()

self.downman = DownloadManager()

def defensively_create_empty_dir(dirname):

if os.path.isdir(dirname) is False:
os.mkdir(dirname)
else:
Expand Down Expand Up @@ -143,7 +142,6 @@ def defensively_create_empty_dir(dirname):

@pytest.mark.skipif("not APH_MACHINE")
def test_ptcl_tables_available_for_download(self):

file_list = self.downman._ptcl_tables_available_for_download(simname="bolshoi")
assert len(file_list) == 1
assert "hlist_1.00035.particles.halotools_v0p4.hdf5" == os.path.basename(
Expand Down Expand Up @@ -188,23 +186,20 @@ def test_ptcl_tables_available_for_download(self):

@pytest.mark.skipif("not APH_MACHINE")
def test_processed_halo_tables_available_for_download1(self):

file_list = self.downman._processed_halo_tables_available_for_download(
simname="bolshoi", halo_finder="rockstar"
)
assert file_list != []

@pytest.mark.skipif("not APH_MACHINE")
def test_processed_halo_tables_available_for_download2(self):

file_list = self.downman._processed_halo_tables_available_for_download(
simname="bolshoi"
)
assert file_list != []

@pytest.mark.skipif("not APH_MACHINE")
def test_processed_halo_tables_available_for_download3(self):

file_list = self.downman._processed_halo_tables_available_for_download(
halo_finder="bdm"
)
Expand Down Expand Up @@ -350,7 +345,6 @@ def test_closest_ptcl_catalog_on_web(self):

@classmethod
def clear_APH_MACHINE_of_highz_file(self, delete_corresponding_halo_catalog=True):

cache = HaloTableCache()
matching_log_entries = cache.matching_log_entry_generator(
simname="bolshoi",
Expand Down
59 changes: 33 additions & 26 deletions halotools/sim_manager/tests/test_supported_sims.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
from __future__ import absolute_import, division, print_function, unicode_literals

import numpy as np

from astropy.config.paths import _find_home
import pytest

from ..cached_halo_catalog import CachedHaloCatalog, InvalidCacheLogEntry
from astropy.config.paths import _find_home

from ...custom_exceptions import HalotoolsError
from ..cached_halo_catalog import CachedHaloCatalog, InvalidCacheLogEntry

slow = pytest.mark.slow

aph_home = '/Users/aphearin'
aph_home = "/Users/aphearin"
detected_home = _find_home()
if aph_home == detected_home:
APH_MACHINE = True
Expand All @@ -22,89 +20,98 @@

try:
import h5py

HAS_H5PY = True
except ImportError:
HAS_H5PY = False

__all__ = ('test_load_halo_catalogs', 'test_halo_rvir_in_correct_units')
__all__ = ("test_load_halo_catalogs", "test_halo_rvir_in_correct_units")

adict = {'bolshoi': [0.33035, 0.54435, 0.67035, 1], 'bolplanck': [0.33406, 0.50112, 0.67, 1],
'consuelo': [0.333, 0.506, 0.6754, 1], 'multidark': [0.318, 0.5, 0.68, 1]}
adict = {
"bolshoi": [0.33035, 0.54435, 0.67035, 1],
"bolplanck": [0.33406, 0.50112, 0.67, 1],
"consuelo": [0.333, 0.506, 0.6754, 1],
"multidark": [0.318, 0.5, 0.68, 1],
}


@pytest.mark.slow
@pytest.mark.skipif('not APH_MACHINE')
@pytest.mark.skipif("not APH_MACHINE")
def test_load_halo_catalogs():
"""
"""
""" """

for simname in list(adict.keys()):
alist = adict[simname]
for a in alist:
z = 1/a - 1
z = 1 / a - 1
halocat = CachedHaloCatalog(simname=simname, redshift=z)
assert np.allclose(halocat.redshift, z, atol=0.01)

if simname not in ['bolshoi', 'multidark']:
if simname not in ["bolshoi", "multidark"]:
particles = halocat.ptcl_table
else:
if a == 1:
particles = halocat.ptcl_table


@pytest.mark.slow
@pytest.mark.skipif('not APH_MACHINE')
@pytest.mark.skipif("not APH_MACHINE")
def test_halo_rvir_in_correct_units():
""" Loop over all halo catalogs in cache and verify that the
"""Loop over all halo catalogs in cache and verify that the
``halo_rvir`` column never exeeds the number 50. This is a crude way of
ensuring that units are in Mpc/h, not kpc/h.
"""
for simname in list(adict.keys()):
alist = adict[simname]
a = alist[0]
z = 1/a - 1
z = 1 / a - 1
halocat = CachedHaloCatalog(simname=simname, redshift=z)
r = halocat.halo_table['halo_rvir']
assert np.all(r < 50.)
r = halocat.halo_table["halo_rvir"]
assert np.all(r < 50.0)


def test_bolplanck_particle_mass():
""" This is a regression test for https://github.com/astropy/halotools/issues/576
"""This is a regression test for https://github.com/astropy/halotools/issues/576
This test should never be deleted or refactored.
"""
from ..supported_sims import BolPlanck

bp = BolPlanck()
assert np.allclose(bp.particle_mass, 1.55e8, rtol=0.01)


@pytest.mark.skipif('not HAS_H5PY')
@pytest.mark.skipif("not HAS_H5PY")
def test_forbidden_sims():
""" This is a regression test that ensures no one will use the
"""This is a regression test that ensures no one will use the
z = 0 halotools_alpha_version2 halo catalog.
This test should never be deleted or refactored.
"""
with pytest.raises(HalotoolsError) as err:
__ = CachedHaloCatalog(simname='bolplanck', version_name='halotools_alpha_version2')
__ = CachedHaloCatalog(
simname="bolplanck", version_name="halotools_alpha_version2"
)
substr = "See https://github.com/astropy/halotools/issues/598"
assert substr in err.value.args[0]


def test_lbox_vector():
""" Ensure that the Lbox attribute of CachedHaloCatalog instances
"""Ensure that the Lbox attribute of CachedHaloCatalog instances
is always a 3-element vector.
"""
for simname in list(adict.keys()):
alist = adict[simname]
a = alist[0]
z = 1/a - 1
z = 1 / a - 1
try:
halocat = CachedHaloCatalog(simname=simname, redshift=z)
assert len(halocat.Lbox) == 3
except (InvalidCacheLogEntry, HalotoolsError, AssertionError):
if APH_MACHINE:
raise HalotoolsError("APH_MACHINE should never fail Lbox_vector test\n"
"simname = {0}\nscale factor = {1}".format(simname, a))
raise HalotoolsError(
"APH_MACHINE should never fail Lbox_vector test\n"
"simname = {0}\nscale factor = {1}".format(simname, a)
)
else:
pass

0 comments on commit 305b75c

Please sign in to comment.