From 07858839e13047365a5eae01823519bad654ada5 Mon Sep 17 00:00:00 2001 From: Stephan Rave Date: Fri, 14 Oct 2016 21:10:11 +0200 Subject: [PATCH] [vectorarrays] remove some unneeded copy() calls --- src/pymor/algorithms/genericsolvers.py | 6 +++--- src/pymor/algorithms/image.py | 2 +- src/pymor/operators/basic.py | 2 +- src/pymor/operators/numpy.py | 2 +- src/pymor/parallel/basic.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pymor/algorithms/genericsolvers.py b/src/pymor/algorithms/genericsolvers.py index 43063ce020..a9a83eaa86 100644 --- a/src/pymor/algorithms/genericsolvers.py +++ b/src/pymor/algorithms/genericsolvers.py @@ -170,7 +170,7 @@ def apply_inverse(op, rhs, options=None): if options['type'] == 'generic_lgmres': for i in range(len(rhs)): - r, info = lgmres(op, rhs[i].copy(), + r, info = lgmres(op, rhs[i], tol=options['tol'], maxiter=options['maxiter'], inner_m=options['inner_m'], @@ -181,7 +181,7 @@ def apply_inverse(op, rhs, options=None): R.append(r) elif options['type'] == 'least_squares_generic_lsmr': for i in range(len(rhs)): - r, info, itn, _, _, _, _, _ = lsmr(op, rhs[i].copy(), + r, info, itn, _, _, _, _, _ = lsmr(op, rhs[i], damp=options['damp'], atol=options['atol'], btol=options['btol'], @@ -195,7 +195,7 @@ def apply_inverse(op, rhs, options=None): R.append(r) elif options['type'] == 'least_squares_generic_lsqr': for i in range(len(rhs)): - r, info, itn, _, _, _, _, _, _ = lsqr(op, rhs[i].copy(), + r, info, itn, _, _, _, _, _, _ = lsqr(op, rhs[i], damp=options['damp'], atol=options['atol'], btol=options['btol'], diff --git a/src/pymor/algorithms/image.py b/src/pymor/algorithms/image.py index ab4e4b2c80..b574b3ec10 100644 --- a/src/pymor/algorithms/image.py +++ b/src/pymor/algorithms/image.py @@ -221,7 +221,7 @@ def estimate_image_hierarchical(operators=(), vectors=(), domain=None, extends=N orthonormalize=False, product=product, riesz_representatives=riesz_representatives) else: - new_image = estimate_image(operators, [], domain[i].copy(), extends=True, + new_image = estimate_image(operators, [], domain[i], extends=True, orthonormalize=False, product=product, riesz_representatives=riesz_representatives) diff --git a/src/pymor/operators/basic.py b/src/pymor/operators/basic.py index 4026dec45d..e74d444b58 100644 --- a/src/pymor/operators/basic.py +++ b/src/pymor/operators/basic.py @@ -101,7 +101,7 @@ def apply_inverse(self, V, mu=None, least_squares=False): self.logger.warn('Least squares solver selected but "least_squares == False"') try: - return genericsolvers.apply_inverse(assembled_op, V.copy(), options=options) + return genericsolvers.apply_inverse(assembled_op, V, options=options) except InversionError as e: if least_squares and options: solver_type = options if isinstance(options, str) else options['type'] diff --git a/src/pymor/operators/numpy.py b/src/pymor/operators/numpy.py index c0dca03c25..9b7878daf0 100644 --- a/src/pymor/operators/numpy.py +++ b/src/pymor/operators/numpy.py @@ -272,7 +272,7 @@ def projected_to_subbasis(self, dim_range=None, dim_source=None, name=None): should be the same as :: - op.projected(r_basis[:dim_range].copy(), s_basis[:dim_source].copy(), prod) + op.projected(r_basis[:dim_range], s_basis[:dim_source], prod) For a |NumpyMatrixOperator| this amounts to extracting the upper-left (dim_range, dim_source) corner of the matrix it wraps. diff --git a/src/pymor/parallel/basic.py b/src/pymor/parallel/basic.py index c5095cd8da..700a7d9612 100644 --- a/src/pymor/parallel/basic.py +++ b/src/pymor/parallel/basic.py @@ -21,7 +21,7 @@ def scatter_array(self, U, copy=True): else: slices = [U.empty() for _ in range(len(self))] for s in slices: - s.append(U[:min(slice_len, len(U))].copy(), remove_from_other=True) + s.append(U[:min(slice_len, len(U))], remove_from_other=True) remote_U = self.push(U.empty()) del U self.map(_append_array_slice, slices, U=remote_U)