few operators improvements

This commit is contained in:
2024-03-14 16:35:13 +01:00
parent 95f0d2fc34
commit 22dcb9d15c
3 changed files with 7 additions and 6 deletions

View File

@@ -45,12 +45,8 @@ MANDATORY_PARAMETERS = {
"length",
"adapt_step_size",
"tolerated_error",
"repeat",
"linear_operator",
"nonlinear_operator",
"soliton_length",
"nonlinear_length",
"dispersion_length",
}
ROOT_PARAMETERS = [

View File

@@ -569,7 +569,11 @@ envelope_rules = default_rules + [
Rule("gamma_op", operators.constant_quantity, ["gamma_arr"], priorities=1),
Rule("gamma_op", lambda w_num, gamma: operators.constant_quantity(np.ones(w_num) * gamma)),
Rule("gamma_op", lambda: operators.constant_quantity(0.0), priorities=-1),
Rule("ss_op", lambda w_c, w0: operators.constant_quantity(w_c / w0)),
Rule(
"ss_op",
lambda w_c, w0: operators.constant_quantity(w_c / w0),
conditions=dict(self_steepening=True),
),
Rule("ss_op", lambda: operators.constant_quantity(0), priorities=-1),
Rule("spm_op", operators.envelope_spm, conditions=dict(spm=True)),
Rule("spm_op", operators.no_op_freq, priorities=-1),
@@ -579,6 +583,7 @@ envelope_rules = default_rules + [
Rule("dispersion_op", operators.constant_polynomial_dispersion),
Rule("dispersion_op", operators.constant_direct_dispersion),
Rule("dispersion_op", operators.direct_dispersion),
Rule("dispersion_op", lambda: operators.constant_quantity(0.0), priorities=-1),
Rule("linear_operator", operators.envelope_linear_operator),
Rule("conserved_quantity", operators.conserved_quantity),
]

View File

@@ -232,7 +232,7 @@ class NoiseMeasurement:
sample on a log-log scale rather than on a linear scale, by default False
"""
nf = nf or len(self.freq)
if rng is None or isinstance(rng, int):
if rng is None or isinstance(rng, (int, np.integer)):
rng = np.random.default_rng(rng)
freq, amp = self.sample_spectrum(nf, dt, log_mode, left=0)