From fde5cd797ec1239ca3fd4c030e46e0ccc7b38d4d Mon Sep 17 00:00:00 2001 From: "marcus.wirtz" Date: Mon, 16 Nov 2020 10:11:36 +0100 Subject: [PATCH] [simulations] Fix python2 integer divisions --- astrotools/simulations.py | 2 +- test/test_simulations.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/astrotools/simulations.py b/astrotools/simulations.py index 4ee19de..b878f94 100644 --- a/astrotools/simulations.py +++ b/astrotools/simulations.py @@ -1109,7 +1109,7 @@ class SourceGeometry: self.rmax = (3*self.n_src/4/np.pi/source_density)**(1/3.) else: assert not isinstance(source_density, np.ndarray), "Dont set 'rmax' when using a varying source denity!" - self.n_src = int(round(4/3*np.pi*self.rmax**3 * source_density)) + self.n_src = int(round(4/3.*np.pi*self.rmax**3 * source_density)) if sources is not None: assert np.all(sources.shape[-1] >= self.n_src), "Too few 'sources' for given keywords \ 'source_density' and 'rmax'!" diff --git a/test/test_simulations.py b/test/test_simulations.py index c4b8ab5..b3d107c 100644 --- a/test/test_simulations.py +++ b/test/test_simulations.py @@ -586,7 +586,7 @@ class TestSourceGeometry(unittest.TestCase): universe2.set_sources(source_density=1e-3, rmax=universe.rmax) self.assertTrue((universe2.n_src == self.n_src) and (universe.rmax == universe2.rmax)) - sources = coord.rand_vec(1000) * 30 * np.random.random((1, 1000))**(1/3) + sources = coord.rand_vec(1000) * 30 * np.random.random((1, 1000))**(1/3.) distances = np.sqrt(np.sum(sources**2, axis=0)) universe = SourceGeometry(self.nsets) universe.set_sources(source_density=1e-3, sources=sources, n_src=self.n_src) -- GitLab