From 23b0ed817284add42a2d8db2fc2e9894e28fff5c Mon Sep 17 00:00:00 2001 From: Martin Reinecke Date: Fri, 18 May 2018 15:39:05 +0200 Subject: [PATCH] bug fix --- nifty4/operators/chain_operator.py | 4 +++- nifty4/operators/sum_operator.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/nifty4/operators/chain_operator.py b/nifty4/operators/chain_operator.py index 965dbb15..15d71ea0 100644 --- a/nifty4/operators/chain_operator.py +++ b/nifty4/operators/chain_operator.py @@ -64,7 +64,7 @@ class ChainOperator(LinearOperator): opsnew[i] = opsnew[i]._scale(fct) fct = 1. break - if fct != 1: + if fct != 1 or len(opsnew) == 0: # have to add the scaling operator at the end opsnew.append(ScalingOperator(fct, lastdom)) ops = opsnew @@ -83,6 +83,8 @@ class ChainOperator(LinearOperator): @staticmethod def make(ops): ops = tuple(ops) + if len(ops) == 0: + raise ValueError("ops is empty") ops = ChainOperator.simplify(ops) if len(ops) == 1: return ops[0] diff --git a/nifty4/operators/sum_operator.py b/nifty4/operators/sum_operator.py index 2680bc43..6755e529 100644 --- a/nifty4/operators/sum_operator.py +++ b/nifty4/operators/sum_operator.py @@ -108,6 +108,8 @@ class SumOperator(LinearOperator): def make(ops, neg): ops = tuple(ops) neg = tuple(neg) + if len(ops) == 0: + raise ValueError("ops is empty") if len(ops) != len(neg): raise ValueError("length mismatch between ops and neg") ops, neg = SumOperator.simplify(ops, neg) -- GitLab