[python-arrayfire] 98/250: Adding documentation for device.py and features.py
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:36 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/master
in repository python-arrayfire.
commit 049e5091b4e003900c5adf557a837f273af1a805
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date: Tue Sep 1 21:41:28 2015 -0400
Adding documentation for device.py and features.py
---
arrayfire/device.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
arrayfire/features.py | 32 +++++++++++++++++++++++-
2 files changed, 99 insertions(+), 1 deletion(-)
diff --git a/arrayfire/device.py b/arrayfire/device.py
index 28961a6..65a7de4 100644
--- a/arrayfire/device.py
+++ b/arrayfire/device.py
@@ -6,14 +6,31 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################
+"""
+Functions to handle the available devices in the backend.
+"""
from .library import *
from .util import (safe_call, to_str)
def info():
+ """
+ Displays the information about the following:
+ - ArrayFire build and version number.
+ - The number of devices available.
+ - The names of the devices.
+ - The current device being used.
+ """
safe_call(backend.get().af_info())
def device_info():
+ """
+ Returns a map with the following fields:
+ - 'device': Name of the current device.
+ - 'backend': The current backend being used.
+ - 'toolkit': The toolkit version for the backend.
+ - 'compute': The compute version of the device.
+ """
c_char_256 = ct.c_char * 256
device_name = c_char_256()
backend_name = c_char_256()
@@ -31,29 +48,80 @@ def device_info():
return dev_info
def get_device_count():
+ """
+ Returns the number of devices available.
+ """
c_num = ct.c_int(0)
safe_call(backend.get().af_get_device_count(ct.pointer(c_num)))
return c_num.value
def get_device():
+ """
+ Returns the id of the current device.
+ """
c_dev = ct.c_int(0)
safe_call(backend.get().af_get_device(ct.pointer(c_dev)))
return c_dev.value
def set_device(num):
+ """
+ Change the active device to the specified id.
+
+ Parameters
+ ---------
+ num: int.
+ id of the desired device.
+ """
safe_call(backend.get().af_set_device(num))
def is_dbl_supported(device=None):
+ """
+ Check if double precision is supported on specified device.
+
+ Parameters
+ ---------
+ device: optional: int. default: None.
+ id of the desired device.
+
+ Returns
+ --------
+ - True if double precision supported.
+ - False if double precision not supported.
+ """
dev = device if device is not None else get_device()
res = ct.c_bool(False)
safe_call(backend.get().af_get_dbl_support(ct.pointer(res), dev))
return res.value
def sync(device=None):
+ """
+ Block until all the functions on the device have completed execution.
+
+ Parameters
+ ---------
+ device: optional: int. default: None.
+ id of the desired device.
+ """
dev = device if device is not None else get_device()
safe_call(backend.get().af_sync(dev))
def device_mem_info():
+ """
+ Returns a map with the following fields:
+ - 'alloc': Contains the map of the following
+ - 'buffers' : Total number of buffers allocated by memory manager.
+ - 'bytes' : Total number of bytes allocated by memory manager.
+ - 'lock': Contains the map of the following
+ - 'buffers' : Total number of buffers currently in scope.
+ - 'bytes' : Total number of bytes currently in scope.
+
+ Note
+ -----
+ ArrayFire does not free memory when array goes out of scope. The memory is marked for reuse.
+ - The difference between alloc buffers and lock buffers equals the number of free buffers.
+ - The difference between alloc bytes and lock bytes equals the number of free bytes.
+
+ """
alloc_bytes = ct.c_size_t(0)
alloc_buffers = ct.c_size_t(0)
lock_bytes = ct.c_size_t(0)
diff --git a/arrayfire/features.py b/arrayfire/features.py
index a293ebb..190bdde 100644
--- a/arrayfire/features.py
+++ b/arrayfire/features.py
@@ -6,44 +6,74 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################
+"""
+arrayfire.Features class
+"""
from .library import *
from .array import *
import numbers
class Features(object):
+ """
+ A container class used for various feature detectors.
- def __init__(self, num=None):
+ Parameters
+ ----------
+
+ num: optional: int. default: 0.
+ Specifies the number of features.
+ """
+
+ def __init__(self, num=0):
self.feat = ct.c_void_p(0)
if num is not None:
assert(isinstance(num, numbers.Number))
safe_call(backend.get().af_create_features(ct.pointer(self.feat), ct.c_longlong(num)))
def num_features():
+ """
+ Returns the number of features detected.
+ """
num = ct.c_longlong(0)
safe_call(backend.get().af_get_features_num(ct.pointer(num), self.feat))
return num
def get_xpos():
+ """
+ Returns the x-positions of the features detected.
+ """
out = Array()
safe_call(backend.get().af_get_features_xpos(ct.pointer(out.arr), self.feat))
return out
def get_ypos():
+ """
+ Returns the y-positions of the features detected.
+ """
out = Array()
safe_call(backend.get().af_get_features_ypos(ct.pointer(out.arr), self.feat))
return out
def get_score():
+ """
+ Returns the scores of the features detected.
+ """
out = Array()
safe_call(backend.get().af_get_features_score(ct.pointer(out.arr), self.feat))
return out
def get_orientation():
+ """
+ Returns the orientations of the features detected.
+ """
out = Array()
safe_call(backend.get().af_get_features_orientation(ct.pointer(out.arr), self.feat))
return out
def get_size():
+ """
+ Returns the sizes of the features detected.
+ """
out = Array()
safe_call(backend.get().af_get_features_size(ct.pointer(out.arr), self.feat))
return out
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-arrayfire.git
More information about the debian-science-commits
mailing list