Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
binary_c-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Izzard, Robert Dr (Maths & Physics)
binary_c-python
Commits
fbfba54f
Commit
fbfba54f
authored
5 years ago
by
David Hendriks
Browse files
Options
Downloads
Patches
Plain Diff
re-formatted
parent
b8bfcf50
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
binarycpython/utils/grid.py
+20
-10
20 additions, 10 deletions
binarycpython/utils/grid.py
examples/example_population.py
+2
-3
2 additions, 3 deletions
examples/example_population.py
with
22 additions
and
13 deletions
binarycpython/utils/grid.py
+
20
−
10
View file @
fbfba54f
...
...
@@ -379,7 +379,8 @@ class Population(object):
"""
# C_logging_code gets priority of C_autogen_code
if
self
.
grid_options
[
'
verbose
'
]
>
0
:
print
(
"
Creating and loading custom logging functionality
"
)
if
self
.
grid_options
[
"
verbose
"
]
>
0
:
print
(
"
Creating and loading custom logging functionality
"
)
#
if
self
.
grid_options
[
"
C_auto_logging
"
]:
...
...
@@ -458,7 +459,8 @@ class Population(object):
self
.
set_custom_logging
()
### Load store
if
self
.
grid_options
[
'
verbose
'
]
>
0
:
print
(
'
loading binary_c store information
'
)
if
self
.
grid_options
[
"
verbose
"
]
>
0
:
print
(
"
loading binary_c store information
"
)
self
.
grid_options
[
"
store_memaddr
"
]
=
binary_c_python_api
.
return_store
(
""
)
# Execute.
...
...
@@ -638,7 +640,8 @@ class Population(object):
Function to test the evolution of a system. Calls the api binding directly.
"""
if
self
.
grid_options
[
'
verbose
'
]
>
0
:
print
(
'
running a single system as a test
'
)
if
self
.
grid_options
[
"
verbose
"
]
>
0
:
print
(
"
running a single system as a test
"
)
m1
=
15.0
# Msun
m2
=
14.0
# Msun
...
...
@@ -680,7 +683,8 @@ class Population(object):
# TODO: add centering center left right for the spacing
"""
if
self
.
grid_options
[
'
verbose
'
]
>
0
:
print
(
"
Generating grid code
"
)
if
self
.
grid_options
[
"
verbose
"
]
>
0
:
print
(
"
Generating grid code
"
)
# Some local values
code_string
=
""
...
...
@@ -950,7 +954,8 @@ class Population(object):
# Stop of code generation. Here the code is saved and written
# Save the gridcode to the grid_options
if
self
.
grid_options
[
'
verbose
'
]
>
0
:
print
(
"
Saving grid code to grid_options
"
)
if
self
.
grid_options
[
"
verbose
"
]
>
0
:
print
(
"
Saving grid code to grid_options
"
)
self
.
grid_options
[
"
code_string
"
]
=
code_string
...
...
@@ -961,7 +966,8 @@ class Population(object):
)
self
.
grid_options
[
"
gridcode_filename
"
]
=
gridcode_filename
if
self
.
grid_options
[
'
verbose
'
]
>
0
:
print
(
"
Writing grid code to {}
"
.
format
(
gridcode_filename
))
if
self
.
grid_options
[
"
verbose
"
]
>
0
:
print
(
"
Writing grid code to {}
"
.
format
(
gridcode_filename
))
with
open
(
gridcode_filename
,
"
w
"
)
as
f
:
f
.
write
(
code_string
)
...
...
@@ -974,7 +980,12 @@ class Population(object):
# Code to load the
import
importlib.util
if
self
.
grid_options
[
'
verbose
'
]
>
0
:
print
(
"
Loading grid code function from {}
"
.
format
(
self
.
grid_options
[
'
gridcode_filename
'
]))
if
self
.
grid_options
[
"
verbose
"
]
>
0
:
print
(
"
Loading grid code function from {}
"
.
format
(
self
.
grid_options
[
"
gridcode_filename
"
]
)
)
spec
=
importlib
.
util
.
spec_from_file_location
(
"
binary_c_python_grid
"
,
...
...
@@ -984,9 +995,8 @@ class Population(object):
spec
.
loader
.
exec_module
(
grid_file
)
generator
=
grid_file
.
grid_code
(
self
)
if
self
.
grid_options
[
'
verbose
'
]
>
0
:
print
(
"
Grid code loaded
"
)
if
self
.
grid_options
[
"
verbose
"
]
>
0
:
print
(
"
Grid code loaded
"
)
print
(
next
(
generator
))
print
(
next
(
generator
))
...
...
This diff is collapsed.
Click to expand it.
examples/example_population.py
+
2
−
3
View file @
fbfba54f
...
...
@@ -85,7 +85,6 @@ example_pop.export_all_info()
# TODO: add example of running a population
# Wrapping up the results to an hdf5 file can be done by using the create_hdf5(<directory containing data and settings>)
# This function takes the settings file (ending in _settings.json) and the data files (ending in .dat) from the data_dir
# This function takes the settings file (ending in _settings.json) and the data files (ending in .dat) from the data_dir
# and packing them into an hdf5 file, which is then written into the same data_dir directory
create_hdf5
(
test_pop
.
custom_options
[
'
data_dir
'
])
create_hdf5
(
test_pop
.
custom_options
[
"
data_dir
"
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment