From 5bda390d825332dc12b7cad272c04c716eabb681 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Tue, 31 Jul 2018 17:37:52 -0400 Subject: [PATCH 01/22] bugfix: forgot to include tlTimer.h in tlThreads.cc --- src/tl/tl/tlThreads.cc | 1 + src/tl/tl/tlTimer.cc | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tl/tl/tlThreads.cc b/src/tl/tl/tlThreads.cc index 239dcaa5f..d87927671 100644 --- a/src/tl/tl/tlThreads.cc +++ b/src/tl/tl/tlThreads.cc @@ -24,6 +24,7 @@ #include "tlThreads.h" #include "tlUtils.h" +#include "tlTimer.h" #include "tlLog.h" #include "tlInternational.h" diff --git a/src/tl/tl/tlTimer.cc b/src/tl/tl/tlTimer.cc index 197fbd19a..59c317f9e 100644 --- a/src/tl/tl/tlTimer.cc +++ b/src/tl/tl/tlTimer.cc @@ -22,7 +22,6 @@ #include "tlTimer.h" -#include "tlUtils.h" #include "tlLog.h" #include "tlString.h" From 98a6b39e688789099839c0c5cafe22c55c29786b Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Tue, 31 Jul 2018 17:55:47 -0400 Subject: [PATCH 02/22] changing travis build order. macos first --- .travis.yml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index cec6b84c8..a95cfe66d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,22 @@ matrix: include: + - os: osx + osx_image: xcode9.3 # macOS 10.13 + env: + - MATRIX_EVAL="" + - os: osx + osx_image: xcode8.3 # macOS 10.12 + env: + - MATRIX_EVAL="" + - os: osx + osx_image: xcode8 # macOS 10.11 + env: + - MATRIX_EVAL="" - os: linux dist: trusty # Ubuntu 14.04 sudo: false language: python - python: '2.6' + python: '3.6' env: - MATRIX_EVAL="" - os: linux @@ -14,6 +26,13 @@ matrix: python: '2.7' env: - MATRIX_EVAL="" + - os: linux + dist: trusty # Ubuntu 14.04 + sudo: false + language: python + python: '2.6' + env: + - MATRIX_EVAL="" - os: linux dist: trusty # Ubuntu 14.04 sudo: false @@ -35,25 +54,6 @@ matrix: python: '3.5' env: - MATRIX_EVAL="" - - os: linux - dist: trusty # Ubuntu 14.04 - sudo: false - language: python - python: '3.6' - env: - - MATRIX_EVAL="" - - os: osx - osx_image: xcode9.3 # macOS 10.13 - env: - - MATRIX_EVAL="" - - os: osx - osx_image: xcode8.3 # macOS 10.12 - env: - - MATRIX_EVAL="" - - os: osx - osx_image: xcode8 # macOS 10.11 - env: - - MATRIX_EVAL="" before_install: - env From 98d66725eb2cf20184805231d71606dfc45bdf8a Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Tue, 31 Jul 2018 19:06:20 -0400 Subject: [PATCH 03/22] adding multithreaded extension build for setup.py --- setup.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/setup.py b/setup.py index 23635782d..b37c219b5 100644 --- a/setup.py +++ b/setup.py @@ -60,6 +60,26 @@ import os import platform import distutils.sysconfig as sysconfig + +# monkey-patch for parallel compilation +# from https://stackoverflow.com/questions/11013851/speeding-up-build-process-with-distutils +def parallelCCompile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): + # those lines are copied from distutils.ccompiler.CCompiler directly + macros, objects, extra_postargs, pp_opts, build = self._setup_compile(output_dir, macros, include_dirs, sources, depends, extra_postargs) + cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) + # parallel code + N=2 # number of parallel compilations + import multiprocessing.pool + def _single_compile(obj): + try: src, ext = build[obj] + except KeyError: return + self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) + # convert to list, imap is evaluated on-demand + list(multiprocessing.pool.ThreadPool(N).imap(_single_compile,objects)) + return objects +import distutils.ccompiler +distutils.ccompiler.CCompiler.compile=parallelCCompile + # ---------------------------------------------------------------------------------------- From 568035cdd65fbe07e998bcf8a5824570cdb2a883 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Wed, 1 Aug 2018 11:56:50 -0400 Subject: [PATCH 04/22] adding __rmul__ in all objects with __mul__ --- src/pya/pya/pyaModule.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pya/pya/pyaModule.cc b/src/pya/pya/pyaModule.cc index 793f4f2ad..90b03a704 100644 --- a/src/pya/pya/pyaModule.cc +++ b/src/pya/pya/pyaModule.cc @@ -2698,6 +2698,11 @@ PythonModule::make_classes (const char *mod_name) add_python_doc (*c, mt, mid, tl::to_string (tr ("This method enables iteration of the object"))); alt_names.push_back ("__iter__"); + } else if (name == "__mul__") { + // Adding right multiplication + // Rationale: if pyaObj * x works, so should x * pyaObj + add_python_doc (*c, mt, mid, tl::to_string (tr ("This method is also available as '__mul__'"))); + alt_names.push_back ("__rmul__"); } for (std::vector ::const_iterator an = alt_names.begin (); an != alt_names.end (); ++an) { From f6d3995d6bf3bc7bd94e9aefe10e81a145c8b564 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Wed, 1 Aug 2018 14:56:58 -0400 Subject: [PATCH 05/22] changing ext/hash_(set|map) to unordered_(set|map) to avoid deprecation warning on mac. --- src/db/db/dbHash.h | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/db/db/dbHash.h b/src/db/db/dbHash.h index 4422dc45b..6a39a9cb5 100644 --- a/src/db/db/dbHash.h +++ b/src/db/db/dbHash.h @@ -23,17 +23,21 @@ #ifndef HDR_dbHash #define HDR_dbHash - -#if defined(__GNUC__) -# include -# include -namespace std_ext = __gnu_cxx; -# define DB_HASH_NAMESPACE __gnu_cxx -#else -# include -# include +#if defined(__APPLE__) // clang compiler complains about deprecation warning on ext/hash_map and ext/hash_set +# include +# include +# define DB_HASH_NAMESPACE std namespace std_ext = std; -# define DB_HASH_NAMESPACE std +#elif defined(__GNUC__) +# include +# include +namespace std_ext = __gnu_cxx; +# define DB_HASH_NAMESPACE __gnu_cxx +#else +# include +# include +namespace std_ext = std; +# define DB_HASH_NAMESPACE std #endif #include "dbPoint.h" @@ -74,7 +78,7 @@ namespace DB_HASH_NAMESPACE }; #endif -#if defined(_WIN64) || defined(__APPLE__) +#if defined(_WIN64) /** * @brief Specialization missing for long long on WIN64 */ @@ -100,6 +104,13 @@ namespace DB_HASH_NAMESPACE }; #endif +#if defined(__APPLE__) + template + using hash_map = unordered_map<_Key, _Tp>; + template + using hash_set = unordered_set<_Value>; +#endif + template inline size_t hfunc (const T &t) { From 92d8a3dacdc5071c1d8b0a802c20e8c93452bc8f Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Wed, 1 Aug 2018 15:57:35 -0400 Subject: [PATCH 06/22] Using C++11 std library on macOS. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index a95cfe66d..7e1f3e308 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,17 @@ matrix: osx_image: xcode9.3 # macOS 10.13 env: - MATRIX_EVAL="" + - ARCHFLAGS="-std=c++11" - os: osx osx_image: xcode8.3 # macOS 10.12 env: - MATRIX_EVAL="" + - ARCHFLAGS="-std=c++11" - os: osx osx_image: xcode8 # macOS 10.11 env: - MATRIX_EVAL="" + - ARCHFLAGS="-std=c++11" - os: linux dist: trusty # Ubuntu 14.04 sudo: false From c8589d6ccb5484628d16193fd31bd7cee4d61744 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Wed, 1 Aug 2018 15:58:53 -0400 Subject: [PATCH 07/22] Using native cpu count for multiprocessing acceleration of pymod build --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b37c219b5..8ec33efe0 100644 --- a/setup.py +++ b/setup.py @@ -68,7 +68,9 @@ def parallelCCompile(self, sources, output_dir=None, macros=None, include_dirs=N macros, objects, extra_postargs, pp_opts, build = self._setup_compile(output_dir, macros, include_dirs, sources, depends, extra_postargs) cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) # parallel code - N=2 # number of parallel compilations + import multiprocessing + + N = multiprocessing.cpu_count() # number of parallel compilations import multiprocessing.pool def _single_compile(obj): try: src, ext = build[obj] From 8cbb76fff6b5c6aa315b0379ea9c946143e45701 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Wed, 1 Aug 2018 19:54:20 -0400 Subject: [PATCH 08/22] limiting number of threads to 4 --- setup.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 8ec33efe0..17763e231 100644 --- a/setup.py +++ b/setup.py @@ -59,28 +59,35 @@ import glob import os import platform import distutils.sysconfig as sysconfig +import multiprocessing +N_cores = multiprocessing.cpu_count() # monkey-patch for parallel compilation # from https://stackoverflow.com/questions/11013851/speeding-up-build-process-with-distutils def parallelCCompile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): # those lines are copied from distutils.ccompiler.CCompiler directly - macros, objects, extra_postargs, pp_opts, build = self._setup_compile(output_dir, macros, include_dirs, sources, depends, extra_postargs) + macros, objects, extra_postargs, pp_opts, build = self._setup_compile( + output_dir, macros, include_dirs, sources, depends, extra_postargs) cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) # parallel code - import multiprocessing - N = multiprocessing.cpu_count() # number of parallel compilations + N = min(N_cores, 4) # number of parallel compilations import multiprocessing.pool + def _single_compile(obj): - try: src, ext = build[obj] - except KeyError: return + try: + src, ext = build[obj] + except KeyError: + return self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) # convert to list, imap is evaluated on-demand - list(multiprocessing.pool.ThreadPool(N).imap(_single_compile,objects)) + list(multiprocessing.pool.ThreadPool(N).imap(_single_compile, objects)) return objects + + import distutils.ccompiler -distutils.ccompiler.CCompiler.compile=parallelCCompile +distutils.ccompiler.CCompiler.compile = parallelCCompile # ---------------------------------------------------------------------------------------- @@ -320,6 +327,7 @@ rdb = Extension(config.root + '.rdb', # Core setup function if __name__ == '__main__': + print("Number of cores", N_cores) setup(name=config.root, version=config.version(), description='KLayout standalone Python package', From 18518353ba179adf0ab5f3a5681e3a52303fab48 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Wed, 1 Aug 2018 20:13:22 -0400 Subject: [PATCH 09/22] testing with more threads for travis ubuntu --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 17763e231..ec224aca5 100644 --- a/setup.py +++ b/setup.py @@ -72,7 +72,8 @@ def parallelCCompile(self, sources, output_dir=None, macros=None, include_dirs=N cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) # parallel code - N = min(N_cores, 4) # number of parallel compilations + N = min(N_cores, len(objects) // 2) # number of parallel compilations + print("Compiling", output_dir, "with", N, "threads.") import multiprocessing.pool def _single_compile(obj): From b0c69d8fe4a4090040b8aeda50e9367bc326d571 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Wed, 1 Aug 2018 20:24:10 -0400 Subject: [PATCH 10/22] capping the number of threads to 8 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ec224aca5..c999361ce 100644 --- a/setup.py +++ b/setup.py @@ -72,8 +72,8 @@ def parallelCCompile(self, sources, output_dir=None, macros=None, include_dirs=N cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) # parallel code - N = min(N_cores, len(objects) // 2) # number of parallel compilations - print("Compiling", output_dir, "with", N, "threads.") + N = min(N_cores, len(objects) // 2, 8) # number of parallel compilations + print("Compiling with", N, "threads.") import multiprocessing.pool def _single_compile(obj): From 51e377cc87b56b2dc09144ebba99331706a62feb Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Wed, 1 Aug 2018 22:29:35 -0400 Subject: [PATCH 11/22] disabling multithreaded build_ext for python 2.6 --- setup.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index c999361ce..1db2f5793 100644 --- a/setup.py +++ b/setup.py @@ -59,6 +59,7 @@ import glob import os import platform import distutils.sysconfig as sysconfig +from distutils.errors import CompileError import multiprocessing N_cores = multiprocessing.cpu_count() @@ -73,6 +74,7 @@ def parallelCCompile(self, sources, output_dir=None, macros=None, include_dirs=N # parallel code N = min(N_cores, len(objects) // 2, 8) # number of parallel compilations + N = max(N, 1) print("Compiling with", N, "threads.") import multiprocessing.pool @@ -81,14 +83,25 @@ def parallelCCompile(self, sources, output_dir=None, macros=None, include_dirs=N src, ext = build[obj] except KeyError: return - self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) + n_tries = 2 + while n_tries > 0: + try: + self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) + except CompileError: + n_tries -= 1 + print("Building", obj, "has failed. Trying again.") + else: + break # convert to list, imap is evaluated on-demand list(multiprocessing.pool.ThreadPool(N).imap(_single_compile, objects)) return objects -import distutils.ccompiler -distutils.ccompiler.CCompiler.compile = parallelCCompile +# only if python version > 2.6, somehow the travis compiler hangs in 2.6 +import sys +if sys.version_info.major >= 2 and sys.version_info.minor > 6: + import distutils.ccompiler + distutils.ccompiler.CCompiler.compile = parallelCCompile # ---------------------------------------------------------------------------------------- From a3234e26451a10be170183899575c83fff5184d5 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Wed, 1 Aug 2018 22:31:09 -0400 Subject: [PATCH 12/22] changing dbHash macro from __APPLE__ to __EXT_HASH_DEPRECATED --- src/db/db/dbHash.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/db/db/dbHash.h b/src/db/db/dbHash.h index 6a39a9cb5..4338d3027 100644 --- a/src/db/db/dbHash.h +++ b/src/db/db/dbHash.h @@ -23,7 +23,11 @@ #ifndef HDR_dbHash #define HDR_dbHash -#if defined(__APPLE__) // clang compiler complains about deprecation warning on ext/hash_map and ext/hash_set + +#if defined(__APPLE__) +#define __EXT_HASH_DEPRECATED +#endif +#if defined(__EXT_HASH_DEPRECATED) // clang compiler complains about deprecation warning on ext/hash_map and ext/hash_set # include # include # define DB_HASH_NAMESPACE std @@ -104,7 +108,7 @@ namespace DB_HASH_NAMESPACE }; #endif -#if defined(__APPLE__) +#if defined(__EXT_HASH_DEPRECATED) template using hash_map = unordered_map<_Key, _Tp>; template From ebf0ae52b4757beba85bd4149168394db5c52ebb Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Wed, 1 Aug 2018 23:45:34 -0400 Subject: [PATCH 13/22] python2.6 fix for setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1db2f5793..68d5a5303 100644 --- a/setup.py +++ b/setup.py @@ -99,7 +99,7 @@ def parallelCCompile(self, sources, output_dir=None, macros=None, include_dirs=N # only if python version > 2.6, somehow the travis compiler hangs in 2.6 import sys -if sys.version_info.major >= 2 and sys.version_info.minor > 6: +if sys.version_info[0] * 10 + sys.version_info[1] > 26: import distutils.ccompiler distutils.ccompiler.CCompiler.compile = parallelCCompile From 1db2bea26c23a448f954dbce25a8e4ba3d97d4a3 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Thu, 2 Aug 2018 00:07:35 -0400 Subject: [PATCH 14/22] adding python2 travis entry for macosx --- .travis.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e1f3e308..a88c38f91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ matrix: include: + # python 3 osx - os: osx - osx_image: xcode9.3 # macOS 10.13 + osx_image: xcode9.4 # macOS 10.13 env: - MATRIX_EVAL="" - ARCHFLAGS="-std=c++11" @@ -15,6 +16,22 @@ matrix: env: - MATRIX_EVAL="" - ARCHFLAGS="-std=c++11" + # python 2 osx + - os: osx + osx_image: xcode9.4 # macOS 10.13 + env: + - MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3';" + - ARCHFLAGS="-std=c++11" + - os: osx + osx_image: xcode8.3 # macOS 10.12 + env: + - MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3';" + - ARCHFLAGS="-std=c++11" + - os: osx + osx_image: xcode8 # macOS 10.11 + env: + - MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3';" + - ARCHFLAGS="-std=c++11" - os: linux dist: trusty # Ubuntu 14.04 sudo: false @@ -62,7 +79,6 @@ before_install: - env - rvm install ruby --latest - gem install dropbox-deployment - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew bundle; shopt -s expand_aliases; alias python='python3'; fi - eval "${MATRIX_EVAL}" - python -c "import distutils.sysconfig as sysconfig; print(sysconfig.__file__)" From cfbcc158bfc2f83eb67001de295870119e2be222 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Thu, 2 Aug 2018 00:37:43 -0400 Subject: [PATCH 15/22] adding / and /= operators to Point and Vector types in db [ci skip] --- src/db/db/dbPoint.h | 40 +++++++++++++++++++++++++++++++++++ src/db/db/dbVector.h | 40 +++++++++++++++++++++++++++++++++++ src/db/db/gsiDeclDbPoint.cc | 41 ++++++++++++++++++++++++++++++++++++ src/db/db/gsiDeclDbVector.cc | 41 ++++++++++++++++++++++++++++++++++++ src/pya/pya/pyaModule.cc | 8 +++++++ 5 files changed, 170 insertions(+) diff --git a/src/db/db/dbPoint.h b/src/db/db/dbPoint.h index c767f7a57..157412fe6 100644 --- a/src/db/db/dbPoint.h +++ b/src/db/db/dbPoint.h @@ -194,6 +194,20 @@ public: */ point &operator*= (long s); + /** + * @brief Division by some divisor. + * + * Scaline involves rounding which in our case is simply handled + * with the coord_traits scheme. + */ + + point &operator/= (double s); + + /** + * @brief Dividing self by some integer divisor + */ + point &operator/= (long s); + /** * @brief The euclidian distance to another point * @@ -452,6 +466,32 @@ operator* (const db::point &p, unsigned int s) return point (p.x () * s, p.y () * s); } +template +inline point +operator/ (const db::point &p, Number s) +{ + double mult = 1.0 / static_cast(s); + return point (p.x () * mult, p.y () * mult); +} + +template +inline point & +point::operator/= (double s) +{ + double mult = 1.0 / static_cast(s); + *this *= mult; + return *this; +} + +template +inline point & +point::operator/= (long s) +{ + double mult = 1.0 / static_cast(s); + *this *= mult; + return *this; +} + template inline point & point::operator*= (double s) diff --git a/src/db/db/dbVector.h b/src/db/db/dbVector.h index ad86d4502..f3432c057 100644 --- a/src/db/db/dbVector.h +++ b/src/db/db/dbVector.h @@ -266,6 +266,20 @@ public: */ vector operator*= (long s); + /** + * @brief Division by some divisor. + * + * Scaline involves rounding which in our case is simply handled + * with the coord_traits scheme. + */ + + vector &operator/= (double s); + + /** + * @brief Dividing self by some integer divisor + */ + vector &operator/= (long s); + /** * @brief The euclidian length */ @@ -450,6 +464,32 @@ vector::operator* (long s) const return vector (m_x * s, m_y * s); } +template +inline vector +operator/ (const db::vector &p, Number s) +{ + double mult = 1.0 / static_cast(s); + return vector (p.x () * mult, p.y () * mult); +} + +template +inline vector & +vector::operator/= (double s) +{ + double mult = 1.0 / static_cast(s); + *this *= mult; + return *this; +} + +template +inline vector & +vector::operator/= (long s) +{ + double mult = 1.0 / static_cast(s); + *this *= mult; + return *this; +} + template inline vector vector::operator*= (double s) diff --git a/src/db/db/gsiDeclDbPoint.cc b/src/db/db/gsiDeclDbPoint.cc index d80b36959..46892b586 100644 --- a/src/db/db/gsiDeclDbPoint.cc +++ b/src/db/db/gsiDeclDbPoint.cc @@ -70,6 +70,23 @@ struct point_defs return C (*p * s); } + static C divide (const C *p, double s) + { + return C (*p / s); + } + + static C iscale (C *p, double s) + { + *p *= s; + return *p; + } + + static C idiv (C *p, double s) + { + *p /= s; + return *p; + } + static C negate (const C *p) { return -*p; @@ -175,6 +192,30 @@ struct point_defs "Returns the scaled object. All coordinates are multiplied with the given factor and if " "necessary rounded." ) + + method_ext ("*=", &iscale, + "@brief Scaling by some factor\n" + "\n" + "@args f\n" + "\n" + "Scales object in place. All coordinates are multiplied with the given factor and if " + "necessary rounded." + ) + + method_ext ("/", ÷, + "@brief Division by some divisor\n" + "\n" + "@args d\n" + "\n" + "Returns the scaled object. All coordinates are divided with the given divisor and if " + "necessary rounded." + ) + + method_ext ("/=", &idiv, + "@brief Division by some divisor\n" + "\n" + "@args d\n" + "\n" + "Divides the object in place. All coordinates are divided with the given divisor and if " + "necessary rounded." + ) + method ("distance", (double (C::*) (const C &) const) &C::double_distance, "@brief The Euclidian distance to another point\n" "\n" diff --git a/src/db/db/gsiDeclDbVector.cc b/src/db/db/gsiDeclDbVector.cc index 49cf76bb0..aacf6aba4 100644 --- a/src/db/db/gsiDeclDbVector.cc +++ b/src/db/db/gsiDeclDbVector.cc @@ -70,6 +70,23 @@ struct vector_defs return C (*p * s); } + static C divide (const C *p, double s) + { + return C (*p / s); + } + + static C iscale (C *p, double s) + { + *p *= s; + return *p; + } + + static C idiv (C *p, double s) + { + *p /= s; + return *p; + } + static C negate (const C *p) { return -*p; @@ -202,6 +219,30 @@ struct vector_defs "Returns the scaled object. All coordinates are multiplied with the given factor and if " "necessary rounded." ) + + method_ext ("*=", &iscale, + "@brief Scaling by some factor\n" + "\n" + "@args f\n" + "\n" + "Scales object in place. All coordinates are multiplied with the given factor and if " + "necessary rounded." + ) + + method_ext ("/", ÷, + "@brief Division by some divisor\n" + "\n" + "@args d\n" + "\n" + "Returns the scaled object. All coordinates are divided with the given divisor and if " + "necessary rounded." + ) + + method_ext ("/=", &idiv, + "@brief Division by some divisor\n" + "\n" + "@args d\n" + "\n" + "Divides the object in place. All coordinates are divided with the given divisor and if " + "necessary rounded." + ) + method_ext ("vprod", &vprod, "@brief Computes the vector product between self and the given vector\n" "\n" diff --git a/src/pya/pya/pyaModule.cc b/src/pya/pya/pyaModule.cc index 90b03a704..df7ed6c19 100644 --- a/src/pya/pya/pyaModule.cc +++ b/src/pya/pya/pyaModule.cc @@ -493,7 +493,11 @@ static std::string extract_python_name (const std::string &name) } else if (name == "-@") { return "__neg__"; } else if (name == "/") { + #if PY_MAJOR_VERSION < 3 return "__div__"; + #else + return "__truediv__"; + #endif } else if (name == "*") { return "__mul__"; } else if (name == "%") { @@ -515,7 +519,11 @@ static std::string extract_python_name (const std::string &name) } else if (name == "-=") { return "__isub__"; } else if (name == "/=") { + #if PY_MAJOR_VERSION < 3 return "__idiv__"; + #else + return "__itruediv__"; + #endif } else if (name == "*=") { return "__imul__"; } else if (name == "%=") { From d8269120895ac42398440deabdeb746933cc366a Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Thu, 2 Aug 2018 00:55:18 -0400 Subject: [PATCH 16/22] (travis) always installing with latest pip, setuptools, wheel --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index a88c38f91..02a71175a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -79,6 +79,10 @@ before_install: - env - rvm install ruby --latest - gem install dropbox-deployment + - pip --version + - pip install --upgrade pip + - pip --version + - pip install --upgrade setuptools wheel - eval "${MATRIX_EVAL}" - python -c "import distutils.sysconfig as sysconfig; print(sysconfig.__file__)" From 61decac8b4b7855af7182b1ce5c7705c93b2a116 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Thu, 2 Aug 2018 01:14:19 -0400 Subject: [PATCH 17/22] bugfix: travis might not have pip --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 02a71175a..cea34068f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -79,11 +79,12 @@ before_install: - env - rvm install ruby --latest - gem install dropbox-deployment + - eval "${MATRIX_EVAL}" + - if [[ "$TRAVIS_OS_NAME" == "osx" && ! -x "$(command -v pip)" ]]; then sudo easy_install pip; fi - pip --version - pip install --upgrade pip - pip --version - pip install --upgrade setuptools wheel - - eval "${MATRIX_EVAL}" - python -c "import distutils.sysconfig as sysconfig; print(sysconfig.__file__)" install: From 6f19bed834299949af48de745845867835a0bac2 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Thu, 2 Aug 2018 01:22:46 -0400 Subject: [PATCH 18/22] sudo pip install --update pip --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cea34068f..e150ae4ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -82,7 +82,7 @@ before_install: - eval "${MATRIX_EVAL}" - if [[ "$TRAVIS_OS_NAME" == "osx" && ! -x "$(command -v pip)" ]]; then sudo easy_install pip; fi - pip --version - - pip install --upgrade pip + - sudo pip install --upgrade pip - pip --version - pip install --upgrade setuptools wheel - python -c "import distutils.sysconfig as sysconfig; print(sysconfig.__file__)" From a24b172c0f7055996b1bea0c31d458ccfa90aa7d Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Thu, 2 Aug 2018 01:29:11 -0400 Subject: [PATCH 19/22] attempting fix for python in travis xcode8.3 image --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e150ae4ba..034de2bb8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ matrix: - os: osx osx_image: xcode8.3 # macOS 10.12 env: - - MATRIX_EVAL="" + - MATRIX_EVAL="brew install python2 || brew link --overwrite python@2" # deficient python2 in travis's xcode8.3 (no ssl) - ARCHFLAGS="-std=c++11" - os: osx osx_image: xcode8 # macOS 10.11 @@ -80,11 +80,10 @@ before_install: - rvm install ruby --latest - gem install dropbox-deployment - eval "${MATRIX_EVAL}" - - if [[ "$TRAVIS_OS_NAME" == "osx" && ! -x "$(command -v pip)" ]]; then sudo easy_install pip; fi - pip --version - sudo pip install --upgrade pip - pip --version - - pip install --upgrade setuptools wheel + - sudo pip install --upgrade setuptools wheel - python -c "import distutils.sysconfig as sysconfig; print(sysconfig.__file__)" install: From 0b197520473e96fc56a094b1e421837cfbbd4028 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Thu, 2 Aug 2018 01:52:06 -0400 Subject: [PATCH 20/22] small edit to travis [ci skip] --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 034de2bb8..bd45b096d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -81,9 +81,9 @@ before_install: - gem install dropbox-deployment - eval "${MATRIX_EVAL}" - pip --version - - sudo pip install --upgrade pip + - pip install --upgrade pip || sudo pip install --upgrade pip - pip --version - - sudo pip install --upgrade setuptools wheel + - pip install --upgrade setuptools wheel || sudo pip install --upgrade setuptools wheel - python -c "import distutils.sysconfig as sysconfig; print(sysconfig.__file__)" install: From 78c8af9a7cbb049d826cbe573f323a32e9ce49ed Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Thu, 2 Aug 2018 01:54:10 -0400 Subject: [PATCH 21/22] small edit to travis --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index bd45b096d..f14eda984 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,17 +20,17 @@ matrix: - os: osx osx_image: xcode9.4 # macOS 10.13 env: - - MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3';" + - MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3'; alias pip='pip3';" - ARCHFLAGS="-std=c++11" - os: osx osx_image: xcode8.3 # macOS 10.12 env: - - MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3';" + - MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3'; alias pip='pip3';" - ARCHFLAGS="-std=c++11" - os: osx osx_image: xcode8 # macOS 10.11 env: - - MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3';" + - MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3'; alias pip='pip3';" - ARCHFLAGS="-std=c++11" - os: linux dist: trusty # Ubuntu 14.04 From ebcb8fd4b54ff97968eec72fda245465da61e44a Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Thu, 2 Aug 2018 09:21:52 -0400 Subject: [PATCH 22/22] disabling pip upgrade for linux py 2.6 --- .travis.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f14eda984..a8a374a71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,32 +6,38 @@ matrix: env: - MATRIX_EVAL="" - ARCHFLAGS="-std=c++11" + - PIP_UPDATE="1" - os: osx osx_image: xcode8.3 # macOS 10.12 env: - MATRIX_EVAL="brew install python2 || brew link --overwrite python@2" # deficient python2 in travis's xcode8.3 (no ssl) - ARCHFLAGS="-std=c++11" + - PIP_UPDATE="1" - os: osx osx_image: xcode8 # macOS 10.11 env: - MATRIX_EVAL="" - ARCHFLAGS="-std=c++11" + - PIP_UPDATE="1" # python 2 osx - os: osx osx_image: xcode9.4 # macOS 10.13 env: - MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3'; alias pip='pip3';" - ARCHFLAGS="-std=c++11" + - PIP_UPDATE="1" - os: osx osx_image: xcode8.3 # macOS 10.12 env: - MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3'; alias pip='pip3';" - ARCHFLAGS="-std=c++11" + - PIP_UPDATE="1" - os: osx osx_image: xcode8 # macOS 10.11 env: - MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3'; alias pip='pip3';" - ARCHFLAGS="-std=c++11" + - PIP_UPDATE="1" - os: linux dist: trusty # Ubuntu 14.04 sudo: false @@ -39,6 +45,7 @@ matrix: python: '3.6' env: - MATRIX_EVAL="" + - PIP_UPDATE="1" - os: linux dist: trusty # Ubuntu 14.04 sudo: false @@ -46,6 +53,7 @@ matrix: python: '2.7' env: - MATRIX_EVAL="" + - PIP_UPDATE="1" - os: linux dist: trusty # Ubuntu 14.04 sudo: false @@ -53,6 +61,7 @@ matrix: python: '2.6' env: - MATRIX_EVAL="" + - PIP_UPDATE="0" # setuptools installed from last pip has syntax error on py 2.6 - os: linux dist: trusty # Ubuntu 14.04 sudo: false @@ -60,6 +69,7 @@ matrix: python: '3.3' env: - MATRIX_EVAL="" + - PIP_UPDATE="1" - os: linux dist: trusty # Ubuntu 14.04 sudo: false @@ -67,6 +77,7 @@ matrix: python: '3.4' env: - MATRIX_EVAL="" + - PIP_UPDATE="1" - os: linux dist: trusty # Ubuntu 14.04 sudo: false @@ -74,16 +85,19 @@ matrix: python: '3.5' env: - MATRIX_EVAL="" + - PIP_UPDATE="1" before_install: - env - rvm install ruby --latest - gem install dropbox-deployment - eval "${MATRIX_EVAL}" - - pip --version - - pip install --upgrade pip || sudo pip install --upgrade pip - - pip --version - - pip install --upgrade setuptools wheel || sudo pip install --upgrade setuptools wheel + - if [ "${PIP_UPDATE}" == "1" ]; then + pip --version; + pip install --upgrade pip || sudo pip install --upgrade pip; + pip --version; + pip install --upgrade setuptools wheel || sudo pip install --upgrade setuptools wheel; + fi - python -c "import distutils.sysconfig as sysconfig; print(sysconfig.__file__)" install: