@@ -39,8 +39,8 @@ You will require whatever libraries with which binary_c was compiled, as well as
If you want to be able to import the binary_c module correctly for child directories (or anywhere for that matter), execute or put the following code in your .bashrc/.zshrc:
```
export LD_LIBRARY_PATH=<full path to directory containing libbinary_c_api.so>:$LD_LIBRARY_PATH
export PYTHONPATH=<full path to directory containing libbinary_c_api.so>:$PYTHONPATH
export LD_LIBRARY_PATH=<full path to root dir of repo>:$LD_LIBRARY_PATH
export PYTHONPATH=<full path to root dir of repo>:$PYTHONPATH
Function that autogenerates PRINTF statements for binaryc. intput is a dictionary where the key is the header of that logging line and items which are lists of parameters\
that will be put in that logging line
Example::
{'MY_STELLAR_DATA':
[
'model.time',
'star[0].mass',
'model.probability',
'model.dt'
]
}
"""
# Check if the input is of the correct form
ifnottype(logging_dict)==dict:
print("Error: please use a dictionary as input")
returnNone
code=""
# Loop over dict keys
forkeyinlogging_dict:
logging_dict_entry=logging_dict[key]
# Check if item is of correct type:
iftype(logging_dict_entry)==list:
# Construct print statement
code+='Printf("{}'.format(key)
code+=" {}".format("%g "*len(logging_dict_entry))
code=code.strip()
code+='\\n"'
# Add format keys
forparaminlogging_dict_entry:
code+=",((double)stardata->{})".format(param)
code+=");\n"
else:
print(
"Error: please use a list for the list of parameters that you want to have logged"
)
code=code.strip()
# print("MADE AUTO CODE\n\n{}\n\n{}\n\n{}\n".format('*'*60, repr(code), '*'*60))