Skip to content

Commit 9dbc91a

Browse files
committed
changed handling of exceptions for logical errors
1 parent f83d78c commit 9dbc91a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

pvlib/pvl_tools.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ def parse_fcn(self, kwargs, Expect):
166166

167167
#Excecute proper logical operations if syntax matches regex
168168
elif np.shape(re.findall(reg,string))[0]>0:
169-
169+
eflag=False
170+
170171
lambdastring='lambda x:'+re.findall(reg,string)[0]
171172

172173
#check df elements
@@ -182,21 +183,28 @@ def parse_fcn(self, kwargs, Expect):
182183
continue
183184
try:
184185
if not(eval(lambdastring)(kwargs[arg][~np.isnan(kwargs[arg])]).all()): #ignore NAN entries
185-
raise Exception('Error: optional input "'+arg+' " fails on logical test " '+ re.findall(reg,string)[0]+'"')
186+
eflag=True
187+
186188
except:
187189
if not(eval(lambdastring)(kwargs[arg])):
188-
raise Exception('Error: optional input "'+arg+' " fails on logical test " '+ re.findall(reg,string)[0]+'"')
190+
eflag=True
191+
189192

190193

191194
#check all other contraints
192-
195+
193196
else:
194197
try:
195198
if not(eval(lambdastring)(kwargs[arg][~np.isnan(kwargs[arg])]).all()): #ignore NAN entries
196-
raise Exception('Error: Numeric input "'+arg+' " fails on logical test " '+ re.findall(reg,string)[0]+'"')
199+
eflag=True
200+
197201
except:
198202
if not(eval(lambdastring)(kwargs[arg])):
199-
raise Exception('Error: Numeric input "'+arg+' " fails on logical test " '+ re.findall(reg,string)[0]+'"')
203+
eflag=True
204+
205+
206+
if eflag==True:
207+
raise Exception('Error: Numeric input "'+arg+' " fails on logical test " '+ re.findall(reg,string)[0]+'"')
200208

201209
#Check if any string logicals are bypassed due to poor formatting
202210

0 commit comments

Comments
 (0)