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
90cadce7
Commit
90cadce7
authored
4 years ago
by
David Hendriks
Browse files
Options
Downloads
Patches
Plain Diff
fixed a bug in the api bindings, the persitent_data needs to be done properly
parent
4dd3beac
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/binary_c_python.h
+2
-0
2 additions, 0 deletions
include/binary_c_python.h
setup.py
+19
-14
19 additions, 14 deletions
setup.py
src/binary_c_python_api.c
+1
-1
1 addition, 1 deletion
src/binary_c_python_api.c
tests/python_API_test.py
+18
-23
18 additions, 23 deletions
tests/python_API_test.py
with
40 additions
and
38 deletions
include/binary_c_python.h
+
2
−
0
View file @
90cadce7
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
*/
*/
#include
"binary_c_API.h"
#include
"binary_c_API.h"
#include
"binary_c.h"
#include
"binary_c_API_prototypes.h"
/* Binary_c's python API prototypes */
/* Binary_c's python API prototypes */
int
run_system
(
char
*
argstring
,
int
run_system
(
char
*
argstring
,
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
19
−
14
View file @
90cadce7
...
@@ -21,13 +21,13 @@ def license():
...
@@ -21,13 +21,13 @@ def license():
with
open
(
"
LICENSE.md
"
)
as
file
:
with
open
(
"
LICENSE.md
"
)
as
file
:
return
file
.
read
()
return
file
.
read
()
def
check_version
(
installed_binary_c_version
,
required_binary_c_version
):
def
check_version
(
installed_binary_c_version
,
required_binary_c_version
s
):
"""
Function to check the installed version and compare it to the required version
"""
"""
Function to check the installed version and compare it to the required version
"""
message
=
"""
message
=
"""
The binary_c version that is installed ({}) does not match
any of
the binary_c versions ({})
The binary_c version that is installed ({}) does not match the binary_c versions ({})
that this release of the binary_c python module requires.
that this release of the binary_c python module requires.
"""
.
format
(
installed_binary_c_version
,
required_binary_c_version
)
"""
.
format
(
installed_binary_c_version
,
required_binary_c_version
s
)
assert
installed_binary_c_version
in
required_binary_c_version
,
message
assert
installed_binary_c_version
in
required_binary_c_version
s
,
message
###
###
REQUIRED_BINARY_C_VERSIONS
=
[
'
2.1.7
'
]
REQUIRED_BINARY_C_VERSIONS
=
[
'
2.1.7
'
]
...
@@ -110,6 +110,10 @@ for x in DEFINES:
...
@@ -110,6 +110,10 @@ for x in DEFINES:
if
y
:
if
y
:
BINARY_C_DEFINE_MACROS
.
extend
([(
y
.
group
(
1
),
None
)])
BINARY_C_DEFINE_MACROS
.
extend
([(
y
.
group
(
1
),
None
)])
# add API header file
API_h
=
os
.
path
.
join
(
BINARY_C_DIR
,
"
src
"
,
"
API
"
,
"
binary_c_API.h
"
)
BINARY_C_DEFINE_MACROS
.
extend
([(
"
BINARY_C_API_H
"
,
API_h
)])
############################################################
############################################################
# Setting all directories and LIBRARIES to their final values
# Setting all directories and LIBRARIES to their final values
############################################################
############################################################
...
@@ -141,16 +145,17 @@ RUNTIME_LIBRARY_DIRS = [
...
@@ -141,16 +145,17 @@ RUNTIME_LIBRARY_DIRS = [
# os.path.join(CWD, "binarycpython/core/"),
# os.path.join(CWD, "binarycpython/core/"),
]
+
BINARY_C_LIBDIRS
]
+
BINARY_C_LIBDIRS
print
(
'
\n
'
)
# print('\n')
print
(
"
BINARY_C_CONFIG:
"
,
str
(
BINARY_C_CONFIG
)
+
"
\n
"
)
# print("BINARY_C_CONFIG: ", str(BINARY_C_CONFIG) + "\n")
print
(
"
incdirs:
"
,
str
(
INCLUDE_DIRS
)
+
"
\n
"
)
# print("incdirs: ", str(INCLUDE_DIRS) + "\n")
print
(
"
BINARY_C_LIBS:
"
,
str
(
BINARY_C_LIBS
)
+
"
\n
"
)
# print("BINARY_C_LIBS: ", str(BINARY_C_LIBS) + "\n")
print
(
"
LIBRARIES:
"
,
str
(
LIBRARIES
)
+
"
\n
"
)
# print("LIBRARIES: ", str(LIBRARIES) + "\n")
print
(
"
LIBRARY_DIRS:
"
,
str
(
LIBRARY_DIRS
)
+
"
\n
"
)
# print("LIBRARY_DIRS: ", str(LIBRARY_DIRS) + "\n")
print
(
"
RUNTIME_LIBRARY_DIRS:
"
,
str
(
RUNTIME_LIBRARY_DIRS
)
+
"
\n
"
)
# print("RUNTIME_LIBRARY_DIRS: ", str(RUNTIME_LIBRARY_DIRS) + "\n")
print
(
"
BINARY_C_CFLAGS:
"
,
str
(
BINARY_C_CFLAGS
)
+
"
\n
"
)
# print("BINARY_C_CFLAGS: ", str(BINARY_C_CFLAGS) + "\n")
print
(
"
macros:
"
,
str
(
BINARY_C_DEFINE_MACROS
)
+
"
\n
"
)
# print("API_h: ", str(API_h) + "\n")
print
(
'
\n
'
)
# print("macros: ", str(BINARY_C_DEFINE_MACROS) + "\n")
# print('\n')
############################################################
############################################################
# Making the extension function
# Making the extension function
...
...
This diff is collapsed.
Click to expand it.
src/binary_c_python_api.c
+
1
−
1
View file @
90cadce7
...
@@ -79,7 +79,7 @@ int run_system(char * argstring,
...
@@ -79,7 +79,7 @@ int run_system(char * argstring,
NULL
,
// previous_stardatas
NULL
,
// previous_stardatas
NULL
,
// preferences
NULL
,
// preferences
&
store
,
// store
&
store
,
// store
&
persistent_data
,
// persistent_data TODO: see if this use is correct
NULL
,
// persistent_data TODO: see if this use is correct
&
argstring
,
// argv
&
argstring
,
// argv
-
1
// argc
-
1
// argc
);
);
...
...
This diff is collapsed.
Click to expand it.
tests/python_API_test.py
+
18
−
23
View file @
90cadce7
...
@@ -10,6 +10,7 @@ from binarycpython.utils.custom_logging_functions import (
...
@@ -10,6 +10,7 @@ from binarycpython.utils.custom_logging_functions import (
from
binarycpython.utils.functions
import
temp_dir
from
binarycpython.utils.functions
import
temp_dir
import
tempfile
import
tempfile
import
textwrap
############################################################
############################################################
# Test script for the api functions
# Test script for the api functions
...
@@ -18,9 +19,7 @@ import tempfile
...
@@ -18,9 +19,7 @@ import tempfile
############################################################
############################################################
# Evolution functionality
# Evolution functions
def
test_run_system
():
def
test_run_system
():
m1
=
15.0
# Msun
m1
=
15.0
# Msun
m2
=
14.0
# Msun
m2
=
14.0
# Msun
...
@@ -43,7 +42,7 @@ def test_run_system():
...
@@ -43,7 +42,7 @@ def test_run_system():
print
(
"
function: test_run_system
"
)
print
(
"
function: test_run_system
"
)
print
(
"
Binary_c output:
"
)
print
(
"
Binary_c output:
"
)
print
(
output
)
print
(
textwrap
.
indent
(
output
,
"
\t
"
)
)
def
test_run_system_with_log
():
def
test_run_system_with_log
():
...
@@ -74,13 +73,10 @@ def test_run_system_with_log():
...
@@ -74,13 +73,10 @@ def test_run_system_with_log():
print
(
"
function: test_run_system_with_log
"
)
print
(
"
function: test_run_system_with_log
"
)
print
(
"
Binary_c output:
"
)
print
(
"
Binary_c output:
"
)
print
(
output
)
print
(
textwrap
.
indent
(
output
,
"
\t
"
)
)
def
test_run_system_with_custom_logging
():
def
test_run_system_with_custom_logging
():
"""
"""
# generate logging lines. Here you can choose whatever you want to have logged, and with what header
# generate logging lines. Here you can choose whatever you want to have logged, and with what header
# this generates working print statements
# this generates working print statements
logging_line
=
autogen_C_logging_code
(
logging_line
=
autogen_C_logging_code
(
...
@@ -116,56 +112,55 @@ def test_run_system_with_custom_logging():
...
@@ -116,56 +112,55 @@ def test_run_system_with_custom_logging():
print
(
"
function: test_run_system_with_custom_logging
"
)
print
(
"
function: test_run_system_with_custom_logging
"
)
print
(
"
memory adress of custom logging functions:
"
)
print
(
"
memory adress of custom logging functions:
"
)
print
(
func_memaddr
)
print
(
textwrap
.
indent
(
str
(
func_memaddr
)
,
"
\t
"
))
out
=
binary_c_python_api
.
run_system
(
out
put
=
binary_c_python_api
.
run_system
(
argstring
,
custom_logging_func_memaddr
=
func_memaddr
argstring
,
custom_logging_func_memaddr
=
func_memaddr
)
)
print
(
"
binary_c output:
"
)
print
(
"
binary_c output:
"
)
print
(
out
)
print
(
textwrap
.
indent
(
output
,
"
\t
"
))
# Testing other utility functions
# Testing other utility functions
def
test_return_help
():
def
test_return_help
():
out
=
binary_c_python_api
.
return_help
(
"
M_1
"
)
out
put
=
binary_c_python_api
.
return_help
(
"
M_1
"
)
print
(
"
function: test_return_help
"
)
print
(
"
function: test_return_help
"
)
print
(
"
help output:
"
)
print
(
"
help output:
"
)
print
(
out
)
print
(
textwrap
.
indent
(
output
,
"
\t
"
)
)
def
test_return_arglines
():
def
test_return_arglines
():
out
=
binary_c_python_api
.
return_arglines
()
out
put
=
binary_c_python_api
.
return_arglines
()
print
(
"
function: test_return_arglines
"
)
print
(
"
function: test_return_arglines
"
)
print
(
"
arglines output:
"
)
print
(
"
arglines output:
"
)
print
(
out
)
print
(
textwrap
.
indent
(
output
,
"
\t
"
)
)
def
test_return_help_all
():
def
test_return_help_all
():
out
=
binary_c_python_api
.
return_help_all
(
"
M_1
"
)
out
put
=
binary_c_python_api
.
return_help_all
(
"
M_1
"
)
print
(
"
function: test_return_help_all
"
)
print
(
"
function: test_return_help_all
"
)
print
(
"
help all output:
"
)
print
(
"
help all output:
"
)
print
(
out
)
print
(
textwrap
.
indent
(
output
,
"
\t
"
)
)
def
test_return_version_info
():
def
test_return_version_info
():
out
=
binary_c_python_api
.
return_version_info
()
out
put
=
binary_c_python_api
.
return_version_info
()
print
(
"
function: test_return_version_info
"
)
print
(
"
function: test_return_version_info
"
)
print
(
"
version info output:
"
)
print
(
"
version info output:
"
)
print
(
out
)
print
(
textwrap
.
indent
(
output
,
"
\t
"
)
)
# Testing other functions
# Testing other functions
def
test_return_store
():
def
test_return_store
():
out
=
binary_c_python_api
.
return_store
(
""
)
out
put
=
binary_c_python_api
.
return_store
(
""
)
print
(
"
function: test_return_store
"
)
print
(
"
function: test_return_store
"
)
print
(
"
store memory adress:
"
)
print
(
"
store memory adress:
"
)
print
(
out
)
print
(
textwrap
.
indent
(
str
(
output
),
"
\t
"
)
)
####
####
...
...
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