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
45c89d5d
Commit
45c89d5d
authored
2 years ago
by
David Hendriks
Browse files
Options
Downloads
Patches
Plain Diff
working on implementing the monte carlo generator
parent
68e82a11
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
binarycpython/utils/population_extensions/monte_carlo_sampling.py
+12
-12
12 additions, 12 deletions
...ython/utils/population_extensions/monte_carlo_sampling.py
with
12 additions
and
12 deletions
binarycpython/utils/population_extensions/monte_carlo_sampling.py
+
12
−
12
View file @
45c89d5d
...
@@ -93,20 +93,20 @@ class monte_carlo_sampling:
...
@@ -93,20 +93,20 @@ class monte_carlo_sampling:
self
.
_add_code
(
self
.
_add_code
(
# Write some info in the function
# Write some info in the function
"
# Grid code generated on {}
\n
"
.
format
(
datetime
.
datetime
.
now
().
isoformat
()),
"
# Grid code generated on {}
\n
"
.
format
(
datetime
.
datetime
.
now
().
isoformat
()),
"
# This function generates the systems that will be evolved with binary_c
\n\n
"
"
# This function generates the systems that will be evolved with binary_c
\n\n
"
,
# Set some values in the generated code:
# Set some values in the generated code:
"
# Set initial values
\n
"
,
"
# Set initial values
\n
"
,
"
_total_starcount = 0
\n
"
,
"
_total_starcount = 0
\n
"
,
"
parameter_dict = {}
\n
"
,
"
parameter_dict = {}
\n
\n
"
,
)
)
#########
#########
# Set up the loop and yield calls
# Set up the loop and yield calls
self
.
_add_code
(
self
.
_add_code
(
# Comment
# Comment
"
# Start of the while loop
"
"
# Start of the while loop
\n
"
,
# while loop
# while loop
"
while True:
"
"
while True:
\n
"
,
)
)
# Increase indent_depth
# Increase indent_depth
...
@@ -116,18 +116,18 @@ class monte_carlo_sampling:
...
@@ -116,18 +116,18 @@ class monte_carlo_sampling:
# Fill the while loop with a dummy sytem of a fixed mass
# Fill the while loop with a dummy sytem of a fixed mass
self
.
_add_code
(
self
.
_add_code
(
# Sample the variables
# Sample the variables
"
# Add M_1 variable
\n
"
"
# Add M_1 variable
\n
"
,
# while loop
# while loop
"
parameter_dict[
'
M_1
'
] = 1
\n\n
"
"
parameter_dict[
'
M_1
'
] = 1
\n\n
"
,
)
)
#########
#########
# Handle system yield
# Handle system yield
self
.
_add_code
(
self
.
_add_code
(
# Comment
# Comment
"
# Yield the system dict
\n
"
"
# Yield the system dict
\n
"
,
# while loop
# while loop
"
yield(parameter_dict)
\n
"
"
yield(parameter_dict)
\n
"
,
)
)
#################################################################################
#################################################################################
...
@@ -166,7 +166,7 @@ class monte_carlo_sampling:
...
@@ -166,7 +166,7 @@ class monte_carlo_sampling:
)
as
file
:
)
as
file
:
file
.
write
(
self
.
code_string
)
file
.
write
(
self
.
code_string
)
raise
NotImplementedError
(
"
This functionality is not available yet
"
)
#
raise NotImplementedError("This functionality is not available yet")
def
_monte_carlo_sampling_load_generator
(
self
):
def
_monte_carlo_sampling_load_generator
(
self
):
"""
"""
...
@@ -176,7 +176,7 @@ class monte_carlo_sampling:
...
@@ -176,7 +176,7 @@ class monte_carlo_sampling:
# Code to load the
# Code to load the
self
.
verbose_print
(
self
.
verbose_print
(
message
=
"
Load monte-carlo generator function from {file}
"
.
format
(
message
=
"
Load monte-carlo generator function from {file}
"
.
format
(
file
=
self
.
grid_options
[
"
_monte_carlo_generator_filename
"
]
file
=
self
.
grid_options
[
"
_monte_carlo_
sampling_
generator_filename
"
]
),
),
verbosity
=
self
.
grid_options
[
"
verbosity
"
],
verbosity
=
self
.
grid_options
[
"
verbosity
"
],
minimal_verbosity
=
1
,
minimal_verbosity
=
1
,
...
@@ -184,11 +184,11 @@ class monte_carlo_sampling:
...
@@ -184,11 +184,11 @@ class monte_carlo_sampling:
spec
=
importlib
.
util
.
spec_from_file_location
(
spec
=
importlib
.
util
.
spec_from_file_location
(
"
binary_c_python_monte_carlo_sampling_generator
"
,
"
binary_c_python_monte_carlo_sampling_generator
"
,
os
.
path
.
join
(
self
.
grid_options
[
"
monte_carlo_sampling_generator_filename
"
]),
os
.
path
.
join
(
self
.
grid_options
[
"
_
monte_carlo_sampling_generator_filename
"
]),
)
)
monte_carlo_sampling_generator_file
=
importlib
.
util
.
module_from_spec
(
spec
)
monte_carlo_sampling_generator_file
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
monte_carlo_sampling_generator_file
)
spec
.
loader
.
exec_module
(
monte_carlo_sampling_generator_file
)
generator
=
monte_carlo_sampling_generator_file
.
grid_code
generator
=
monte_carlo_sampling_generator_file
.
monte_carlo_generator
self
.
grid_options
[
"
_monte_carlo_sampling_generator
"
]
=
generator
self
.
grid_options
[
"
_monte_carlo_sampling_generator
"
]
=
generator
...
...
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