Skip to content

Commit e2922fc

Browse files
committed
WIP
1 parent d2194ce commit e2922fc

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

empymod/utils.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,9 @@ def check_bipole(inp, name):
258258

259259
def chck_dipole(inp, name):
260260
r"""Check inp for shape and type."""
261-
# Check x
261+
# Check x, y, and z
262262
inp_x = _check_var(inp[0], float, 1, name+'-x')
263-
264-
# Check y and ensure it has same dimension as x
265263
inp_y = _check_var(inp[1], float, 1, name+'-y')
266-
267-
# Check z
268264
inp_z = _check_var(inp[2], float, 1, name+'-z')
269265

270266
# Expand x or y coordinate if necessary.
@@ -275,9 +271,11 @@ def chck_dipole(inp, name):
275271
inp_y = np.repeat(inp_y, inp_x.size)
276272
else:
277273
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}."
280277
)
278+
281279
# If x/y=1, but z not => expand
282280
if inp_z.size > 1 and inp_x.size == 1:
283281
inp_x = np.repeat(inp_x, inp_z.size)
@@ -310,21 +308,19 @@ def chck_dipole(inp, name):
310308
inp_a = _check_var(inp[3], float, 1, 'azimuth')
311309
inp_d = _check_var(inp[4], float, 1, 'dip')
312310

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+
)
328324

329325
# How many different depths
330326
nz = out[2].size

0 commit comments

Comments
 (0)