How to use the osqp.__path__ function in osqp

To help you get started, we’ve selected a few osqp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oxfordcontrol / osqp / interfaces / python / module / codegen / utils.py View on Github external
"""
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])
github oxfordcontrol / osqp / interfaces / python / module / codegen / code_generator.py View on Github external
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)
github oxfordcontrol / osqp-python / module / codegen / code_generator.py View on Github external
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)
github oxfordcontrol / osqp-python / module / codegen / utils.py View on Github external
"""
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])

osqp

OSQP: The Operator Splitting QP Solver

Apache-2.0
Latest version published 2 months ago

Package Health Score

77 / 100
Full package analysis