diff --git a/ci/scripts/build_and_test.sh b/ci/scripts/build_and_test.sh index 9465a2dd6a3e2544369ed5ca0fb1273be2b9f19e..9fcbd15052434f65fb0450ab17514f1453c367dc 100755 --- a/ci/scripts/build_and_test.sh +++ b/ci/scripts/build_and_test.sh @@ -30,4 +30,4 @@ time ${SCRIPT_DIR}/test.sh "${HYSOP_INSTALL_DIR}" "${HYSOP_DIR}/hysop" # clean everything because image may be commited to retain hysop cache cd rm -rf /tmp/hysop -pip2.7 uninstall hysop +pip3.8 uninstall hysop diff --git a/ci/scripts/config.sh b/ci/scripts/config.sh index ac2158623814d2e73893c48d6e827c8dd2c9c12e..9654bf957ac2853b60ee801f415d0b2355dc3a3a 100755 --- a/ci/scripts/config.sh +++ b/ci/scripts/config.sh @@ -22,7 +22,7 @@ INSTALL_DIR="$2" mkdir -p "${BUILD_DIR}" cd "${BUILD_DIR}" -CC="$3" CXX="$4" FC="$5" cmake -DCMAKE_BUILD_TYPE=Release -DVERBOSE=OFF -DWITH_SCALES=ON -DPYTHON_EXECUTABLE="$(which python2.7)" -DHYSOP_INSTALL="${INSTALL_DIR}" -DFIND_FFTW_STATIC_ONLY=ON -DFIND_FFTW_VERBOSE=ON "${ROOT_DIR}" +CC="$3" CXX="$4" FC="$5" cmake -DCMAKE_BUILD_TYPE=Release -DVERBOSE=OFF -DWITH_SCALES=ON -DPYTHON_EXECUTABLE="$(which python3.8)" -DHYSOP_INSTALL="${INSTALL_DIR}" -DFIND_FFTW_STATIC_ONLY=ON -DFIND_FFTW_VERBOSE=ON "${ROOT_DIR}" if [ ! -f Makefile ]; then echo "The makefile has not been generated." diff --git a/ci/scripts/install.sh b/ci/scripts/install.sh index 82f3f64561b88e76e38b02cac4a2b8b6e66aaa44..6fe6b4b9b226dbe1fd9ff53a7f27006e7b7e6d9d 100755 --- a/ci/scripts/install.sh +++ b/ci/scripts/install.sh @@ -1,7 +1,7 @@ #!/bin/bash set -feu -o pipefail -PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-"$(which python2.7)"} +PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-"$(which python3.8)"} if [ $# -ne 2 ]; then echo "Usage ./install build_folder install_folder" @@ -24,12 +24,12 @@ INSTALL_FOLDER="$2" cd "${BUILD_FOLDER}" make install -if [ ! -d "${INSTALL_FOLDER}/lib/python2.7/site-packages/hysop" ]; then - echo "${INSTALL_FOLDER}/lib/python2.7/site-packages/hysop was not created." +if [ ! -d "${INSTALL_FOLDER}/lib/python3.8/site-packages/hysop" ]; then + echo "${INSTALL_FOLDER}/lib/python3.8/site-packages/hysop was not created." exit 1 fi -export PYTHONPATH="${INSTALL_FOLDER}/lib/python2.7/site-packages" -"${PYTHON_EXECUTABLE}" -c 'import hysop; print hysop' +export PYTHONPATH="${INSTALL_FOLDER}/lib/python3.8/site-packages" +"${PYTHON_EXECUTABLE}" -c 'import hysop; print(hysop)' exit 0 diff --git a/ci/scripts/test.sh b/ci/scripts/test.sh index 706a8f1e11110def06193a245dbd09f168856663..40569b881f311749f25be220bc8cbfaa7515db09 100755 --- a/ci/scripts/test.sh +++ b/ci/scripts/test.sh @@ -1,7 +1,7 @@ #!/bin/bash set -feu -o pipefail -PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-"$(which python2.7)"} +PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-"$(which python3.8)"} if [ $# -lt 2 ]; then echo "Usage ./test install_folder hysop_folder [cache_dir] [backup_cache_dir]" @@ -66,7 +66,7 @@ if [ "${HAS_CACHE_DIR}" = true ]; then mkdir -p "${CACHE_DIR}" fi -export PYTHONPATH="${INSTALL_DIR}/lib/python2.7/site-packages:${INSTALL_DIR}" +export PYTHONPATH="${INSTALL_DIR}/lib/python3.8/site-packages:${INSTALL_DIR}" export MPLBACKEND='cairo' export HYSOP_VERBOSE=0 export HYSOP_DEBUG=0 @@ -79,12 +79,12 @@ export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 export OMPI_MCA_rmaps_base_oversubscribe=1 echo "Trying to load hysop module:" -${PYTHON_EXECUTABLE} -c 'import hysop; print hysop' +${PYTHON_EXECUTABLE} -c 'import hysop; print(hysop)' echo "module import successful !" echo echo "Default testing OpenCL platform is:" -${PYTHON_EXECUTABLE} -c 'import hysop; from hysop.testsenv import iter_clenv; print next(iter(iter_clenv()));' +${PYTHON_EXECUTABLE} -c 'import hysop; from hysop.testsenv import iter_clenv; print(next(iter(iter_clenv())));' RUN_TESTS=${RUN_TESTS:-true} RUN_EXAMPLES=${RUN_EXAMPLES:-true} diff --git a/docs/config/mainpage.doxygen b/docs/config/mainpage.doxygen index e1f084f09e143121e91bbee813b7da227c3a4692..419d0ad3c934137e43d905b0024da12969164477 100644 --- a/docs/config/mainpage.doxygen +++ b/docs/config/mainpage.doxygen @@ -132,14 +132,14 @@ If you are using a Python distribution from the <a href="http://brew.sh/">Homebr \code cmake -DPREFIX=$(brew --prefix) $SOURCEDIR \endcode -and it will install package to '$(brew --prefix)/lib/pythonX.Y/site-packages', for example '/usr/local/lib/python2.7/site-packages' +and it will install package to '$(brew --prefix)/lib/pythonX.Y/site-packages', for example '/usr/local/lib/python3.8/site-packages' A posible issue is that Python libraries and headers are not correctly discovered by CMake. We invite the user to carefully check that Python stuff in the cmake summary are correct and set the two variables : PYTHON_LIBRARY and PYTHON_INCLUDE_DIR. For example: \code -cmake -DPYTHON_LIBRARY=$(brew --prefix)/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/Python \ - -DPYTHON_INCLUDE_DIR=$(brew --prefix)/Cellar/python/2.7.5/Frameworks/Python.framework/Headers \ +cmake -DPYTHON_LIBRARY=$(brew --prefix)/Cellar/python/3.8.5/Frameworks/Python.framework/Versions/3.8/Python \ + -DPYTHON_INCLUDE_DIR=$(brew --prefix)/Cellar/python/3.8.5/Frameworks/Python.framework/Headers \ $SOURCEDIR \endcode diff --git a/hysop/backend/device/codegen/base/variables.py b/hysop/backend/device/codegen/base/variables.py index 0beac4671a5b941dff3410268a1d37ed4f60e643..d93169010460cd19df111e9e9a8fc2e32d269066 100644 --- a/hysop/backend/device/codegen/base/variables.py +++ b/hysop/backend/device/codegen/base/variables.py @@ -855,7 +855,7 @@ class CodegenVectorClBuiltin(CodegenVector): if key<0: key += dim if key<0 or key>=dim: - raise IndexError, "The index {} is out of range.".format(key) + raise IndexError("The index {} is out of range.".format(key)) return self.sval(key) else: msg='Invalid key type {}!'.format(type(key)) @@ -952,8 +952,8 @@ class CodegenStruct(CodegenVariable): self.vars = VarDict() - struct_vars = re.compile('\s+((?:struct\s+)?\w+)\s+((?:\s*\**(?:\w+)(?:\[\d+\])*[,;])+)') - var_decl = re.compile('(\**)(\w+)((?:\[\d+\])*)') + struct_vars = re.compile(r'\s+((?:struct\s+)?\w+)\s+((?:\s*\**(?:\w+)(?:\[\d+\])*[,;])+)') + var_decl = re.compile(r'(\**)(\w+)((?:\[\d+\])*)') lines = struct.c_decl().split('\n') svalue = [] diff --git a/hysop/backend/device/opencl/opencl_fft.py b/hysop/backend/device/opencl/opencl_fft.py index 552fdadf59577013cbf31747931a589c371368f5..f75018bfec126d1195d0863869bf2d7b0cbd0a4a 100644 --- a/hysop/backend/device/opencl/opencl_fft.py +++ b/hysop/backend/device/opencl/opencl_fft.py @@ -181,7 +181,7 @@ class OpenClFFT(FFT): return self def enqueue(self, queue=None, wait_for_events=None, direction_forward=True): - """ + r""" Enqueue transform with array base_data. /!\ Do not forget to offset input and output by array.offset within custom user callbacks, only base_data is passed diff --git a/hysop/backend/device/opencl/opencl_types.py b/hysop/backend/device/opencl/opencl_types.py index b2575fa944acee9763e7ad6788a09ebf55fe463e..276852313bb235e661862e871cab04ad0611cd25 100644 --- a/hysop/backend/device/opencl/opencl_types.py +++ b/hysop/backend/device/opencl/opencl_types.py @@ -1,6 +1,6 @@ from hysop import __KERNEL_DEBUG__, vprint, dprint from hysop.deps import sm, np, it, string, re -from hysop.backend.device.opencl import cl, clArray +from hysop.backend.device.opencl import cl, clArray, clTypes from hysop.tools.numerics import MPZ, MPQ, MPFR, F2Q from hysop.tools.types import first_not_None, to_tuple @@ -131,7 +131,7 @@ def float_to_dec_str(f,fbtype): #pyopencl specific -vec = clArray.vec +vec = clTypes def npmake(dtype): return lambda scalar: dtype(scalar) #np.array([scalar], dtype=dtype) @@ -439,7 +439,7 @@ class OpenClTypeGen(TypeGen): def opencl_version(self): assert (self.device is not None) sversion = self.device.version.strip() - _regexp='OpenCL\s+(\d)\.(\d)' + _regexp=r'OpenCL\s+(\d)\.(\d)' regexp=re.compile(_regexp) match=re.match(regexp,sversion) if not match: diff --git a/hysop/core/graph/computational_graph.py b/hysop/core/graph/computational_graph.py index 156d922841f637ab548d0f6fffee1e6d44ef4c6a..7e5ab3a9e5af2560ef678301b7eb23efdcd96a25 100644 --- a/hysop/core/graph/computational_graph.py +++ b/hysop/core/graph/computational_graph.py @@ -241,7 +241,7 @@ class ComputationalGraph(ComputationalGraphNode, metaclass=ABCMeta): maxlen = (None, 40, None, 40, None) split_sep = (None, ',', None, ',', None) newline_prefix = (None, ' ', '', ' ', None) - replace = ('', '', '-', '', '') + replace = ('', '', '-', '', '') for (domain, operators) in domains.items(): if (domain is None): @@ -300,11 +300,11 @@ class ComputationalGraph(ComputationalGraphNode, metaclass=ABCMeta): op_data = ops.setdefault(None, []) op_data += multiline_split(strdata, maxlen, split_sep, replace, newline_prefix) - name_size = max(strlen(s[0]) for ss in ops.values() for s in ss) - in_size = max(strlen(s[1]) for ss in ops.values() for s in ss) + name_size = max(strlen(s[0]) for ss in ops.values() for s in ss) + in_size = max(strlen(s[1]) for ss in ops.values() for s in ss) arrow_size = max(strlen(s[2]) for ss in ops.values() for s in ss) - out_size = max(strlen(s[3]) for ss in ops.values() for s in ss) - type_size = max(strlen(s[4]) for ss in ops.values() for s in ss) + out_size = max(strlen(s[3]) for ss in ops.values() for s in ss) + type_size = max(strlen(s[4]) for ss in ops.values() for s in ss) ss = '' for (domain, dops) in ops.items(): @@ -336,8 +336,7 @@ class ComputationalGraph(ComputationalGraphNode, metaclass=ABCMeta): arrow_size=arrow_size, out_size=out_size, type_size=type_size) - title = 'ComputationalGraph {} domain and operator report '.format( - self.pretty_name + title = 'ComputationalGraph {} domain and operator report '.format(self.pretty_name) return '\n{}\n'.format(framed_str(title=title, msg=ss[1:])) def topology_report(self): @@ -346,8 +345,7 @@ class ComputationalGraph(ComputationalGraphNode, metaclass=ABCMeta): ss += '\n {}:'.format(backend.short_description()) ss += '\n *'+'\n *'.join(t.short_description() for t in sorted(topologies, key=lambda x: x.id)) - title = 'ComputationalGraph {} topology report '.format( - self.pretty_name + title = 'ComputationalGraph {} topology report '.format(self.pretty_name) return '\n{}\n'.format(framed_str(title=title, msg=ss[1:])) def variable_report(self): @@ -849,7 +847,7 @@ class ComputationalGraph(ComputationalGraphNode, metaclass=ABCMeta): ss = (srequests if (srequests != '') else ' *no extra work requested*') title = 'ComputationalGraph {} work properties report '.format( self.pretty_name) - vprint('\n{}\n'.format(framed_str(title=title, msg=ss)) + vprint('\n{}\n'.format(framed_str(title=title, msg=ss))) return requests @debug diff --git a/hysop/core/tests/test_checkpoint.sh b/hysop/core/tests/test_checkpoint.sh index d6cfc4919b1901987aedf81742a1ac9bf1bfb687..e6470096597cff39e07061862d6ac5cf7a73dc03 100755 --- a/hysop/core/tests/test_checkpoint.sh +++ b/hysop/core/tests/test_checkpoint.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -feu -o pipefail -PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-python2.7} +PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-python3.8} MPIRUN_EXECUTABLE=${MPIRUN_EXECUTABLE:-mpirun --allow-run-as-root} SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" diff --git a/hysop/domain/domain.py b/hysop/domain/domain.py index 9bd77042e05dd942718c86cb2814500e6936e01e..8bbc131905d1f56b56d2c0e54bf99272beeb61e5 100644 --- a/hysop/domain/domain.py +++ b/hysop/domain/domain.py @@ -256,7 +256,7 @@ class Domain(RegisteredObject, metaclass=ABCMeta): # Build a per-machine communicator in order to get a rank on local machines # Split accoring to machine name hashed and converted to integer (strings generally differs only from a single character) machine_comm = parent_comm.Split( - color=np.int32(int(hashlib.md5(MPI.Get_processor_name()).hexdigest(), 16) % + color=np.int32(int(hashlib.md5(MPI.Get_processor_name().encode('utf-8')).hexdigest(), 16) % np.iinfo(np.int32).max), key=parent_rank) machine_rank = machine_comm.Get_rank() diff --git a/hysop/fields/tests/test_cartesian.sh b/hysop/fields/tests/test_cartesian.sh index f73967d46af4fe6601d2b2e1ffda51363cdd7d71..46bad9664dd55ab7b951acf243e9ffba39cee409 100755 --- a/hysop/fields/tests/test_cartesian.sh +++ b/hysop/fields/tests/test_cartesian.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash set -feu -o pipefail +PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-python3.8} +MPIRUN_EXECUTABLE=${MPIRUN_EXECUTABLE:-mpirun --allow-run-as-root} SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" TEST_FILE=${SCRIPT_DIR}/test_cartesian.py @@ -9,5 +11,5 @@ export HYSOP_DEBUG=0 export KERNEL_DEBUG=0 for i in 2; do - mpirun -np $i --allow-run-as-root python2.7 ${TEST_FILE} + ${MPIRUN_EXECUTABLE} -np $i ${PYTHON_EXECUTABLE} ${TEST_FILE} done diff --git a/hysop/numerics/interpolation/polynomial.py b/hysop/numerics/interpolation/polynomial.py index 918b77023fb6fe1c04dc48dd9d56b69e21fbc9f7..603ee580099ec6c98be0b4be23f8b4d69a806cea 100644 --- a/hysop/numerics/interpolation/polynomial.py +++ b/hysop/numerics/interpolation/polynomial.py @@ -273,7 +273,7 @@ class PolynomialInterpolator(object): Si = Si.coeffs Sd.append(Si) if verbose: - print ' {}-th derivative: {}'.format(i,Si) + print(' {}-th derivative: {}'.format(i,Si)) return S def _build_stencil(self, dvec): @@ -798,7 +798,7 @@ if __name__ == '__main__': print(GI5(F)) print() - 3D test + # 3D test grid_ratio = (2,2,2) print('Solving trilinear...') PI = PolynomialInterpolator(dim=3, deg=1, fd=2, verbose=False) diff --git a/hysop/operator/convergence.py b/hysop/operator/convergence.py index 3abcd47e3b029717970dadf51fec6cb65f9bf942..935464300f12a8e551a89f057f32a5eb312db942 100644 --- a/hysop/operator/convergence.py +++ b/hysop/operator/convergence.py @@ -35,7 +35,7 @@ class Convergence(ComputationalGraphNodeFrontend): @debug def __init__(self, variables, error=None, convergence=None, implementation=None, **kwds): - """Initialize a convergence operator. + r"""Initialize a convergence operator. Computes ||u-u_old||_\infty or ||u-u_old||_\infty/||u||_\infty depending on method absolute or relative. diff --git a/hysop/operator/derivative.py b/hysop/operator/derivative.py index cc475284f2010284ffba413ad2160b1ef485de67..35e03a2bd19d3d65760bde506b663eb1e2b6c0e5 100644 --- a/hysop/operator/derivative.py +++ b/hysop/operator/derivative.py @@ -148,7 +148,7 @@ class SpectralSpaceDerivative(SpaceDerivative): class FiniteDifferencesSpaceDerivative(SpaceDerivative): - """ + r""" Operator frontend to compute the derivative of a component of a field in a given direction using finite differences. diff --git a/hysop/operator/penalization.py b/hysop/operator/penalization.py index 94d750e7392f588948447ad1f053fdb54d3541c4..fbfa9ca2831a86d93b897a5243cd7f62a012a856 100644 --- a/hysop/operator/penalization.py +++ b/hysop/operator/penalization.py @@ -19,7 +19,7 @@ from hysop.backend.host.python.operator.penalization import PythonPenalizeVortic class PenalizeVorticity(ComputationalGraphNodeFrontend): - """ + r""" Solve \f{eqnarray*} \frac{\partial w}{\partial t} &=& \lambda\chi_s\nabla\times(v_D - v) @@ -43,7 +43,7 @@ class PenalizeVorticity(ComputationalGraphNodeFrontend): velocity, vorticity, dt, coeff=None, ubar=None, formulation=None, implementation=None, **kwds): - """ + r""" Parameters ---------- obstacles : dict or list of :class:`~hysop.Field` diff --git a/hysop/symbolic/base.py b/hysop/symbolic/base.py index 052d9d34a294d1c864a77d38aa98941cd33d59ed..2641ddfc5af05b72c0730cb5f1f7ce35542d0dd3 100644 --- a/hysop/symbolic/base.py +++ b/hysop/symbolic/base.py @@ -170,15 +170,15 @@ class TensorBase(npw.ndarray): assert self.ndim <= 2 ss = '' if with_packages: - ss += '\usepackage{amsmath}' + ss += r'\usepackage{amsmath}' ss += '\n$$' - ss += '\n\\begin{{{}matrix}}'.format(matrix) + ss += '\n'+r'\begin{{{}matrix}}'.format(matrix) for i in range(self.shape[0]): if self.ndim==1: ss += '\n ' + _latex(self[i]) + ' \\\\' else: ss += '\n ' + ' & '.join(_latex(val) for val in self[i]) + ' \\\\' - ss += '\n\\end{{{}matrix}}'.format(matrix) + ss += '\n'+r'\end{{{}matrix}}'.format(matrix) ss += '\n$$' return ss diff --git a/hysop/tools/handle.py b/hysop/tools/handle.py index c560df833876e2bb2117f2cc717c5ba241a8d462..052cc93da8b76813a2ba3b5028809c9771fa9c5c 100644 --- a/hysop/tools/handle.py +++ b/hysop/tools/handle.py @@ -124,7 +124,7 @@ class TaggedObject(object, metaclass=ABCMeta): assert (tag_postfix is None) or isinstance(tag_postfix, str) assert (tag_formatter is None) or callable(tag_formatter) - super(TaggedObject, self).__init__(**kwds) + super(TaggedObject, self).__init__() # reaffect attributes (some classes use only __init__ for simplicity) self.__tag_prefix = first_not_None(self.__tag_prefix, tag_prefix, '') @@ -242,7 +242,7 @@ class RegisteredObject(TaggedObject): msg = 'Keyword argument {} is a np.ndarray but it has not been set to readonly.' msg=msg.format(key) raise RuntimeError(msg) - return arg.data + return arg.tobytes() elif isinstance(arg, (MPI.Intracomm, MPI.Intercomm)): return id(arg) else: @@ -322,16 +322,14 @@ class RegisteredObject(TaggedObject): obj = super(RegisteredObject,cls).__new__(cls, tag_prefix=tag_prefix, tag_postfix=tag_postfix, - tag_formatter=tag_formatter, - **kwds) + tag_formatter=tag_formatter) obj.__initialized = False registered_objects[key] = obj else: obj = super(RegisteredObject,cls).__new__(cls, tag_prefix=tag_prefix, tag_postfix=tag_postfix, - tag_formatter=tag_formatter, - **kwds) + tag_formatter=tag_formatter) obj.__initialized = False return obj diff --git a/hysop/tools/numpywrappers.py b/hysop/tools/numpywrappers.py index 7ef697a086c299701e95009c62618d2d6b372a73..c3c884f4f73f99ad1734173b658964aa99036ffe 100644 --- a/hysop/tools/numpywrappers.py +++ b/hysop/tools/numpywrappers.py @@ -21,7 +21,7 @@ def hysop_array_generated_method(a, order=HYSOP_ORDER, **kargs): Convert the input to an array of dtype HYSOP_{TYPE}. """ dtype = HYSOP_{TYPE} - return npw.asarray(a=a, dtype=dtype, order=order, **kargs) + return np.asarray(a=a, dtype=dtype, order=order, **kargs) ''', 'asany{type}array': ''' @@ -30,7 +30,7 @@ def hysop_array_generated_method(a, order=HYSOP_ORDER, **kargs): Convert the input to an array of dtype HYSOP_{TYPE}. """ dtype = HYSOP_{TYPE} - return npw.asanyarray(a=a, dtype=dtype, order=order, **kargs) + return np.asanyarray(a=a, dtype=dtype, order=order, **kargs) ''', '{type}_prod': ''' @@ -39,7 +39,7 @@ def hysop_array_generated_method(a, axis=None, out=None, **kargs): Sum of array elements over a given axis. """ dtype = HYSOP_{TYPE} - return npw.prod(a=a,axis=axis,out=out,dtype=dtype,**kargs) + return np.prod(a=a,axis=axis,out=out,dtype=dtype,**kargs) ''', '{type}_sum': ''' @@ -48,7 +48,7 @@ def hysop_array_generated_method(a, axis=None, out=None, **kargs): Sum of array elements over a given axis. """ dtype = HYSOP_{TYPE} - return npw.sum(a=a,axis=axis,out=out,dtype=dtype,**kargs) + return np.sum(a=a,axis=axis,out=out,dtype=dtype,**kargs) ''', '{type}_empty': @@ -58,7 +58,7 @@ def hysop_array_generated_method(shape, order=HYSOP_ORDER, **kargs): Return a new array of given shape and type, without initializing entries. """ dtype = HYSOP_{TYPE} - return npw.empty(shape=shape, dtype=dtype, order=order, **kargs) + return np.empty(shape=shape, dtype=dtype, order=order, **kargs) ''', '{type}_ones': @@ -68,7 +68,7 @@ def hysop_array_generated_method(shape, order=HYSOP_ORDER, **kargs): Return a new array of given shape filled with ones of type HYSOP_{TYPE}. """ dtype = HYSOP_{TYPE} - return npw.ones(shape=shape, order=order, dtype=dtype, **kargs) + return np.ones(shape=shape, order=order, dtype=dtype, **kargs) ''', '{type}_zeros': @@ -78,7 +78,7 @@ def hysop_array_generated_method(shape, order=HYSOP_ORDER, **kargs): Return a new array of given shape, filled with zeros of type HYSOP_{TYPE}. """ dtype = HYSOP_{TYPE} - return npw.zeros(shape=shape, order=order, dtype=dtype, **kargs) + return np.zeros(shape=shape, order=order, dtype=dtype, **kargs) ''', '{type}_full': @@ -88,7 +88,7 @@ def hysop_array_generated_method(shape, fill_value, order=HYSOP_ORDER, **kargs): Return a new array of given shape, filled with fill_value of type HYSOP_{TYPE}. """ dtype = HYSOP_{TYPE} - return npw.full(shape=shape, fill_value=fill_value, order=order, dtype=dtype, **kargs) + return np.full(shape=shape, fill_value=fill_value, order=order, dtype=dtype, **kargs) ''' } @@ -99,6 +99,7 @@ def hysop_array_generated_method(shape, fill_value, order=HYSOP_ORDER, **kargs): fname = _fname.format(type=ht, TYPE=ht.upper()) fdef = \ ''' +import numpy as np from hysop.constants import HYSOP_REAL, HYSOP_COMPLEX, HYSOP_ORDER from hysop.constants import HYSOP_INTEGER, HYSOP_INDEX, HYSOP_DIM, HYSOP_BOOL {} diff --git a/hysop/topology/cartesian_topology.py b/hysop/topology/cartesian_topology.py index c3105ef62fb3d0cf079b26f42bd372f128cbec86..85feb8cfa5079bd61859395f8bf750734de85b8e 100644 --- a/hysop/topology/cartesian_topology.py +++ b/hysop/topology/cartesian_topology.py @@ -325,7 +325,7 @@ class CartesianTopologyView(TopologyView): """ return self._proc_transposed(self._topology._is_distributed) def _get_is_periodic(self): - """ + r""" MPI communicator grid periodicity. is_periodic[dir] = True means that the MPI grid is periodic along dir. /!\ This is not equivalent to domain periodicity, as a periodic @@ -462,7 +462,7 @@ class CartesianTopology(CartesianTopologyView, Topology): is_periodic=None, cutdirs=None, mesh=None, cartesian_topology=None, cl_env=None, **kwds): - """ + r""" Initializes or get an existing CartesianTopology topology. Parameters diff --git a/hysop/topology/topology.py b/hysop/topology/topology.py index 9c972ea714ee5917d89a5293671aa0abc04e879f..faeb44dd28adee10a16be98a8aa3924ab59ff3d8 100644 --- a/hysop/topology/topology.py +++ b/hysop/topology/topology.py @@ -42,7 +42,11 @@ class TopologyState(TaggedObject, metaclass=ABCMeta): __slots__ = ('_is_read_only',) @debug - def __init__(self, is_read_only, **kwds): + def __new__(cls, is_read_only, **kwds): + return super(TopologyState, cls).__new__(cls, tag_prefix='ts', **kwds) + + @debug + def __init__(self, is_read_only, **kwds): """Initialize a topology state.""" check_instance(is_read_only, bool) super(TopologyState,self).__init__(tag_prefix='ts', **kwds) @@ -104,7 +108,7 @@ class TopologyView(TaggedObjectView, metaclass=ABCMeta): @debug def __new__(cls, topology_state, topology=None, **kwds): - """ + r""" Create and initialize a TopologyView on given topology. Parameters @@ -179,7 +183,7 @@ class TopologyView(TaggedObjectView, metaclass=ABCMeta): """ArrayBackend of this topology.""" return self._topology._backend def _get_mpi_params(self): - """The parent MPI parameters of this topology. + r"""The parent MPI parameters of this topology. /!\ Topologies may define a sub communicator CartesianTopology topologies will define a MPI.Cartcomm for example. """