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
e49cb1ac
Commit
e49cb1ac
authored
4 years ago
by
David Hendriks
Browse files
Options
Downloads
Patches
Plain Diff
will go and separate the test cases and fixing the memory allocs
parent
f0f43af2
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
src/binary_c_python_api.c
+15
-35
15 additions, 35 deletions
src/binary_c_python_api.c
tests/test_run_system.py
+34
-0
34 additions, 0 deletions
tests/test_run_system.py
with
49 additions
and
35 deletions
src/binary_c_python_api.c
+
15
−
35
View file @
e49cb1ac
...
@@ -71,7 +71,8 @@ int run_system(char * argstring,
...
@@ -71,7 +71,8 @@ int run_system(char * argstring,
store
=
NULL
;
store
=
NULL
;
}
}
struct
persistent_data_t
*
persistent_data
;
// persistent_data
struct
persistent_data_t
*
persistent_data
=
NULL
;
/* make new stardata */
/* make new stardata */
stardata
=
NULL
;
stardata
=
NULL
;
...
@@ -79,7 +80,7 @@ int run_system(char * argstring,
...
@@ -79,7 +80,7 @@ int run_system(char * argstring,
NULL
,
// previous_stardatas
NULL
,
// previous_stardatas
NULL
,
// preferences
NULL
,
// preferences
&
store
,
// store
&
store
,
// store
NULL
,
// persistent_data TODO: see if this use is correct
&
persistent_data
,
// persistent_data TODO: see if this use is correct
&
argstring
,
// argv
&
argstring
,
// argv
-
1
// argc
-
1
// argc
);
);
...
@@ -117,26 +118,23 @@ int run_system(char * argstring,
...
@@ -117,26 +118,23 @@ int run_system(char * argstring,
/* get error buffer pointer */
/* get error buffer pointer */
binary_c_error_buffer
(
stardata
,
error_buffer
);
binary_c_error_buffer
(
stardata
,
error_buffer
);
/* set raw_buffer_size = -1 to prevent it being freed */
/* Determine whether to free the store memory adress*/
stardata
->
tmpstore
->
raw_buffer_size
=
-
1
;
Boolean
free_store
=
FALSE
;
if
(
store_memaddr
==
-
1
)
{
Boolean
free_store
=
TRUE
;
}
/* free stardata (except the buffer) */
/* free stardata (except the buffer) */
binary_c_free_memory
(
&
stardata
,
// Stardata
binary_c_free_memory
(
&
stardata
,
// Stardata
TRUE
,
// free_preferences
TRUE
,
// free_preferences
TRUE
,
// free_stardata
TRUE
,
// free_stardata
FALSE
,
// free_store
free_store
,
// free_store
FALSE
,
// free_raw_buffer
FALSE
,
// free_raw_buffer
TRUE
// free_persistent TODO: check if this is correct here
TRUE
// free_persistent TODO: check if this is correct here
);
);
// add flag or logic to free store contents.
if
(
store_memaddr
==
-
1
)
{
binary_c_free_store_contents
(
store
);
}
// TODO: Ask rob whether to free the memory here or not? or to free it manually.
return
0
;
return
0
;
}
}
...
@@ -188,21 +186,15 @@ int return_arglines(char ** const buffer,
...
@@ -188,21 +186,15 @@ int return_arglines(char ** const buffer,
/* get error buffer pointer */
/* get error buffer pointer */
binary_c_error_buffer
(
stardata
,
error_buffer
);
binary_c_error_buffer
(
stardata
,
error_buffer
);
/* set raw_buffer_size = -1 to prevent it being freed */
stardata
->
tmpstore
->
raw_buffer_size
=
-
1
;
/* free stardata (except the buffer) */
/* free stardata (except the buffer) */
binary_c_free_memory
(
&
stardata
,
// Stardata
binary_c_free_memory
(
&
stardata
,
// Stardata
TRUE
,
// free_preferences
TRUE
,
// free_preferences
TRUE
,
// free_stardata
TRUE
,
// free_stardata
FALS
E
,
// free_store
TRU
E
,
// free_store
FALSE
,
// free_raw_buffer
FALSE
,
// free_raw_buffer
TRUE
// free_persistent TODO: check if this is correct here
TRUE
// free_persistent TODO: check if this is correct here
);
);
// TODO: check what this does
binary_c_free_store_contents
(
store
);
return
0
;
return
0
;
}
}
...
@@ -239,10 +231,7 @@ int return_help_info(char * argstring,
...
@@ -239,10 +231,7 @@ int return_help_info(char * argstring,
/* get error buffer pointer */
/* get error buffer pointer */
binary_c_error_buffer
(
stardata
,
error_buffer
);
binary_c_error_buffer
(
stardata
,
error_buffer
);
/* set raw_buffer_size = -1 to prevent it being freed */
stardata
->
tmpstore
->
raw_buffer_size
=
-
1
;
/* free stardata (except the buffer) */
/* free stardata (except the buffer) */
binary_c_free_memory
(
&
stardata
,
// Stardata
binary_c_free_memory
(
&
stardata
,
// Stardata
TRUE
,
// free_preferences
TRUE
,
// free_preferences
...
@@ -290,10 +279,7 @@ int return_help_all_info(char ** const buffer,
...
@@ -290,10 +279,7 @@ int return_help_all_info(char ** const buffer,
/* get error buffer pointer */
/* get error buffer pointer */
binary_c_error_buffer
(
stardata
,
error_buffer
);
binary_c_error_buffer
(
stardata
,
error_buffer
);
/* set raw_buffer_size = -1 to prevent it being freed */
stardata
->
tmpstore
->
raw_buffer_size
=
-
1
;
/* free stardata (except the buffer) */
/* free stardata (except the buffer) */
binary_c_free_memory
(
&
stardata
,
// Stardata
binary_c_free_memory
(
&
stardata
,
// Stardata
TRUE
,
// free_preferences
TRUE
,
// free_preferences
...
@@ -342,9 +328,6 @@ int return_version_info(char ** const buffer,
...
@@ -342,9 +328,6 @@ int return_version_info(char ** const buffer,
/* get error buffer pointer */
/* get error buffer pointer */
binary_c_error_buffer
(
stardata
,
error_buffer
);
binary_c_error_buffer
(
stardata
,
error_buffer
);
/* set raw_buffer_size = -1 to prevent it being freed */
stardata
->
tmpstore
->
raw_buffer_size
=
-
1
;
/* free stardata (except the buffer) */
/* free stardata (except the buffer) */
binary_c_free_memory
(
&
stardata
,
// Stardata
binary_c_free_memory
(
&
stardata
,
// Stardata
TRUE
,
// free_preferences
TRUE
,
// free_preferences
...
@@ -392,10 +375,7 @@ long int return_store(char * argstring,
...
@@ -392,10 +375,7 @@ long int return_store(char * argstring,
/* get error buffer pointer */
/* get error buffer pointer */
binary_c_error_buffer
(
stardata
,
error_buffer
);
binary_c_error_buffer
(
stardata
,
error_buffer
);
/* set raw_buffer_size = -1 to prevent it being freed */
stardata
->
tmpstore
->
raw_buffer_size
=
-
1
;
/* free stardata (except the buffer) */
/* free stardata (except the buffer) */
binary_c_free_memory
(
&
stardata
,
// Stardata
binary_c_free_memory
(
&
stardata
,
// Stardata
TRUE
,
// free_preferences
TRUE
,
// free_preferences
...
...
This diff is collapsed.
Click to expand it.
tests/test_run_system.py
0 → 100644
+
34
−
0
View file @
e49cb1ac
import
binary_c_python_api
import
textwrap
# Evolution functions
def
test_run_system
():
m1
=
15.0
# Msun
m2
=
14.0
# Msun
separation
=
0
# 0 = ignored, use period
orbital_period
=
4530.0
# days
eccentricity
=
0.0
metallicity
=
0.02
max_evolution_time
=
15000
argstring
=
"
binary_c M_1 {0:g} M_2 {1:g} separation {2:g} orbital_period {3:g} eccentricity {4:g} metallicity {5:g} max_evolution_time {6:g}
"
.
format
(
m1
,
m2
,
separation
,
orbital_period
,
eccentricity
,
metallicity
,
max_evolution_time
,
)
output
=
binary_c_python_api
.
run_system
(
argstring
=
argstring
)
print
(
"
function: test_run_system
"
)
print
(
"
Binary_c output:
"
)
print
(
textwrap
.
indent
(
output
,
"
\t
"
))
####
if
__name__
==
"
__main__
"
:
test_run_system
()
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