MCPcopy Create free account
hub / github.com/NanoComp/meep / fix_dft_args

Function fix_dft_args

python/simulation.py:72–93  ·  view source on GitHub ↗
(args, i)

Source from the content-addressed store, hash-verified

70
71
72def fix_dft_args(args, i):
73 if (
74 len(args) > i + 2
75 and isinstance(args[i], (int, float))
76 and isinstance(args[i + 1], (int, float))
77 and isinstance(args[i + 2], int)
78 ):
79 fcen = args[i]
80 df = args[i + 1]
81 nfreq = args[i + 2]
82 freq = (
83 [fcen]
84 if nfreq == 1
85 else np.linspace(fcen - 0.5 * df, fcen + 0.5 * df, nfreq)
86 )
87 return args[:i] + (freq,) + args[i + 3 :]
88 elif not isinstance(args[i], (np.ndarray, list)):
89 raise TypeError(
90 "add_dft functions only accept fcen,df,nfreq (3 numbers) or freq (array/list)"
91 )
92 else:
93 return args
94
95
96def get_num_args(func):

Callers 8

add_dft_fieldsMethod · 0.85
add_near2farMethod · 0.85
add_energyMethod · 0.85
add_forceMethod · 0.85
add_fluxMethod · 0.85
add_mode_monitorMethod · 0.85
LdosFunction · 0.85
dft_ldosFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected