[python-arrayfire] 35/58: Cleaning up scan, scan_by_key and moments
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Sep 28 13:57:07 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository python-arrayfire.
commit 204d9000ea2080afeb5f1591a5b7bfcfab33739d
Author: Pavan Yalamanchili <contact at pavanky.com>
Date: Thu Sep 22 14:12:46 2016 -0700
Cleaning up scan, scan_by_key and moments
- Use consistent naming scheme for enums
- Fixed minor bugs when passing enum to the C function
---
arrayfire/algorithm.py | 24 ++++++++++++++++--------
arrayfire/image.py | 11 ++++++++---
arrayfire/library.py | 36 +++++++++++++++++++++---------------
3 files changed, 45 insertions(+), 26 deletions(-)
diff --git a/arrayfire/algorithm.py b/arrayfire/algorithm.py
index 50c9b61..a219ea6 100644
--- a/arrayfire/algorithm.py
+++ b/arrayfire/algorithm.py
@@ -299,7 +299,7 @@ def accum(a, dim=0):
"""
return _parallel_dim(a, dim, backend.get().af_accum)
-def scan(a, dim=0, op=BINARYOP.BINARY_ADD, inclusive_scan=True):
+def scan(a, dim=0, op=BINARYOP.ADD, inclusive_scan=True):
"""
Generalized scan of an array.
@@ -311,8 +311,12 @@ def scan(a, dim=0, op=BINARYOP.BINARY_ADD, inclusive_scan=True):
dim : optional: int. default: 0
Dimension along which the scan is performed.
- op : optional: af.BINARYOP. default: af.BINARYOP.BINARY_ADD.
- - Interpolation method used for resizing.
+ op : optional: af.BINARYOP. default: af.BINARYOP.ADD.
+ Binary option the scan algorithm uses. Can be one of:
+ - af.BINARYOP.ADD
+ - af.BINARYOP.MUL
+ - af.BINARYOP.MIN
+ - af.BINARYOP.MAX
inclusive_scan: optional: bool. default: True
Specifies if the scan is inclusive
@@ -323,10 +327,10 @@ def scan(a, dim=0, op=BINARYOP.BINARY_ADD, inclusive_scan=True):
- will contain scan of input.
"""
out = Array()
- safe_call(backend.get().af_scan(ct.pointer(out.arr), a.arr, dim, op, inclusive_scan))
+ safe_call(backend.get().af_scan(ct.pointer(out.arr), a.arr, dim, op.value, inclusive_scan))
return out
-def scan_by_key(key, a, dim=0, op=BINARYOP.BINARY_ADD, inclusive_scan=True):
+def scan_by_key(key, a, dim=0, op=BINARYOP.ADD, inclusive_scan=True):
"""
Generalized scan by key of an array.
@@ -341,8 +345,12 @@ def scan_by_key(key, a, dim=0, op=BINARYOP.BINARY_ADD, inclusive_scan=True):
dim : optional: int. default: 0
Dimension along which the scan is performed.
- op : optional: af.BINARYOP. default: af.BINARYOP.BINARY_ADD.
- - Interpolation method used for resizing.
+ op : optional: af.BINARYOP. default: af.BINARYOP.ADD.
+ Binary option the scan algorithm uses. Can be one of:
+ - af.BINARYOP.ADD
+ - af.BINARYOP.MUL
+ - af.BINARYOP.MIN
+ - af.BINARYOP.MAX
inclusive_scan: optional: bool. default: True
Specifies if the scan is inclusive
@@ -353,7 +361,7 @@ def scan_by_key(key, a, dim=0, op=BINARYOP.BINARY_ADD, inclusive_scan=True):
- will contain scan of input.
"""
out = Array()
- safe_call(backend.get().af_scan_by_key(ct.pointer(out.arr), key.arr, a.arr, dim, op, inclusive_scan))
+ safe_call(backend.get().af_scan_by_key(ct.pointer(out.arr), key.arr, a.arr, dim, op.value, inclusive_scan))
return out
def where(a):
diff --git a/arrayfire/image.py b/arrayfire/image.py
index 94a424a..842ce22 100644
--- a/arrayfire/image.py
+++ b/arrayfire/image.py
@@ -1198,7 +1198,7 @@ def rgb2ycbcr(image, standard=YCC_STD.BT_601):
safe_call(backend.get().af_rgb2ycbcr(ct.pointer(out.arr), image.arr, standard.value))
return out
-def moments(image, moment = MOMENT.MOMENT_FIRST_ORDER):
+def moments(image, moment = MOMENT.FIRST_ORDER):
"""
Calculate image moments.
@@ -1208,8 +1208,13 @@ def moments(image, moment = MOMENT.MOMENT_FIRST_ORDER):
- A 2 D arrayfire array representing an image, or
- A multi dimensional array representing batch of images.
- moment : optional: af.MOMENT. default: af.MOMENT.MOMENT_FIRST_ORDER.
- - Moment(s) to calculate
+ moment : optional: af.MOMENT. default: af.MOMENT.FIRST_ORDER.
+ Moment(s) to calculate. Can be one of:
+ - af.MOMENT.M00
+ - af.MOMENT.M01
+ - af.MOMENT.M10
+ - af.MOMENT.M11
+ - af.MOMENT.FIRST_ORDER
Returns
---------
diff --git a/arrayfire/library.py b/arrayfire/library.py
index 79aa823..ef108d4 100644
--- a/arrayfire/library.py
+++ b/arrayfire/library.py
@@ -113,11 +113,16 @@ class INTERP(_Enum):
"""
Interpolation method
"""
- NEAREST = _Enum_Type(0)
- LINEAR = _Enum_Type(1)
- BILINEAR = _Enum_Type(2)
- CUBIC = _Enum_Type(3)
- LOWER = _Enum_Type(4)
+ NEAREST = _Enum_Type(0)
+ LINEAR = _Enum_Type(1)
+ BILINEAR = _Enum_Type(2)
+ CUBIC = _Enum_Type(3)
+ LOWER = _Enum_Type(4)
+ LINEAR_COSINE = _Enum_Type(5)
+ BILINEAR_COSINE = _Enum_Type(6)
+ BICUBIC = _Enum_Type(7)
+ CUBIC_SPLINE = _Enum_Type(8)
+ BICUBIC_SPLINE = _Enum_Type(9)
class PAD(_Enum):
"""
@@ -351,22 +356,23 @@ class MARKER(_Enum):
class MOMENT(_Enum):
"""
- Image Moments
+ Image Moments types
"""
- MOMENT_M00 = _Enum_Type(1)
- MOMENT_M01 = _Enum_Type(2)
- MOMENT_M10 = _Enum_Type(4)
- MOMENT_M11 = _Enum_Type(8)
- MOMENT_FIRST_ORDER = _Enum_Type(15)
+ M00 = _Enum_Type(1)
+ M01 = _Enum_Type(2)
+ M10 = _Enum_Type(4)
+ M11 = _Enum_Type(8)
+ FIRST_ORDER = _Enum_Type(15)
class BINARYOP(_Enum):
"""
Binary Operators
"""
- BINARY_ADD = _Enum_Type(0)
- BINARY_MUL = _Enum_Type(1)
- BINARY_MIN = _Enum_Type(2)
- BINARY_MAX = _Enum_Type(3)
+ ADD = _Enum_Type(0)
+ MUL = _Enum_Type(1)
+ MIN = _Enum_Type(2)
+ MAX = _Enum_Type(3)
+
def _setup():
import platform
--
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