Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
astro
astrotools
Commits
fde5cd79
Commit
fde5cd79
authored
Nov 16, 2020
by
Marcus Wirtz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[simulations] Fix python2 integer divisions
parent
ea6f3278
Pipeline
#361214
passed with stages
in 6 minutes and 15 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
astrotools/simulations.py
astrotools/simulations.py
+1
-1
test/test_simulations.py
test/test_simulations.py
+1
-1
No files found.
astrotools/simulations.py
View file @
fde5cd79
...
@@ -1109,7 +1109,7 @@ class SourceGeometry:
...
@@ -1109,7 +1109,7 @@ class SourceGeometry:
self
.
rmax
=
(
3
*
self
.
n_src
/
4
/
np
.
pi
/
source_density
)
**
(
1
/
3.
)
self
.
rmax
=
(
3
*
self
.
n_src
/
4
/
np
.
pi
/
source_density
)
**
(
1
/
3.
)
else
:
else
:
assert
not
isinstance
(
source_density
,
np
.
ndarray
),
"Dont set 'rmax' when using a varying source denity!"
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
:
if
sources
is
not
None
:
assert
np
.
all
(
sources
.
shape
[
-
1
]
>=
self
.
n_src
),
"Too few 'sources' for given keywords
\
assert
np
.
all
(
sources
.
shape
[
-
1
]
>=
self
.
n_src
),
"Too few 'sources' for given keywords
\
'source_density' and 'rmax'!"
'source_density' and 'rmax'!"
...
...
test/test_simulations.py
View file @
fde5cd79
...
@@ -586,7 +586,7 @@ class TestSourceGeometry(unittest.TestCase):
...
@@ -586,7 +586,7 @@ class TestSourceGeometry(unittest.TestCase):
universe2
.
set_sources
(
source_density
=
1e-3
,
rmax
=
universe
.
rmax
)
universe2
.
set_sources
(
source_density
=
1e-3
,
rmax
=
universe
.
rmax
)
self
.
assertTrue
((
universe2
.
n_src
==
self
.
n_src
)
and
(
universe
.
rmax
==
universe2
.
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
))
distances
=
np
.
sqrt
(
np
.
sum
(
sources
**
2
,
axis
=
0
))
universe
=
SourceGeometry
(
self
.
nsets
)
universe
=
SourceGeometry
(
self
.
nsets
)
universe
.
set_sources
(
source_density
=
1e-3
,
sources
=
sources
,
n_src
=
self
.
n_src
)
universe
.
set_sources
(
source_density
=
1e-3
,
sources
=
sources
,
n_src
=
self
.
n_src
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment