@@ -258,13 +258,9 @@ def check_bipole(inp, name):
258
258
259
259
def chck_dipole (inp , name ):
260
260
r"""Check inp for shape and type."""
261
- # Check x
261
+ # Check x, y, and z
262
262
inp_x = _check_var (inp [0 ], float , 1 , name + '-x' )
263
-
264
- # Check y and ensure it has same dimension as x
265
263
inp_y = _check_var (inp [1 ], float , 1 , name + '-y' )
266
-
267
- # Check z
268
264
inp_z = _check_var (inp [2 ], float , 1 , name + '-z' )
269
265
270
266
# Expand x or y coordinate if necessary.
@@ -275,9 +271,11 @@ def chck_dipole(inp, name):
275
271
inp_y = np .repeat (inp_y , inp_x .size )
276
272
else :
277
273
raise ValueError (
278
- f"Parameter { name } -x and { name } -y must have same shape or "
279
- f"(1,); provided: { inp_x .shape } ; { inp_y .shape } ."
274
+ f"Parameters { name } -x and { name } -y must be of same size "
275
+ "or be a single value; provided: "
276
+ f"{ inp_x .shape } ; { inp_y .shape } ."
280
277
)
278
+
281
279
# If x/y=1, but z not => expand
282
280
if inp_z .size > 1 and inp_x .size == 1 :
283
281
inp_x = np .repeat (inp_x , inp_z .size )
@@ -310,21 +308,19 @@ def chck_dipole(inp, name):
310
308
inp_a = _check_var (inp [3 ], float , 1 , 'azimuth' )
311
309
inp_d = _check_var (inp [4 ], float , 1 , 'dip' )
312
310
313
- # Expand x/y coordinate or azm if necessary.
314
- if inp_a .size != 1 and out [0 ].shape != inp_a .shape :
315
- if out [0 ].size == 1 :
316
- out [0 ] = np .repeat (out [0 ], inp_a .size )
317
- out [1 ] = np .repeat (out [1 ], inp_a .size )
318
- else :
319
- raise ValueError ("TODO" )
320
-
321
- # Expand x/y coordinate or azm if necessary.
322
- if inp_d .size != 1 and out [0 ].shape != inp_d .shape :
323
- if out [0 ].size == 1 :
324
- out [0 ] = np .repeat (out [0 ], inp_d .size )
325
- out [1 ] = np .repeat (out [1 ], inp_d .size )
326
- else :
327
- raise ValueError ("TODO" )
311
+ # Expand x/y coordinate or azm/dip if necessary.
312
+ # THINK ABOUT IT!
313
+ for inp_ad , ad_name in ([inp_a , 'azimuth' ], [inp_d , 'dip' ]):
314
+ if inp_ad .size != 1 and out [0 ].shape != inp_ad .shape :
315
+ if out [0 ].size == 1 :
316
+ out [0 ] = np .repeat (out [0 ], inp_ad .size )
317
+ out [1 ] = np .repeat (out [1 ], inp_ad .size )
318
+ else :
319
+ raise ValueError (
320
+ f"Parameter { name } -x and { name } -y must be of same size "
321
+ "or be a single value; provided: "
322
+ f"{ inp_x .shape } ; { inp_y .shape } ."
323
+ )
328
324
329
325
# How many different depths
330
326
nz = out [2 ].size
0 commit comments