Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
Utilities to generate embedded C code from OSQP sources
"""
# Compatibility with Python 2
from __future__ import print_function
from builtins import range
# Path of osqp module
import os.path
import osqp
files_to_generate_path = os.path.join(osqp.__path__[0],
'codegen', 'files_to_generate')
def write_vec(f, vec, name, vec_type):
"""
Write vector to file
"""
f.write('%s %s[%d] = {\n' % (vec_type, name, len(vec)))
# Write vector elements
for i in range(len(vec)):
if vec_type == 'c_float':
f.write('(c_float)%.20f,\n' % vec[i])
else:
f.write('%i,\n' % vec[i])
def codegen(work, target_dir, python_ext_name, project_type, embedded,
force_rewrite, loop_unrolling):
"""
Generate code
"""
# Import OSQP path
osqp_path = osqp.__path__[0]
# Path of osqp module
files_to_generate_path = os.path.join(osqp_path,
'codegen', 'files_to_generate')
# Module extension
if system() == 'Linux' or system() == 'Darwin':
module_ext = '.so'
else:
module_ext = '.pyd'
# Check if interface already exists
resp = None # Initialize response
if os.path.isdir(target_dir):
if force_rewrite:
sh.rmtree(target_dir)
def codegen(work, target_dir, python_ext_name, project_type, embedded,
force_rewrite, float_flag, long_flag):
"""
Generate code
"""
# Import OSQP path
osqp_path = osqp.__path__[0]
# Path of osqp module
files_to_generate_path = os.path.join(osqp_path,
'codegen', 'files_to_generate')
# Module extension
if system() == 'Linux' or system() == 'Darwin':
module_ext = '.so'
else:
module_ext = '.pyd'
# Check if interface already exists
resp = None # Initialize response
if os.path.isdir(target_dir):
if force_rewrite:
sh.rmtree(target_dir)
"""
Utilities to generate embedded C code from OSQP sources
"""
# Compatibility with Python 2
from __future__ import print_function
from builtins import range
# Path of osqp module
import os.path
import osqp
files_to_generate_path = os.path.join(osqp.__path__[0],
'codegen', 'files_to_generate')
# Timestamp
import datetime
def write_vec(f, vec, name, vec_type):
"""
Write vector to file
"""
f.write('%s %s[%d] = {\n' % (vec_type, name, len(vec)))
# Write vector elements
for i in range(len(vec)):
if vec_type == 'c_float':
f.write('(c_float)%.20f,\n' % vec[i])