diff -Nru python-fann2-1.0.7/ChangeLog python-fann2-1.1.2+ds/ChangeLog --- python-fann2-1.0.7/ChangeLog 2015-03-31 15:40:24.000000000 +0000 +++ python-fann2-1.1.2+ds/ChangeLog 2017-12-07 19:02:19.000000000 +0000 @@ -2,6 +2,29 @@ CHANGELOG ========= +1.1.2 - 2017-12-07 + + * Fix badly placed return value for nested conditional under FANN libs search function. + * Fixed indentation for raise function under for loop. + +1.1.1 - 2017-12-07 + + * Added '/usr/lib64' directory to FANN libs search function for setup.py. + * Removed unnecessary search block for FreeBSD specifics. + * Pylinted setup.py. + +1.1.0 - 2017-10-02 + + * Fixed build for Windows OS. + * Added Windows installation details to README. + * Added support for 2.7 - 3.6. + * Fixed functions that return arrays and functions that deal with "FANN::connection arrays". Patch by @troiganto. + * Created wheel files for FreeBSD, Windows x64 & Linux (py27 & py36). + +1.0.7 - 2015-03-31 + + * Fixed build for ARM devices + 1.0.6 - 2015-03-30 * Fixed type/size checking for array of arrays (ksuszka/patch-1). diff -Nru python-fann2-1.0.7/debian/changelog python-fann2-1.1.2+ds/debian/changelog --- python-fann2-1.0.7/debian/changelog 2018-11-03 12:08:52.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/changelog 2019-02-17 11:40:31.000000000 +0000 @@ -1,26 +1,39 @@ -python-fann2 (1:1.0.7-6build4) disco; urgency=medium +python-fann2 (1:1.1.2+ds-1) unstable; urgency=medium - * No-change rebuild to build without python3.6 support. + * New upstream version 1.1.2 + - Many smallish bugfixes. + * d/control: + - Point Vcs-* URLs to Salsa + - Switch Build-Depends from debhelper to debhelper-compat + - Remove the now obsolete d/compat + - Bump debhelper compat level to 12 + - Drop ancient X-Python{,3}-Version + - Bump Standards-Version to 4.3.0 + - Drop python-pyfann Priority: extra + * Add Rules-Requires-Root: no + We don't need (fake)root for building the packages + * d/patches: + - Refresh Improve-SWIG-invocation.patch + - Add Don-t-check-for-existence-of-libfann.patch + libfann is in Build-Depends, and therefore present + * d/test: Rename ADTTMP to AUTOPKGTEST + * d/rules: Remove fann2.egg-info on clean + * Add d/source/lintian-overrides + - Add tag override_dh_auto_test-does-not-check-DEB_BUILD_OPTIONS + False-positive. We do override dh_auto_test, but, only to call + dh_auto_test with a prepped environment. + * Add d/NEWS to warn about legacy python-pyfann package + * d/copyright: + - Add Files-Excluded to exclude pre-compiled wheels + - Extend Comment to document this + - Switch Format field to https + - Bump copyrights + * d/watch: + - Update to formation version 4 + - Add repacksuffix and dversionmangle for +ds + * gbp.conf: Set pristine-tar, sign-tags options - -- Matthias Klose Sat, 03 Nov 2018 12:08:52 +0000 - -python-fann2 (1:1.0.7-6build3) cosmic; urgency=medium - - * No-change rebuild to build for python3.7. - - -- Matthias Klose Thu, 28 Jun 2018 06:54:42 +0000 - -python-fann2 (1:1.0.7-6build2) artful; urgency=medium - - * No change rebuild to drop Python 3.5 support. - - -- Michael Hudson-Doyle Fri, 04 Aug 2017 18:52:37 +1200 - -python-fann2 (1:1.0.7-6build1) artful; urgency=medium - - * No change rebuild to add Python 3.6 support. - - -- Michael Hudson-Doyle Fri, 12 May 2017 14:45:47 +1200 + -- Christian Kastner Sun, 17 Feb 2019 12:40:31 +0100 python-fann2 (1:1.0.7-6) unstable; urgency=medium diff -Nru python-fann2-1.0.7/debian/compat python-fann2-1.1.2+ds/debian/compat --- python-fann2-1.0.7/debian/compat 2016-04-17 14:25:28.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -9 diff -Nru python-fann2-1.0.7/debian/control python-fann2-1.1.2+ds/debian/control --- python-fann2-1.0.7/debian/control 2016-04-17 14:25:28.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/control 2019-02-17 11:40:31.000000000 +0000 @@ -3,7 +3,7 @@ Priority: optional Maintainer: Christian Kastner Build-Depends: - debhelper (>= 9), + debhelper-compat (= 12), dh-python, python-all-dev, python-setuptools, @@ -11,12 +11,11 @@ python3-setuptools, swig (>= 2.0.4-2), libfann-dev (>= 2.2.0), -Standards-Version: 3.9.8 +Rules-Requires-Root: no +Standards-Version: 4.3.0 Homepage: https://github.com/FutureLinkCorporation/fann2/ -Vcs-Git: https://anonscm.debian.org/git/debian-science/packages/python-fann2.git -Vcs-Browser: https://anonscm.debian.org/cgit/debian-science/packages/python-fann2.git -X-Python-Version: >= 2.6 -X-Python3-Version: >= 3.0 +Vcs-Git: https://salsa.debian.org/science-team/python-fann2.git +Vcs-Browser: https://salsa.debian.org/science-team/python-fann2 Package: python3-fann2 Architecture: any @@ -46,7 +45,6 @@ Package: python-pyfann Section: oldlibs -Priority: extra Architecture: any Depends: ${python:Depends}, diff -Nru python-fann2-1.0.7/debian/copyright python-fann2-1.1.2+ds/debian/copyright --- python-fann2-1.0.7/debian/copyright 2016-04-17 14:25:28.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/copyright 2019-02-17 11:40:31.000000000 +0000 @@ -1,14 +1,18 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: fann2 Source: https://github.com/FutureLinkCorporation/fann2/ +Files-Excluded: + wheels Comment: + The source is repackaged to excluded the binary wheels. + . Until FANN-2.1.0, the Python bindings to FANN were provided by src:libfann itself. These are now maintained by an external contributor, hence a separate source package. Files: * Copyright: 2004-2007, Vincenzo Di Massa - 2014-2015, FutureLinkCorporation + 2014-2017, FutureLinkCorporation License: LGPL-2.1+ Files: include/* @@ -25,7 +29,7 @@ Files: debian/patches/Add-an-example.patch Copyright: 2004-2007, Vincenzo Di Massa - 2015, Christian Kastner + 2015-2019, Christian Kastner License: LGPL-2.1+ License: LGPL-2.1+ diff -Nru python-fann2-1.0.7/debian/gbp.conf python-fann2-1.1.2+ds/debian/gbp.conf --- python-fann2-1.0.7/debian/gbp.conf 2016-04-17 14:25:28.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/gbp.conf 2019-02-17 11:40:31.000000000 +0000 @@ -1,2 +1,8 @@ +[DEFAULT] +pristine-tar = True + +[buildpackage] +sign-tags = True + [pq] patch-numbers = False diff -Nru python-fann2-1.0.7/debian/NEWS python-fann2-1.1.2+ds/debian/NEWS --- python-fann2-1.0.7/debian/NEWS 1970-01-01 00:00:00.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/NEWS 2019-02-17 11:40:31.000000000 +0000 @@ -0,0 +1,8 @@ +python-fann2 (1:1.0.7-6) unstable; urgency=medium + + If you are still using package python-pyfann, please switch to python-fann2, + which are the bindings provided by the new upstream. + + python-pyfann will be removed from the archive soon. + + -- Christian Kastner Sun, 17 Feb 2019 12:24:27 +0100 diff -Nru python-fann2-1.0.7/debian/patches/Don-t-check-for-existence-of-libfann.patch python-fann2-1.1.2+ds/debian/patches/Don-t-check-for-existence-of-libfann.patch --- python-fann2-1.0.7/debian/patches/Don-t-check-for-existence-of-libfann.patch 1970-01-01 00:00:00.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/patches/Don-t-check-for-existence-of-libfann.patch 2019-02-17 11:40:31.000000000 +0000 @@ -0,0 +1,48 @@ +From: Christian Kastner +Date: Sun, 17 Feb 2019 12:13:49 +0100 +Subject: Don't check for existence of libfann + +It's in Build-Depends, and therefore present. +--- + setup.py | 21 --------------------- + 1 file changed, 21 deletions(-) + +diff --git a/setup.py b/setup.py +index 174b137..cb3eae4 100755 +--- a/setup.py ++++ b/setup.py +@@ -53,25 +53,6 @@ def find_x(path1): + if "doublefann" in lib_dir: + return True + +-def find_fann(): +- '''Find doublefann library''' +- # FANN possible libs directories (as $LD_LIBRARY_PATH), also includes +- # pkgsrc framework support. +- if sys.platform == "win32": +- dirs = sys.path +- for ver in dirs: +- if os.path.isdir(ver): +- if find_x(ver): +- return True +- raise Exception("Couldn't find FANN source libs!") +- else: +- dirs = ['/lib', '/usr/lib', '/usr/lib64', '/usr/local/lib', '/usr/pkg/lib'] +- for path in dirs: +- if os.path.isdir(path): +- if find_x(path): +- return True +- raise Exception("Couldn't find FANN source libs!") +- + def find_swig(): + '''Find SWIG executable path''' + for executable in ("swig2.0", "swig"): +@@ -81,8 +62,6 @@ def find_swig(): + + def build_swig(): + '''Run SWIG with specified parameters''' +- print("Looking for FANN libs...") +- find_fann() + print("running SWIG...") + swig_bin = find_swig() + swig_cmd = [swig_bin, '-c++', '-python', 'fann2/fann2.i'] diff -Nru python-fann2-1.0.7/debian/patches/Improve-SWIG-invocation.patch python-fann2-1.1.2+ds/debian/patches/Improve-SWIG-invocation.patch --- python-fann2-1.0.7/debian/patches/Improve-SWIG-invocation.patch 2016-04-17 14:25:28.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/patches/Improve-SWIG-invocation.patch 2019-02-17 11:40:31.000000000 +0000 @@ -5,35 +5,35 @@ Only build the extension in the build target (instead of in all targets but sdist), and don't install unnecessary files. -Last-Update: 2015-09-29 +Last-Update: 2019-02-17 --- setup.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py -index b4afbbb..6741fae 100755 +index 37af7c7..174b137 100755 --- a/setup.py +++ b/setup.py -@@ -61,7 +61,7 @@ def build_swig(): - swig_cmd = [swig_bin, '-c++', '-python', 'fann2/fann2.i'] - subprocess.Popen(swig_cmd).wait() - --if "sdist" not in sys.argv: -+if "build" in sys.argv: - build_swig() - - -@@ -92,10 +92,11 @@ setup( - ], - keywords="ANN artificial intelligence FANN2.2.0 bindings".split(' '), - zip_safe=False, -- include_package_data=True, -+ include_package_data=False, - packages=find_packages(), - py_modules=['fann2.libfann'], -- ext_modules=[Extension('fann2._libfann', ['fann2/fann2_wrap.cxx'], -+ ext_modules=[Extension('fann2._libfann', ['fann2/fann2.i'], -+ swig_opts=['-c++'], - include_dirs=['./include', - '../include', 'include'], - libraries=['doublefann'], +@@ -88,7 +88,7 @@ def build_swig(): + swig_cmd = [swig_bin, '-c++', '-python', 'fann2/fann2.i'] + subprocess.Popen(swig_cmd).wait() + +-if "sdist" not in sys.argv: ++if "build" in sys.argv: + build_swig() + + setup( +@@ -117,10 +117,11 @@ setup( + ], + keywords="ANN artificial intelligence FANN2.2.0 bindings".split(' '), + zip_safe=False, +- include_package_data=True, ++ include_package_data=False, + packages=find_packages(), + py_modules=['fann2.libfann'], +- ext_modules=[Extension('fann2._libfann', ['fann2/fann2_wrap.cxx'], ++ ext_modules=[Extension('fann2._libfann', ['fann2/fann2.i'], ++ swig_opts=['-c++'], + include_dirs=['./include', + '../include', 'include'], + libraries=['doublefann'], diff -Nru python-fann2-1.0.7/debian/patches/series python-fann2-1.1.2+ds/debian/patches/series --- python-fann2-1.0.7/debian/patches/series 2016-04-17 14:25:28.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/patches/series 2019-02-17 11:40:31.000000000 +0000 @@ -1,2 +1,3 @@ Improve-SWIG-invocation.patch Add-an-example.patch +Don-t-check-for-existence-of-libfann.patch diff -Nru python-fann2-1.0.7/debian/rules python-fann2-1.1.2+ds/debian/rules --- python-fann2-1.0.7/debian/rules 2016-04-17 14:25:28.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/rules 2019-02-17 11:40:31.000000000 +0000 @@ -18,7 +18,7 @@ PYBUILD_SYSTEM=custom \ PYBUILD_TEST_ARGS="\ - ADTTMP={dir}/test \ + AUTOPKGTEST_TMP={dir}/test \ PYTHONPATH={build_dir} \ PYINTERPRETER={interpreter} \ /bin/sh $(CURDIR)/debian/tests/python{version.major}-basic" \ @@ -42,6 +42,7 @@ override_dh_auto_clean: dh_auto_clean + rm -rf fann2.egg-info rm -rf build rm -rf test rm -f fann2/fann2_wrap.cxx fann2/fann2_wrap.cpp diff -Nru python-fann2-1.0.7/debian/source/lintian-overrides python-fann2-1.1.2+ds/debian/source/lintian-overrides --- python-fann2-1.0.7/debian/source/lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/source/lintian-overrides 2019-02-17 11:40:31.000000000 +0000 @@ -0,0 +1,3 @@ +# False-positive. We do override dh_auto_test, but, only to call dh_auto_test +# with a prepped environment. +python-fann2: override_dh_auto_test-does-not-check-DEB_BUILD_OPTIONS diff -Nru python-fann2-1.0.7/debian/tests/common python-fann2-1.1.2+ds/debian/tests/common --- python-fann2-1.0.7/debian/tests/common 2016-04-17 14:25:28.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/tests/common 2019-02-17 11:40:31.000000000 +0000 @@ -1,13 +1,13 @@ #!/bin/sh # Consolidates common code of the autopkgtests -# Requires that ADTTMP and PYINTERPRETER are set +# Requires that AUTOPKGTEST_TMP and PYINTERPRETER are set set -e -# Presence of $ADTTMP implies that someone will handle cleanup for us -if [ -z "$ADTTMP" ] +# Presence of $AUTOPKGTEST_TMP implies that someone will handle cleanup for us +if [ -z "$AUTOPKGTEST_TMP" ] then - echo "Required envvar ADTTMP is not set" >&2 + echo "Required envvar AUTOPKGTEST is not set" >&2 exit 1 fi @@ -17,11 +17,11 @@ exit 1 fi -# Copy the simple example and the training data to $ADTTMP, and execute it -mkdir -p "$ADTTMP/$PYINTERPRETER" -cp examples/simple_train.py "$ADTTMP/$PYINTERPRETER" -cp examples/xor.data "$ADTTMP/$PYINTERPRETER" -cd "$ADTTMP/$PYINTERPRETER" +# Copy the simple example and the training data to $AUTOPKGTEST, and execute it +mkdir -p "$AUTOPKGTEST_TMP/$PYINTERPRETER" +cp examples/simple_train.py "$AUTOPKGTEST_TMP/$PYINTERPRETER" +cp examples/xor.data "$AUTOPKGTEST_TMP/$PYINTERPRETER" +cd "$AUTOPKGTEST_TMP/$PYINTERPRETER" if [ "$1" = "pyfann" ] then diff -Nru python-fann2-1.0.7/debian/watch python-fann2-1.1.2+ds/debian/watch --- python-fann2-1.0.7/debian/watch 2016-04-17 14:25:28.000000000 +0000 +++ python-fann2-1.1.2+ds/debian/watch 2019-02-17 11:40:31.000000000 +0000 @@ -1,4 +1,7 @@ -version=3 +version=4 -opts="filenamemangle=s/.+\/(\d\S*)\.tar\.gz/python-fann2-$1\.tar\.gz/" \ - https://github.com/FutureLinkCorporation/fann2/releases .*/(\d\S*)\.tar\.gz +opts=\ +dversionmangle=s/\+ds//,\ +filenamemangle=s/.+\/(\d\S*)\.tar\.gz/python-fann2-$1\.tar\.gz/,\ +repacksuffix=+ds \ +https://github.com/FutureLinkCorporation/fann2/releases .*/(\d\S*)\.tar\.gz diff -Nru python-fann2-1.0.7/fann2/fann2.i python-fann2-1.1.2+ds/fann2/fann2.i --- python-fann2-1.0.7/fann2/fann2.i 2015-03-31 15:40:24.000000000 +0000 +++ python-fann2-1.1.2+ds/fann2/fann2.i 2017-12-07 19:02:19.000000000 +0000 @@ -15,7 +15,7 @@ #include "fann_cpp_subclass.h" %} -%define HELPER_ARRAY_TEMPLATE( templ , T, GetFunc, SetFunc, cast) +%define HELPER_ARRAY_TEMPLATE( templ , T, GetFunc, SetFunc, cast) %typemap(in) templ * (templ temp){ // templ* type_map in int i; @@ -35,7 +35,7 @@ if (PyNumber_Check(o)) { $1->array[i] = (T) GetFunc(o); } else { - PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers"); + PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers"); Py_DECREF(o); SWIG_fail; } @@ -44,8 +44,8 @@ } %typemap(freearg) templ* { // templ* type_map freearg - if ($1 && $1->array && $1->can_delete) - { + if ($1 && $1->array && $1->can_delete) + { free($1->array); } } @@ -53,29 +53,13 @@ %typemap(out) templ* { // templ* type_map out $result= PyList_New( $1->array_len ); - for (unsigned int i = 0; i < $1->array_len; i++) + for (unsigned int i = 0; i < $1->array_len; i++) { PyObject *o = SetFunc( (cast) $1->array[i]); PyList_SetItem($result,i,o); } - if ($1 && $1->array && $1->can_delete) - { - free($1->array); - } - if ($1) delete $1; - -} - -%typemap(argout) templ* ARGOUT{ - // templ* type_map out - $result= PyList_New( $1->array_len ); - for (unsigned int i = 0; i < $1->array_len; i++) + if ($1 && $1->array && $1->can_delete) { - PyObject *o = SetFunc( (cast) $1->array[i]); - PyList_SetItem($result,i,o); - } - if ($1 && $1->array && $1->can_delete) - { free($1->array); } if ($1) delete $1; @@ -83,10 +67,10 @@ %enddef -%define HELPER_ARRAY_ARRAY_TEMPLATE(templ, T, GetFunc, SetFunc, cast) +%define HELPER_ARRAY_ARRAY_TEMPLATE(templ, T, GetFunc, SetFunc, cast) %typemap(in) templ< T >* ( templ temp) { // templ* type_map - unsigned int i; + unsigned int i; unsigned int j; unsigned int dim; unsigned int num; @@ -101,7 +85,7 @@ $1=&temp; num=PySequence_Length($input); $1->array_num=num; - + PyObject* o0=PySequence_GetItem($input,0); if (!PySequence_Check(o0)) { PyErr_SetString(PyExc_ValueError,"Expected an inner sequence"); @@ -110,10 +94,10 @@ } dim=PySequence_Length(o0); Py_DECREF(o0); - + $1->array_len=dim; $1->arrays = (T **) calloc(num,sizeof(T*)); - + for (j = 0; j< num; j++) { PyObject* o1=PySequence_GetItem($input,j); @@ -133,7 +117,7 @@ if (PyNumber_Check(o)) { $1->arrays[j][i] = (T) GetFunc(o); } else { - PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers"); + PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers"); Py_DECREF(o); Py_DECREF(o1); SWIG_fail; @@ -146,10 +130,10 @@ %typemap(freearg) templ< T >* { // templ* type_map freearg unsigned int i; - if ($1 && $1->arrays && $1->can_delete) + if ($1 && $1->arrays && $1->can_delete) { for (i=0; i < $1->array_num;++i) - if ($1->arrays[i]) + if ($1->arrays[i]) free($1->arrays[i]); free($1->arrays); } @@ -157,11 +141,11 @@ %typemap(out) templ* { // templ* type_map out $result= PyList_New( $1->array_num ); - for (unsigned int j = 0; j < $1->array_num; ++j) + for (unsigned int j = 0; j < $1->array_num; ++j) { PyObject *l= PyList_New( $1->array_len ); PyList_SetItem($result,j,l); - for (unsigned int i = 0; i < $1->array_len; i++) + for (unsigned int i = 0; i < $1->array_len; i++) { PyObject *o = SetFunc($1->arrays[j][i] ); //PyObject *o = SetFunc($1->arrays[i][j] ); @@ -169,10 +153,10 @@ } } unsigned int i; - if ($1 && $1->arrays && $1->can_delete) + if ($1 && $1->arrays && $1->can_delete) { for (i=0; i < $1->array_num;++i) - if ($1->arrays[i]) + if ($1->arrays[i]) free($1->arrays[i]); free($1->arrays); } @@ -194,6 +178,83 @@ HELPER_ARRAY_ARRAY_TEMPLATE( FANN::helper_array_array, fann_type , PyFloat_AsDouble, PyFloat_FromDouble, double ); + + +// Begin typemap specialization for helper_array*. + +%typemap(in) FANN::helper_array * (FANN::helper_array temp){ + // FANN::helper_array* type_map in + int i; + if (!PySequence_Check($input)) { + PyErr_SetString(PyExc_ValueError,"Expected a sequence"); + SWIG_fail; + } + if (PySequence_Length($input) == 0) { + PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected some elements"); + SWIG_fail; + } + $1=&temp; + $1->array_len=PySequence_Length($input); + $1->array = (FANN::connection *) malloc($1->array_len*sizeof(FANN::connection)); + for (i = 0; i < PySequence_Length($input); i++) { + PyObject *o = PySequence_GetItem($input,i); + if (!PySequence_Check(o) || PySequence_Length(o) != 3) { + PyErr_SetString(PyExc_ValueError,"Connection must be a sequence of length 3"); + SWIG_fail; + } + PyObject *from_neuron = PySequence_GetItem(o,0); + PyObject *to_neuron = PySequence_GetItem(o,1); + PyObject *weight = PySequence_GetItem(o,2); + if (PyInt_Check(from_neuron) && PyInt_Check(to_neuron) && + PyNumber_Check(weight)) { + $1->array[i].from_neuron = (unsigned int) PyInt_AsLong(from_neuron); + $1->array[i].to_neuron = (unsigned int) PyInt_AsLong(to_neuron); + $1->array[i].weight = (fann_type) PyFloat_AsDouble(weight); + } else { + PyErr_SetString(PyExc_ValueError,"Connection elements must be (int, int, float)"); + Py_DECREF(from_neuron); + Py_DECREF(to_neuron); + Py_DECREF(weight); + Py_DECREF(o); + SWIG_fail; + } + Py_DECREF(from_neuron); + Py_DECREF(to_neuron); + Py_DECREF(weight); + Py_DECREF(o); + } +} + +%typemap(freearg) FANN::helper_array* { + // FANN::helper_array* type_map freearg + if ($1 && $1->array && $1->can_delete) + { + free($1->array); + } +} + +%typemap(out) FANN::helper_array* { + // FANN::helper_array* type_map out + $result= PyList_New( $1->array_len ); + for (unsigned int i = 0; i < $1->array_len; i++) + { + PyObject *o = PyTuple_Pack (3, + PyInt_FromLong( (long) ($1->array[i].from_neuron)), + PyInt_FromLong( (long) ($1->array[i].to_neuron)), + PyFloat_FromDouble( (double) ($1->array[i].weight))); + PyList_SetItem($result,i,o); + } + if ($1 && $1->array && $1->can_delete) + { + free($1->array); + } + if ($1) delete $1; +} + +// End typemap specialization for helper_array*. + + + %rename(neural_net_parent) FANN::neural_net; %rename(neural_net) FANN::Neural_net; diff -Nru python-fann2-1.0.7/fann2/fann_cpp_subclass.h python-fann2-1.1.2+ds/fann2/fann_cpp_subclass.h --- python-fann2-1.0.7/fann2/fann_cpp_subclass.h 2015-03-31 15:40:24.000000000 +0000 +++ python-fann2-1.1.2+ds/fann2/fann_cpp_subclass.h 2017-12-07 19:02:19.000000000 +0000 @@ -10,7 +10,7 @@ The FANN namespace groups the C++ wrapper definitions */ namespace FANN { - + template class helper_array { @@ -30,7 +30,7 @@ unsigned int array_len; bool can_delete; }; - + template class helper_array_array { @@ -53,7 +53,7 @@ unsigned int array_num; bool can_delete; }; - + /* Forward declaration of class neural_net and training_data */ class Neural_net; class Training_data; @@ -70,7 +70,7 @@ { public: /* Constructor: training_data - + Default constructor creates an empty neural net. Use , or to initialize. */ @@ -79,7 +79,7 @@ } /* Constructor: training_data - + Copy constructor constructs a copy of the training data. Corresponds to the C API function. */ @@ -115,7 +115,7 @@ or uses the training data for testing and related functions */ /* Method: get_input - + Returns: A pointer to the array of input training data @@ -131,7 +131,7 @@ else { helper_array_array* ret = new helper_array_array; - + ret->arrays=train_data->input; ret->array_num=train_data->num_data; ret->array_len=train_data->num_input; @@ -141,7 +141,7 @@ } /* Method: get_output - + Returns: A pointer to the array of output training data @@ -158,7 +158,7 @@ else { helper_array_array* ret = new helper_array_array; - + ret->arrays=train_data->output; ret->array_num=train_data->num_data; ret->array_len=train_data->num_output; @@ -175,7 +175,7 @@ A copy of the data is made so there are no restrictions on the allocation of the input/output data and the caller is responsible for the deallocation of the data pointed to by input and output. - + See also: , */ @@ -183,16 +183,16 @@ void set_train_data(helper_array_array< fann_type >* input, helper_array_array< fann_type >* output) { - if (input->array_num!=output->array_num) + if (input->array_num!=output->array_num) { std::cerr<<"Error: input and output must have the same dimension!"<can_delete=true; output->can_delete=true; - + training_data::set_train_data(input->array_num, input->array_len, input->arrays, output->array_len, output->arrays); - } + } }; @@ -208,7 +208,7 @@ { public: /* Constructor: neural_net - + Default constructor creates an empty neural net. Use one of the create functions to create the neural network. @@ -247,7 +247,7 @@ This function appears in FANN >= 2.0.0. - */ + */ bool create_standard_array( helper_array* layers) { @@ -294,14 +294,14 @@ /* Method: run - Will run input through the neural network, returning an array of outputs, the number of which being + Will run input through the neural network, returning an array of outputs, the number of which being equal to the number of neurons in the output layer. See also: , This function appears in FANN >= 1.0.0. - */ + */ helper_array* run(helper_array *input) { @@ -324,15 +324,15 @@ Train one iteration with a set of inputs, and a set of desired outputs. This training is always incremental training (see ), since only one pattern is presented. - + Parameters: ann - The neural network structure input - an array of inputs. This array must be exactly long. desired_output - an array of desired outputs. This array must be exactly long. - + See also: , , - + This function appears in FANN >= 1.0.0. */ @@ -351,12 +351,12 @@ Test with a set of inputs, and a set of desired outputs. This operation updates the mean square error, but does not change the network in any way. - + See also: , , - + This function appears in FANN >= 1.0.0. - */ + */ helper_array* test(helper_array *input, helper_array* desired_output) { @@ -377,27 +377,30 @@ /* Method: get_layer_array - Get the number of neurons in each layer in the network. + Return the number of neurons in each layer in the network. Bias is not included so the layers match the create methods. - The layers array must be preallocated to at least - sizeof(unsigned int) * get_num_layers() long. - See also: This function appears in FANN >= 2.1.0 */ - void get_layer_array(helper_array* ARGOUT) + helper_array* get_layer_array() { if (ann != NULL) { - ARGOUT->array_len = fann_get_num_layers(ann); - ARGOUT->array = (unsigned int*) malloc(sizeof(unsigned int)* - ARGOUT->array_len); - fann_get_layer_array(ann, ARGOUT->array); + helper_array* res= new helper_array; + res->array_len = fann_get_num_layers(ann); + res->array = (unsigned int*) malloc(sizeof(unsigned int)* + res->array_len); + res->can_delete = true; + fann_get_layer_array(ann, res->array); + return res; + } + else { + return NULL; } } @@ -413,38 +416,47 @@ This function appears in FANN >= 2.1.0 */ - void get_bias_array(helper_array* ARGOUT) + helper_array* get_bias_array() { if (ann != NULL) { - ARGOUT->array_len = fann_get_num_layers(ann); - ARGOUT->array = (unsigned int*) malloc(sizeof(unsigned int)* - ARGOUT->array_len); - fann_get_bias_array(ann, ARGOUT->array); + helper_array* res= new helper_array; + res->array_len = fann_get_num_layers(ann); + res->array = (unsigned int*) malloc(sizeof(unsigned int)* + res->array_len); + res->can_delete = true; + fann_get_bias_array(ann, res->array); + return res; + } + else { + return NULL; } } /* Method: get_connection_array - Get the connections in the network. - - The connections array must be preallocated to at least - sizeof(struct fann_connection) * get_total_connections() long. + Return the connections in the network. See also: This function appears in FANN >= 2.1.0 */ - - void get_connection_array(helper_array *ARGOUT) + + helper_array* get_connection_array() { if (ann != NULL) { - ARGOUT->array_len = fann_get_total_connections(ann); - ARGOUT->array = (connection*) malloc(sizeof(connection)* - ARGOUT->array_len); - fann_get_connection_array(ann, ARGOUT->array); + helper_array* res= new helper_array; + res->array_len = fann_get_total_connections(ann); + res->array = (connection*) malloc(sizeof(connection)* + res->array_len); + res->can_delete = true; + fann_get_connection_array(ann, res->array); + return res; + } + else { + return NULL; } } /* Method: set_weight_array @@ -475,11 +487,11 @@ /* Method: get_cascade_activation_functions The cascade activation functions array is an array of the different activation functions used by - the candidates. - - See for a description of which candidate neurons will be + the candidates. + + See for a description of which candidate neurons will be generated by this array. - + See also: , , @@ -501,7 +513,7 @@ Sets the array of cascade candidate activation functions. The array must be just as long as defined by the count. - See for a description of which candidate neurons will be + See for a description of which candidate neurons will be generated by this array. See also: @@ -526,7 +538,7 @@ The cascade activation steepnesses array is an array of the different activation functions used by the candidates. - See for a description of which candidate neurons will be + See for a description of which candidate neurons will be generated by this array. The default activation steepnesses is {0.25, 0.50, 0.75, 1.00} @@ -546,14 +558,14 @@ activation_steepnesses->array = fann_get_cascade_activation_steepnesses(ann); } return activation_steepnesses; - } + } /* Method: set_cascade_activation_steepnesses Sets the array of cascade candidate activation steepnesses. The array must be just as long as defined by the count. - See for a description of which candidate neurons will be + See for a description of which candidate neurons will be generated by this array. See also: diff -Nru python-fann2-1.0.7/include/fann_cpp.h python-fann2-1.1.2+ds/include/fann_cpp.h --- python-fann2-1.0.7/include/fann_cpp.h 2015-03-31 15:40:24.000000000 +0000 +++ python-fann2-1.1.2+ds/include/fann_cpp.h 2017-12-07 19:02:19.000000000 +0000 @@ -952,15 +952,15 @@ This function appears in FANN >= 2.0.0. */ - bool create_standard(unsigned int num_layers, ...) - { + bool create_standard(unsigned int num_layers, ...) { va_list layers; - unsigned int arr[num_layers]; + unsigned int* arr= new unsigned int[num_layers]; va_start(layers, num_layers); for (unsigned int ii = 0; ii < num_layers; ii++) arr[ii] = va_arg(layers, unsigned int); bool status = create_standard_array(num_layers, arr); + delete[] arr; va_end(layers); return status; } @@ -1005,15 +1005,15 @@ This function appears in FANN >= 2.0.0. */ - bool create_sparse(float connection_rate, unsigned int num_layers, ...) - { + bool create_sparse(float connection_rate, unsigned int num_layers, ...) { va_list layers; - unsigned int arr[num_layers]; + unsigned int* arr= new unsigned int[num_layers]; va_start(layers, num_layers); for (unsigned int ii = 0; ii < num_layers; ii++) arr[ii] = va_arg(layers, unsigned int); bool status = create_sparse_array(connection_rate, num_layers, arr); + delete[] arr; va_end(layers); return status; } @@ -1055,15 +1055,15 @@ This function appears in FANN >= 2.0.0. */ - bool create_shortcut(unsigned int num_layers, ...) - { + bool create_shortcut(unsigned int num_layers, ...) { va_list layers; - unsigned int arr[num_layers]; + unsigned int* arr= new unsigned int[num_layers]; va_start(layers, num_layers); for (unsigned int ii = 0; ii < num_layers; ii++) arr[ii] = va_arg(layers, unsigned int); bool status = create_shortcut_array(num_layers, arr); + delete[] arr; va_end(layers); return status; } diff -Nru python-fann2-1.0.7/README.rst python-fann2-1.1.2+ds/README.rst --- python-fann2-1.0.7/README.rst 2015-03-31 15:40:24.000000000 +0000 +++ python-fann2-1.1.2+ds/README.rst 2017-12-07 19:02:19.000000000 +0000 @@ -7,17 +7,17 @@ ===== Python bindings for Fast Artificial Neural Networks 2.2.0 (FANN >= 2.2.0). These -are the original python bindings included with FANN 2.1.0beta and updated to -include support for python 2.6-3.4. +are the original python bindings included with FANN 2.1.0 beta and updated to +include support for python 2.6-3.6. DESCRIPTION =========== This is a python binding for Fast Artificial Neural Network Library (FANN >= -2.2.0) that implements multilayer artificial neural networks with support for +2.2.0) that implements multi-layer artificial neural networks with support for both fully-connected and sparsely-connected networks. It includes a framework -for easy handling of training data sets. It is easy to use, versatile, well- +for easily handling training data sets. It is easy to use, versatile, well- documented, and fast. FANN 2.2.0 source @@ -32,6 +32,12 @@ You can install fann2 from pkgsrc or from pypi, using either pip or easy_install: +wheels +------ + + $ pip install ${wheel_file} + + pypi ---- @@ -67,6 +73,17 @@ pkgin -y install py-fann2 +Windows considerations +---------------------- + +Source installation +................... + +- Install Visual C++ Build Tools; +- Install `FANN source code `_, using cmake; +- Copy "fanndouble.lib" from FANN installed files to ${python_libs_directory} as "doublefann.lib"; +- Install swig for Windows (you will need to set an Enviroment Variable for "swig.exe"); +- Run > python setup.py install from PowerShell/Command Prompt. USAGE ===== @@ -84,7 +101,7 @@ >> train_data = libfann.training_data() -Look at the examples at the FANN documentation and its C++ bindings for further +Look at the examples in the FANN documentation and its C++ bindings for further reference. diff -Nru python-fann2-1.0.7/setup.py python-fann2-1.1.2+ds/setup.py --- python-fann2-1.0.7/setup.py 2015-03-31 15:40:24.000000000 +0000 +++ python-fann2-1.1.2+ds/setup.py 2017-12-07 19:02:19.000000000 +0000 @@ -1,105 +1,130 @@ -#!/usr/bin/python - -from setuptools import setup, Extension, find_packages -import glob -import os -import sys -import subprocess - - -NAME = 'fann2' -VERSION = '1.0.7' - -with open("README.rst") as f: - LONG_DESCRIPTION = f.read() - - -def find_executable(executable, path=None): - """Try to find 'executable' in the directories listed in 'path' (a - string listing directories separated by 'os.pathsep'; defaults to - os.environ['PATH']). Returns the complete filename or None if not - found - """ - if path is None: - path = os.environ['PATH'] - paths = path.split(os.pathsep) - extlist = [''] - if os.name == 'os2': - (base, ext) = os.path.splitext(executable) - # executable files on OS/2 can have an arbitrary extension, but - # .exe is automatically appended if no dot is present in the name - if not ext: - executable = executable + ".exe" - elif sys.platform == 'win32': - pathext = os.environ['PATHEXT'].lower().split(os.pathsep) - (base, ext) = os.path.splitext(executable) - if ext.lower() not in pathext: - extlist = pathext - for ext in extlist: - execname = executable + ext - if os.path.isfile(execname): - return execname - else: - for p in paths: - f = os.path.join(p, execname) - if os.path.isfile(f): - return f - else: - return None - - -def find_swig(): - for executable in ("swig2.0", "swig"): - if find_executable(executable): - return executable - raise Exception("Couldn't find swig2.0 binary!") - - -def build_swig(): - print("running swig") - swig_bin = find_swig() - swig_cmd = [swig_bin, '-c++', '-python', 'fann2/fann2.i'] - subprocess.Popen(swig_cmd).wait() - -if "sdist" not in sys.argv: - build_swig() - - -def hunt_files(root, which): - return glob.glob(os.path.join(root, which)) - -setup( - name=NAME, - description='Fast Artificial Neural Network Library (fann) bindings.', - long_description=LONG_DESCRIPTION, - version=VERSION, - author='Steffen Nissen', - author_email='lukesky@diku.dk', - maintainer='Gil Megidish, Vincenzo Di Massa and FutureLinkCorporation', - maintainer_email='gil@megidish.net & hawk.it@tiscali,it and devel@futurelinkcorporation.com', - url='https://github.com/FutureLinkCorporation/fann2', - license='GNU LESSER GENERAL PUBLIC LICENSE (LGPL)', - dependency_links=[ - "http://sourceforge.net/projects/fann/files/fann/2.2.0/FANN-2.2.0-Source.zip/download", - "http://www.swig.org/download.html"], - classifiers=[ - "Development Status :: 4 - Beta", - "Topic :: Scientific/Engineering :: Artificial Intelligence", - "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.3", - "Programming Language :: Python :: 3.4" - ], - keywords="ANN artificial intelligence FANN2.2.0 bindings".split(' '), - zip_safe=False, - include_package_data=True, - packages=find_packages(), - py_modules=['fann2.libfann'], - ext_modules=[Extension('fann2._libfann', ['fann2/fann2_wrap.cxx'], - include_dirs=['./include', - '../include', 'include'], - libraries=['doublefann'], - define_macros=[("SWIG_COMPILE", None)] - ), - ] -) +#!/usr/bin/python +'''FANN Python bindings setup''' + +import os +import os.path +import sys +import subprocess +from setuptools import setup, Extension, find_packages + +NAME = 'fann2' +VERSION = '1.1.2' + +with open("README.rst") as f: + LONG_DESCRIPTION = f.read() + +def find_executable(executable, path=None): + '''Try to find 'executable' in the directories listed in 'path' (a + string listing directories separated by 'os.pathsep'; defaults to + os.environ['PATH']).''' + if path is None: + path = os.environ['PATH'] + paths = path.split(os.pathsep) + extlist = [''] + if os.name == 'os2': + ext = os.path.splitext(executable) + # executable files on OS/2 can have an arbitrary extension, but + # .exe is automatically appended if no dot is present in the name + if not ext: + executable = executable + ".exe" + elif sys.platform == 'win32': + pathext = os.environ['PATHEXT'].lower().split(os.pathsep) + ext = os.path.splitext(executable) + if ext not in pathext: + extlist = pathext + for ext in extlist: + execname = executable + ext + if os.path.isfile(execname): + return execname + else: + for pth in paths: + fil = os.path.join(pth, execname) + if os.path.isfile(fil): + return fil + break + else: + return None + +def find_x(path1): + '''Return true if substring is in string for files + in specified path''' + libs = os.listdir(path1) + for lib_dir in libs: + if "doublefann" in lib_dir: + return True + +def find_fann(): + '''Find doublefann library''' + # FANN possible libs directories (as $LD_LIBRARY_PATH), also includes + # pkgsrc framework support. + if sys.platform == "win32": + dirs = sys.path + for ver in dirs: + if os.path.isdir(ver): + if find_x(ver): + return True + raise Exception("Couldn't find FANN source libs!") + else: + dirs = ['/lib', '/usr/lib', '/usr/lib64', '/usr/local/lib', '/usr/pkg/lib'] + for path in dirs: + if os.path.isdir(path): + if find_x(path): + return True + raise Exception("Couldn't find FANN source libs!") + +def find_swig(): + '''Find SWIG executable path''' + for executable in ("swig2.0", "swig"): + if find_executable(executable): + return executable + raise Exception("Couldn't find SWIG binary!") + +def build_swig(): + '''Run SWIG with specified parameters''' + print("Looking for FANN libs...") + find_fann() + print("running SWIG...") + swig_bin = find_swig() + swig_cmd = [swig_bin, '-c++', '-python', 'fann2/fann2.i'] + subprocess.Popen(swig_cmd).wait() + +if "sdist" not in sys.argv: + build_swig() + +setup( + name=NAME, + description='Fast Artificial Neural Network Library (FANN) Python bindings.', + long_description=LONG_DESCRIPTION, + version=VERSION, + author='Steffen Nissen', + author_email='lukesky@diku.dk', + maintainer='Gil Megidish, Vincenzo Di Massa and FutureLinkCorporation', + maintainer_email='gil@megidish.net & hawk.it@tiscali,it and devel@futurelinkcorporation.com', + url='https://github.com/FutureLinkCorporation/fann2', + license='GNU LESSER GENERAL PUBLIC LICENSE (LGPL)', + dependency_links=[ + "http://sourceforge.net/projects/fann/files/fann/2.2.0/FANN-2.2.0-Source.zip/download", + "http://www.swig.org/download.html"], + classifiers=[ + "Development Status :: 4 - Beta", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3.3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6" + ], + keywords="ANN artificial intelligence FANN2.2.0 bindings".split(' '), + zip_safe=False, + include_package_data=True, + packages=find_packages(), + py_modules=['fann2.libfann'], + ext_modules=[Extension('fann2._libfann', ['fann2/fann2_wrap.cxx'], + include_dirs=['./include', + '../include', 'include'], + libraries=['doublefann'], + define_macros=[("SWIG_COMPILE", None)] + ), + ] +)