diff --git a/halotools/sim_manager/tests/test_user_supplied_halo_catalog.py b/halotools/sim_manager/tests/test_user_supplied_halo_catalog.py index 95bba46cf..256256a0d 100644 --- a/halotools/sim_manager/tests/test_user_supplied_halo_catalog.py +++ b/halotools/sim_manager/tests/test_user_supplied_halo_catalog.py @@ -463,3 +463,22 @@ def tearDown(self): shutil.rmtree(self.dummy_cache_baseloc) except: pass + + +def test_support_for_empty_halo_catalogs(): + """Regression test for #960.""" + Nhalos = 0 + Lbox = 100 + redshift = 0.0 + halo_x = np.linspace(0, Lbox, Nhalos) + halo_y = np.linspace(0, Lbox, Nhalos) + halo_z = np.linspace(0, Lbox, Nhalos) + halo_mass = np.logspace(10, 15, Nhalos) + halo_id = np.arange(0, Nhalos, dtype=np.int) + good_halocat_args = ( + {'halo_x': halo_x, 'halo_y': halo_y, + 'halo_z': halo_z, 'halo_id': halo_id, 'halo_mass': halo_mass} + ) + halocat = UserSuppliedHaloCatalog(Lbox=Lbox, particle_mass=100, redshift=0., + **good_halocat_args) + assert halocat.halo_table['halo_x'].shape == (0, ) diff --git a/halotools/sim_manager/user_supplied_halo_catalog.py b/halotools/sim_manager/user_supplied_halo_catalog.py index 1e5a6ef1d..1a0cadbd9 100644 --- a/halotools/sim_manager/user_supplied_halo_catalog.py +++ b/halotools/sim_manager/user_supplied_halo_catalog.py @@ -177,10 +177,8 @@ def _parse_constructor_kwargs(self, **kwargs): halo_id = np.array(kwargs['halo_id']) assert type(halo_id) is np.ndarray Nhalos = custom_len(halo_id) - assert Nhalos > 1 except KeyError: - msg = ("\nThe UserSuppliedHaloCatalog requires a ``halo_id`` keyword argument " - "storing an ndarray of length Nhalos > 1.\n") + msg = ("\nThe UserSuppliedHaloCatalog requires a ``halo_id`` keyword argument.") raise HalotoolsError(msg) halo_table_dict = (