From ef66aadae8ceb55f9872ab05b57800a4f6120be5 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Keck <Jean-Baptiste.Keck@imag.fr> Date: Fri, 30 Oct 2020 17:54:03 +0100 Subject: [PATCH] fix python version in test scripts --- ci/scripts/build_and_test.sh | 2 +- ci/scripts/config.sh | 2 +- ci/scripts/install.sh | 10 +++++----- ci/scripts/test.sh | 8 ++++---- docs/config/mainpage.doxygen | 6 +++--- hysop/backend/device/codegen/base/variables.py | 6 +++--- hysop/backend/device/opencl/opencl_fft.py | 2 +- hysop/backend/device/opencl/opencl_types.py | 6 +++--- hysop/core/graph/computational_graph.py | 18 ++++++++---------- hysop/core/tests/test_checkpoint.sh | 2 +- hysop/domain/domain.py | 2 +- hysop/fields/tests/test_cartesian.sh | 4 +++- hysop/numerics/interpolation/polynomial.py | 4 ++-- hysop/operator/convergence.py | 2 +- hysop/operator/derivative.py | 2 +- hysop/operator/penalization.py | 4 ++-- hysop/symbolic/base.py | 6 +++--- hysop/tools/handle.py | 10 ++++------ hysop/tools/numpywrappers.py | 17 +++++++++-------- hysop/topology/cartesian_topology.py | 4 ++-- hysop/topology/topology.py | 10 +++++++--- 21 files changed, 65 insertions(+), 62 deletions(-) diff --git a/ci/scripts/build_and_test.sh b/ci/scripts/build_and_test.sh index 9465a2dd6..9fcbd1505 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 ac2158623..9654bf957 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 82f3f6456..6fe6b4b9b 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 706a8f1e1..40569b881 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 e1f084f09..419d0ad3c 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 0beac4671..d93169010 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 552fdadf5..f75018bfe 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 b2575fa94..276852313 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 156d92284..7e5ab3a9e 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 d6cfc4919..e64700965 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 9bd77042e..8bbc13190 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 f73967d46..46bad9664 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 918b77023..603ee5800 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 3abcd47e3..935464300 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 cc475284f..35e03a2bd 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 94d750e73..fbfa9ca28 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 052d9d34a..2641ddfc5 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 c560df833..052cc93da 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 7ef697a08..c3c884f4f 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 c3105ef62..85feb8cfa 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 9c972ea71..faeb44dd2 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. """ -- GitLab