Python ctypes.c_bool() Examples
The following are 30
code examples of ctypes.c_bool().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ctypes
, or try the search function
.
Example #1
Source File: io_can.py From PythonPilot with Apache License 2.0 | 7 votes |
def __init__(self, cfg): self.__is_use_can_port = cfg['use_can'] # Data for store self.tx_counter_camera_unit = multiprocessing.Value(ctypes.c_int,0) self.tx_servo_on_flag = multiprocessing.Value(ctypes.c_bool,False) self.tx_target_angle = multiprocessing.Value(ctypes.c_float,0.0) self.can_error_count_tx = multiprocessing.Value(ctypes.c_int,0) # Initialize process self.__m = multiprocessing.Process(target=self.__update, \ args=(cfg['can_name'], \ cfg['can_bustype'], \ cfg['can_bitrate'], \ cfg['can_dbc_path'], \ cfg['can_tx_interval'])) # Start process self.__m.start() return
Example #2
Source File: drag_and_drop.py From blackmamba with MIT License | 6 votes |
def _load_data_imp(_cmd, _block_ptr): global _dragged_item_path handler = runtime.ObjCBlockPointer(_block_ptr, argtypes=[ctypes.c_void_p, ctypes.c_bool, ctypes.c_void_p]) if _dragged_item_path: NSURL = ObjCClass('NSURL') url = NSURL.fileURLWithPath_isDirectory_(ns(_dragged_item_path), os.path.isdir(_dragged_item_path)) _dragged_item_path = None else: url = None if not url: error = NSError.errorWithDomain_code_userInfo_('com.robertvojta.blackmamba', 1, None) handler(None, None, error) else: handler(url.ptr, False, None)
Example #3
Source File: pyglet_window.py From pyglet with BSD 3-Clause "New" or "Revised" License | 6 votes |
def nextEventMatchingMask_untilDate_inMode_dequeue_(self, mask, date, mode, dequeue): if self.inLiveResize(): # Call the idle() method while we're stuck in a live resize event. from pyglet import app if app.event_loop is not None: app.event_loop.idle() event = send_super(self, 'nextEventMatchingMask:untilDate:inMode:dequeue:', mask, date, mode, dequeue, argtypes=[NSUInteger, c_void_p, c_void_p, c_bool]) if event.value == None: return 0 else: return event.value # Need this for set_size to not flash.
Example #4
Source File: windows.py From BoomER with GNU General Public License v3.0 | 6 votes |
def process_is_wow64(handle=None): """ Determine whether the process associated with the handle is running in WOW64 or not. :param int handle: A handle to the process to check. :return: Whether the process is running in WOW64 or not. :rtype: bool """ if not hasattr(ctypes.windll.kernel32, 'IsWow64Process'): return False if platform.architecture()[0] == '64bit': ctypes.windll.kernel32.IsWow64Process.argtypes = [ctypes.c_uint64, ctypes.POINTER(ctypes.c_bool)] handle = (handle or -1) is_wow64 = ctypes.c_bool() if not ctypes.windll.kernel32.IsWow64Process(handle, ctypes.byref(is_wow64)): raise WindowsProcessError('Error: IsWow64Process', get_last_error=ctypes.windll.kernel32.GetLastError()) return is_wow64.value
Example #5
Source File: test_health.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def setUp(self): super(TestCNIHealthServer, self).setUp() healthy = multiprocessing.Value(c_bool, True) self.srv = health.CNIHealthServer(healthy) self.srv.application.testing = True self.test_client = self.srv.application.test_client()
Example #6
Source File: pytorch_data_teacher.py From neural_chat with MIT License | 6 votes |
def create(cls): """Singleton factory.""" if not hasattr(cls, 'length_to_eps'): # Maps episode length to list of episodes cls.length_to_eps = {} # Set of episode indices already in the cache cls.ep_indices = set() # List of batches if popping batches cls.batches = [] # If all episodes have been loaded into memory cls.load_complete = Value(ctypes.c_bool, False) # Lock to access batches cls.batches_lock = Lock() # Lock to access length_to_eps cls.cache_lock = Lock() # Lock for condition variables cls.fill_cache_lock = RLock() # Condition notifying Loader to add to cache cls.add_to_cache_cv = Condition(lock=cls.fill_cache_lock) # Condition notifying teacher that cache has episodes cls.cache_filled_cv = Condition(lock=cls.fill_cache_lock)
Example #7
Source File: pyglet_window.py From pyglet with BSD 3-Clause "New" or "Revised" License | 6 votes |
def nextEventMatchingMask_untilDate_inMode_dequeue_(self, mask, date, mode, dequeue): if self.inLiveResize(): # Call the idle() method while we're stuck in a live resize event. from pyglet import app if app.event_loop is not None: app.event_loop.idle() event = send_super(self, 'nextEventMatchingMask:untilDate:inMode:dequeue:', mask, date, mode, dequeue, superclass_name='NSWindow', argtypes=[NSUInteger, c_void_p, c_void_p, c_bool]) if event.value is None: return 0 else: return event.value # Need this for set_size to not flash.
Example #8
Source File: operator_interface.py From deep500 with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self, so_file: str, input_descriptors: List[TensorDescriptor], output_descriptors: List[TensorDescriptor]): self._lib = ctypes.CDLL(so_file) if not getattr(self._lib, 'create_new_op', False): raise ValueError('Invalid custom operator library file') self._input_desc = input_descriptors self._output_desc = output_descriptors # Obtain handle to operator object self._lib.create_new_op.restype = ctypes.c_void_p self._ophandle = ctypes.c_void_p(self._lib.create_new_op( _to_c_array(input_descriptors), len(input_descriptors), _to_c_array(output_descriptors), len(output_descriptors))) self._lib.is_cuda_supported.restype = ctypes.c_bool self._lib.report.restype = ctypes.c_int64
Example #9
Source File: tf.py From deep500 with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _custom_cpp_op(op: CompilableOp, stateful, name): """ Compiles and registers a custom C++ Tensorflow operator """ # Compile the .so file tf_path = os.path.abspath(os.path.dirname(tf.__file__)) so_file = TFCompiler().compile_op(op.name, op.files, op.inputs, op.outputs, any([f.endswith('.cu') for f in op.files]), op.live_output, additional_cmake_options=['-DTENSORFLOW_PATH=' + tf_path] + op.cmake_options, additional_definitions=op.defs, output_folder=op.output_folder) # Load the compiled library into Tensorflow op_module = tf.load_op_library(so_file) op_func = getattr(op_module, 'tf_op' + op.name) op_grad_func = getattr(op_module, 'tf_op_grad' + op.name) # Create the deep500 custom op object lib = ctypes.CDLL(so_file) if not getattr(lib, 'create_new_op', False): raise ValueError('Invalid custom operator library file') lib.create_new_op.restype = ctypes.c_int64 lib.is_cuda_supported.restype = ctypes.c_bool lib.report.restype = ctypes.c_int64 return TFCompiledOp(op, op_func, op_grad_func, lib)
Example #10
Source File: features.py From khiva-python with Mozilla Public License 2.0 | 6 votes |
def sum_of_reoccurring_datapoints(arr, is_sorted=False): """ Calculates the sum of all data points, that are present in the time series more than once. :param arr: KHIVA array with the time series. :param is_sorted: Indicates if the input time series is sorted or not. Defaults to false. :return: KHIVA array with the sum of all data points, that are present in the time series more than once. """ b = ctypes.c_void_p(0) error_code = ctypes.c_int(0) error_message = ctypes.create_string_buffer(KHIVA_ERROR_LENGTH) KhivaLibrary().c_khiva_library.sum_of_reoccurring_datapoints(ctypes.pointer(arr.arr_reference), ctypes.pointer( ctypes.c_bool(is_sorted)), ctypes.pointer(b), ctypes.pointer(error_code), error_message) if error_code.value != 0: raise Exception(str(error_message.value.decode())) return Array(array_reference=b)
Example #11
Source File: features.py From khiva-python with Mozilla Public License 2.0 | 6 votes |
def percentage_of_reoccurring_values_to_all_values(arr, is_sorted): """ Calculates the percentage of unique values, that are present in the time series more than once. .. math:: \\frac{\\textit{number of data points occurring more than once}}{\\textit{number of all data points})} This means the percentage is normalized to the number of unique values, in contrast to the percentage_of_reoccurring_datapoints_to_all_datapoints. :param arr: KHIVA array with the time series. :param is_sorted: Indicates if the input time series is sorted or not. Defaults to false. :return: KHIVA array with the percentage of unique values, that are present in the time series more than once. """ b = ctypes.c_void_p(0) error_code = ctypes.c_int(0) error_message = ctypes.create_string_buffer(KHIVA_ERROR_LENGTH) KhivaLibrary().c_khiva_library.percentage_of_reoccurring_values_to_all_values(ctypes.pointer(arr.arr_reference), ctypes.pointer( ctypes.c_bool(is_sorted)), ctypes.pointer(b), ctypes.pointer(error_code), error_message) if error_code.value != 0: raise Exception(str(error_message.value.decode())) return Array(array_reference=b)
Example #12
Source File: nsf2x.py From nsf2x with GNU General Public License v2.0 | 6 votes |
def __SetDLLReturnTypes(self): self.nnotesdll.NotesInitExtended.restype = ctypes.c_uint16 self.nnotesdll.NotesTerm.restype = ctypes.c_uint16 self.nnotesdll.NSFDbOpen.restype = ctypes.c_uint16 self.nnotesdll.NSFDbClose.restype = ctypes.c_uint16 self.nnotesdll.NSFNoteOpenExt.restype = ctypes.c_uint16 self.nnotesdll.NSFNoteOpenByUNID.restype = ctypes.c_uint16 self.nnotesdll.NSFNoteClose.restype = ctypes.c_uint16 self.nnotesdll.NSFNoteCopy.restype = ctypes.c_uint16 self.nnotesdll.NSFNoteGetInfo.restype = None self.nnotesdll.NSFNoteIsSignedOrSealed.restype = ctypes.c_bool self.nnotesdll.NSFNoteDecrypt.restype = ctypes.c_uint16 self.nnotesdll.NSFItemDelete.restype = ctypes.c_uint16 self.nnotesdll.NSFNoteHasMIMEPart.restype = ctypes.c_bool self.nnotesdll.NSFNoteHasMIME.restype = ctypes.c_bool self.nnotesdll.NSFNoteHasComposite.restype = ctypes.c_bool self.nnotesdll.MMCreateConvControls.restype = ctypes.c_uint16 self.nnotesdll.MMDestroyConvControls.restype = ctypes.c_uint16 self.nnotesdll.MMSetMessageContentEncoding.restype = None self.nnotesdll.MIMEConvertCDParts.restype = ctypes.c_uint16 self.nnotesdll.MIMEConvertMIMEPartCC.restype = ctypes.c_uint16 self.nnotesdll.NSFNoteUpdate.restype = ctypes.c_uint16
Example #13
Source File: features.py From khiva-python with Mozilla Public License 2.0 | 6 votes |
def cid_ce(arr, z_normalize): """ Calculates an estimate for the time series complexity defined by Batista, Gustavo EAPA, et al (2014). (A more complex time series has more peaks, valleys, etc.) :param arr: KHIVA array with the time series. :param z_normalize: Controls wheter the time series should be z-normalized or not. :return: KHIVA array with the complexity value for the given time series. """ b = ctypes.c_void_p(0) error_code = ctypes.c_int(0) error_message = ctypes.create_string_buffer(KHIVA_ERROR_LENGTH) KhivaLibrary().c_khiva_library.cid_ce(ctypes.pointer(arr.arr_reference), ctypes.pointer(ctypes.c_bool(z_normalize)), ctypes.pointer(b), ctypes.pointer(error_code), error_message) if error_code.value != 0: raise Exception(str(error_message.value.decode())) return Array(array_reference=b)
Example #14
Source File: features.py From khiva-python with Mozilla Public License 2.0 | 6 votes |
def auto_covariance(arr, unbiased=False): """ Calculates the auto-covariance the given time series. :param arr: KHIVA array with the time series. :param unbiased: Determines whether it divides by n - lag (if true) or n (if false). :return: KHIVA array with the auto-covariance value for the given time series. """ b = ctypes.c_void_p(0) error_code = ctypes.c_int(0) error_message = ctypes.create_string_buffer(KHIVA_ERROR_LENGTH) KhivaLibrary().c_khiva_library.auto_covariance(ctypes.pointer(arr.arr_reference), ctypes.pointer( ctypes.c_bool(unbiased)), ctypes.pointer(b), ctypes.pointer(error_code), error_message) if error_code.value != 0: raise Exception(str(error_message.value.decode())) return Array(array_reference=b)
Example #15
Source File: features.py From khiva-python with Mozilla Public License 2.0 | 6 votes |
def cross_covariance(xss, yss, unbiased): """ Calculates the cross-covariance of the given time series. :param xss: A KHIVA array with time series. :param yss: A KHIVA Array with time series. :param unbiased: Determines whether it divides by n - lag (if true) or n (if false). :return: KHIVA array with the cross-covariance value for the given time series. """ b = ctypes.c_void_p(0) error_code = ctypes.c_int(0) error_message = ctypes.create_string_buffer(KHIVA_ERROR_LENGTH) KhivaLibrary().c_khiva_library.cross_covariance(ctypes.pointer(xss.arr_reference), ctypes.pointer( yss.arr_reference), ctypes.pointer(ctypes.c_bool(unbiased)), ctypes.pointer(b), ctypes.pointer(error_code), error_message) if error_code.value != 0: raise Exception(str(error_message.value.decode())) return Array(array_reference=b)
Example #16
Source File: PlatformManagerWindows.py From lackey with MIT License | 6 votes |
def getWindowByTitle(self, wildcard, order=0): """ Returns a handle for the first window that matches the provided "wildcard" regex """ EnumWindowsProc = ctypes.WINFUNCTYPE( ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.py_object) def callback(hwnd, context): if ctypes.windll.user32.IsWindowVisible(hwnd): length = ctypes.windll.user32.GetWindowTextLengthW(hwnd) buff = ctypes.create_unicode_buffer(length + 1) ctypes.windll.user32.GetWindowTextW(hwnd, buff, length + 1) if re.search(context["wildcard"], buff.value, flags=re.I) != None and not context["handle"]: if context["order"] > 0: context["order"] -= 1 else: context["handle"] = hwnd return True data = {"wildcard": wildcard, "handle": None, "order": order} ctypes.windll.user32.EnumWindows(EnumWindowsProc(callback), ctypes.py_object(data)) return data["handle"]
Example #17
Source File: PlatformManagerWindows.py From lackey with MIT License | 6 votes |
def getWindowByPID(self, pid, order=0): """ Returns a handle for the first window that matches the provided PID """ if pid <= 0: return None EnumWindowsProc = ctypes.WINFUNCTYPE( ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.py_object) def callback(hwnd, context): if ctypes.windll.user32.IsWindowVisible(hwnd): pid = ctypes.c_ulong() ctypes.windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid)) if context["pid"] == int(pid.value) and not context["handle"]: if context["order"] > 0: context["order"] -= 1 else: context["handle"] = hwnd return True data = {"pid": pid, "handle": None, "order": order} ctypes.windll.user32.EnumWindows(EnumWindowsProc(callback), ctypes.py_object(data)) return data["handle"]
Example #18
Source File: io_can.py From PythonPilot with Apache License 2.0 | 6 votes |
def __init__(self, cfg): self.__is_use_can_port = cfg['use_can'] # Data for store self.rx_counter_servo_unit = multiprocessing.Value(ctypes.c_int,0) self.rx_time_us_diff = multiprocessing.Value(ctypes.c_int,0) self.rx_button_y = multiprocessing.Value(ctypes.c_bool,False) self.rx_button_g = multiprocessing.Value(ctypes.c_bool,False) self.rx_button_r = multiprocessing.Value(ctypes.c_bool,False) self.rx_actual_angle = multiprocessing.Value(ctypes.c_float,0.0) self.can_error_count_rx = multiprocessing.Value(ctypes.c_int,0) # Initialize process self.__m = multiprocessing.Process(target=self.__process_can, \ args=(cfg['can_name'], \ cfg['can_bustype'], \ cfg['can_bitrate'], \ cfg['can_dbc_path'], \ cfg['can_rx_interval'])) # Start process self.__m.start() return
Example #19
Source File: array.py From khiva-python with Mozilla Public License 2.0 | 6 votes |
def transpose(self, conjugate=False): """ Transpose the KHIVA Array. :param conjugate: Indicates if the transpose is conjugated or not. :return: The transposed KHIVA Array. """ result = ctypes.c_void_p(0) error_code = ctypes.c_int(0) error_message = ctypes.create_string_buffer(KHIVA_ERROR_LENGTH) KhivaLibrary().c_khiva_library.khiva_transpose(ctypes.pointer(self.arr_reference), ctypes.c_bool( conjugate), ctypes.pointer(result), ctypes.pointer( error_code), error_message) if error_code.value != 0: raise Exception(str(error_message.value.decode())) return Array(array_reference=result)
Example #20
Source File: py_mini_racer.py From PyMiniRacer with ISC License | 6 votes |
def eval(self, js_str, timeout=0, max_memory=0): """ Eval the JavaScript string """ if is_unicode(js_str): bytes_val = js_str.encode("utf8") else: bytes_val = js_str res = None self.lock.acquire() try: res = self.ext.mr_eval_context(self.ctx, bytes_val, len(bytes_val), ctypes.c_ulong(timeout), ctypes.c_size_t(max_memory), ctypes.c_bool(self.basic_types_only)) if bool(res) is False: raise JSConversionException() return self._eval_return(res) finally: self.lock.release() if res is not None: self.free(res)
Example #21
Source File: logi_led.py From logiPy with MIT License | 6 votes |
def logi_led_pulse_single_key(key_name, red_percentage_start, green_percentage_start, blue_percentage_start, ms_duration, is_infinite = False, red_percentage_end = 0, green_percentage_end = 0, blue_percentage_end = 0): """ pulses the lighting color of the combined RGB percentages over the specified millisecond duration for the specified key name. the color will gradually change from the starting color to the ending color. if no ending color is specified, the ending color will be black. the effect will stop after one interval unless is_infinite is set to True. note that RGB ranges from 0-255, but this function ranges from 0-100. this function only applies to LOGI_DEVICETYPE_PERKEY_RGB devices. """ if led_dll: key_name = ctypes.c_int(key_name) red_percentage_start = ctypes.c_int(red_percentage_start) green_percentage_start = ctypes.c_int(green_percentage_start) blue_percentage_start = ctypes.c_int(blue_percentage_start) red_percentage_end = ctypes.c_int(red_percentage_end) green_percentage_end = ctypes.c_int(green_percentage_end) blue_percentage_end = ctypes.c_int(blue_percentage_end) ms_duration = ctypes.c_int(ms_duration) is_infinite = ctypes.c_bool(is_infinite) return bool(led_dll.LogiLedPulseSingleKey(key_name, red_percentage_start, green_percentage_start, blue_percentage_start, red_percentage_end, green_percentage_end, blue_percentage_end, ms_duration, is_infinite)) else: return False
Example #22
Source File: multiproc_data.py From training_results_v0.6 with Apache License 2.0 | 6 votes |
def __init__(self, num_processes, max_queue_size, fn): """ Parameters ---------- num_processes: int Number of processes to spawn max_queue_size: int Maximum samples in the queue before processes wait fn: function function that generates samples, executed on separate processes. """ self.queue = mp.Queue(maxsize=int(max_queue_size)) self.alive = mp.Value(c_bool, False, lock=False) self.num_proc = num_processes self.proc = list() self.fn = fn
Example #23
Source File: Tagger.py From python-zpar with MIT License | 6 votes |
def __init__(self, modelpath, libptr, zpar_session_obj): super(Tagger, self).__init__() # save the zpar session object self._zpar_session_obj = zpar_session_obj # set up a logger self.logger = logging.getLogger(__name__) # get the library method that loads the tagger models self._load_tagger = libptr.load_tagger self._load_tagger.restype = c.c_int self._load_tagger.argtypes = [c.c_void_p, c.c_char_p] # get the library methods that tag sentences and files self._tag_sentence = libptr.tag_sentence self._tag_sentence.restype = c.c_char_p self._tag_sentence.argtypes = [c.c_void_p, c.c_char_p, c.c_bool] self._tag_file = libptr.tag_file self._tag_file.restype = None self._tag_file.argtypes = [c.c_void_p, c.c_char_p, c.c_char_p, c.c_bool] if self._load_tagger(self._zpar_session_obj, modelpath.encode('utf-8')): raise OSError('Cannot find tagger model at {}\n'.format(modelpath))
Example #24
Source File: windows.py From mayhem with BSD 3-Clause "New" or "Revised" License | 6 votes |
def process_is_wow64(handle=None): """ Determine whether the process associated with the handle is running in WOW64 or not. :param int handle: A handle to the process to check. :return: Whether the process is running in WOW64 or not. :rtype: bool """ if not hasattr(m_k32, 'IsWow64Process'): return False handle = (handle or -1) is_wow64 = ctypes.c_bool() if not m_k32.IsWow64Process(handle, ctypes.byref(is_wow64)): raise WindowsProcessError('Error: IsWow64Process', get_last_error=m_k32.GetLastError()) return is_wow64.value
Example #25
Source File: features.py From khiva-python with Mozilla Public License 2.0 | 6 votes |
def auto_correlation(arr, max_lag, unbiased): """ Calculates the autocorrelation of the specified lag for the given time series. :param arr: KHIVA array with the time series. :param max_lag: The maximum lag to compute. :param unbiased: Determines whether it divides by n - lag (if true) or n (if false). :return: KHIVA array with the autocorrelation value for the given time series. """ b = ctypes.c_void_p(0) error_code = ctypes.c_int(0) error_message = ctypes.create_string_buffer(KHIVA_ERROR_LENGTH) KhivaLibrary().c_khiva_library.auto_correlation(ctypes.pointer(arr.arr_reference), ctypes.pointer( ctypes.c_long(max_lag)), ctypes.pointer( ctypes.c_bool(unbiased)), ctypes.pointer(b), ctypes.pointer(error_code), error_message) if error_code.value != 0: raise Exception(str(error_message.value.decode())) return Array(array_reference=b)
Example #26
Source File: manticore.py From manticore with GNU Affero General Public License v3.0 | 5 votes |
def _manticore_single(self): self._worker_type = WorkerSingle class FakeLock: def _nothing(self, *args, **kwargs): pass acquire = _nothing release = _nothing __enter__ = _nothing __exit__ = _nothing notify_all = _nothing wait = _nothing def wait_for(self, condition, *args, **kwargs): if not condition(): raise Exception("Deadlock: Waiting for CTRL+C") self._lock = FakeLock() self._killed = ctypes.c_bool(False) self._running = ctypes.c_bool(False) self._ready_states = [] self._terminated_states = [] self._busy_states = [] self._killed_states = [] self._shared_context = {}
Example #27
Source File: pytorch_data_teacher.py From KBRD with MIT License | 5 votes |
def create(cls): if not hasattr(cls, 'length_to_eps'): # Maps episode length to list of episodes cls.length_to_eps = {} if not hasattr(cls, 'ep_indices'): # Set of episode indices already in the cache cls.ep_indices = set() if not hasattr(cls, 'batches'): # List of batches if popping batches cls.batches = [] if not hasattr(cls, 'load_complete'): # If all episodes have been loaded into memory cls.load_complete = Value(ctypes.c_bool, False) if not hasattr(cls, 'batches_lock'): # Lock to access batches cls.batches_lock = Lock() if not hasattr(cls, 'cache_lock'): # Lock to access length_to_eps cls.cache_lock = Lock() if not hasattr(cls, 'fill_cache_lock'): # Lock for condition variables cls.fill_cache_lock = RLock() if not hasattr(cls, 'add_to_cache_cv'): # Condition notifying Loader to add to cache cls.add_to_cache_cv = Condition(lock=cls.fill_cache_lock) if not hasattr(cls, 'cache_filled_cv'): # Condition notifying teacher that cache has episodes cls.cache_filled_cv = Condition(lock=cls.fill_cache_lock)
Example #28
Source File: py_mini_racer.py From PyMiniRacer with ISC License | 5 votes |
def _fetch_ext_handle(): global _ext_handle if _ext_handle: return _ext_handle _ext_handle = ctypes.CDLL(EXTENSION_PATH) _ext_handle.mr_init_context.restype = ctypes.c_void_p _ext_handle.mr_eval_context.argtypes = [ ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int, ctypes.c_ulong, ctypes.c_size_t, ctypes.c_bool] _ext_handle.mr_eval_context.restype = ctypes.POINTER(PythonValue) _ext_handle.mr_free_value.argtypes = [ctypes.c_void_p] _ext_handle.mr_free_context.argtypes = [ctypes.c_void_p] _ext_handle.mr_heap_stats.argtypes = [ctypes.c_void_p] _ext_handle.mr_heap_stats.restype = ctypes.POINTER(PythonValue) _ext_handle.mr_low_memory_notification.argtypes = [ctypes.c_void_p] _ext_handle.mr_heap_snapshot.argtypes = [ctypes.c_void_p] _ext_handle.mr_heap_snapshot.restype = ctypes.POINTER(PythonValue) _ext_handle.mr_set_soft_memory_limit.argtypes = [ctypes.c_void_p, ctypes.c_size_t] _ext_handle.mr_set_soft_memory_limit.restype = None _ext_handle.mr_soft_memory_limit_reached.argtypes = [ctypes.c_void_p] _ext_handle.mr_soft_memory_limit_reached.restype = ctypes.c_bool return _ext_handle
Example #29
Source File: manticore.py From manticore with GNU Affero General Public License v3.0 | 5 votes |
def _manticore_threading(self): self._worker_type = WorkerThread self._lock = threading.Condition() self._killed = ctypes.c_bool(False) self._running = ctypes.c_bool(False) self._ready_states = [] self._terminated_states = [] self._busy_states = [] self._killed_states = [] self._shared_context = {}
Example #30
Source File: sparse.py From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 | 5 votes |
def check_format(self, full_check=True): """Check whether the NDArray format is valid. Parameters ---------- full_check : bool, optional If `True`, rigorous check, O(N) operations. Otherwise basic check, O(1) operations (default True). """ check_call(_LIB.MXNDArraySyncCheckFormat(self.handle, ctypes.c_bool(full_check)))