ml4gw 0.7.5__py3-none-any.whl → 0.7.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ml4gw might be problematic. Click here for more details.

@@ -25,17 +25,17 @@ class Whiten(torch.nn.Module):
25
25
  In order to avoid edge effects due to filter settle-in,
26
26
  the provided PSDs will have their spectrum truncated
27
27
  such that their impulse response time in the time
28
- domain is `fduration` seconds, and `fduration / 2`
28
+ domain is ``fduration`` seconds, and ``fduration / 2``
29
29
  seconds worth of data will be removed from each
30
30
  edge of the whitened timeseries.
31
31
 
32
- For more information, see the documentation to
33
- `ml4gw.spectral.whiten`.
32
+ For more information, see the documentation for
33
+ :meth:`~ml4gw.spectral.whiten`.
34
34
 
35
35
  Args:
36
36
  fduration:
37
37
  The length of the whitening filter's impulse
38
- response, in seconds. `fduration / 2` seconds
38
+ response, in seconds. ``fduration / 2`` seconds
39
39
  worth of data will be cropped from the edges
40
40
  of the whitened timeseries.
41
41
  sample_rate:
@@ -43,11 +43,11 @@ class Whiten(torch.nn.Module):
43
43
  time is expected to be sampled
44
44
  highpass:
45
45
  Cutoff frequency to apply highpass filtering
46
- during whitening. If left as `None`, no highpass
46
+ during whitening. If left as ``None``, no highpass
47
47
  filtering will be performed.
48
48
  lowpass:
49
49
  Cutoff frequency to apply lowpass filtering
50
- during whitening. If left as `None`, no lowpass
50
+ during whitening. If left as ``None``, no lowpass
51
51
  filtering will be performed.
52
52
  """
53
53
 
@@ -80,28 +80,28 @@ class Whiten(torch.nn.Module):
80
80
  Args:
81
81
  X:
82
82
  Batch of multichannel timeseries to whiten.
83
- Should have the shape (B, C, N), where
84
- B is the batch size, C is the number of
85
- channels, and N is the number of seconds
86
- in the timeseries times `self.sample_rate`.
83
+ Should have the shape ``(B, C, N)``, where
84
+ ``B`` is the batch size, ``C`` is the number of
85
+ channels, and ``N`` is the number of seconds
86
+ in the timeseries times ``self.sample_rate``.
87
87
  psd:
88
88
  Power spectral density used to whiten the
89
89
  provided timeseries. Can be either 1D, 2D,
90
90
  or 3D, with the last dimension representing
91
91
  power at each frequency value. All other
92
92
  dimensions must match their corresponding
93
- value in `X`, starting from the right.
94
- (e.g. if `psd.ndim == 2`, `psd.size(1)` should
95
- be equal to `X.size(1)`. If `psd.ndim == 3`,
96
- `psd.size(1)` and `psd.size(0)` should be equal
97
- to `X.size(1)` and `X.size(0)`, respectively.)
93
+ value in ``X``, starting from the right.
94
+ (e.g. if ``psd.ndim == 2``, ``psd.size(1)`` should
95
+ be equal to ``X.size(1)``. If ``psd.ndim == 3``,
96
+ ``psd.size(1)`` and ``psd.size(0)`` should be equal
97
+ to ``X.size(1)`` and ``X.size(0)``, respectively.)
98
98
  For more information about what these different
99
- shapes for `psd` represent, consult the documentation
100
- for `ml4gw.spectral.whiten`.
99
+ shapes for ``psd`` represent, consult the documentation
100
+ for :meth:`~ml4gw.spectral.whiten`.
101
101
  Returns:
102
- Whitened timeseries, with `fduration * sample_rate / 2`
102
+ Whitened timeseries, with ``fduration * sample_rate / 2``
103
103
  samples cropped from each edge. Output shape will then
104
- be (B, C, N - `fduration * sample_rate`).
104
+ be ``(B, C, N - fduration * sample_rate)``.
105
105
  """
106
106
 
107
107
  return spectral.whiten(
@@ -118,7 +118,7 @@ class FixedWhiten(FittableSpectralTransform):
118
118
  """
119
119
  Transform that whitens timeseries by a fixed
120
120
  power spectral density that's determined by
121
- calling the `.fit` method.
121
+ calling the ``.fit`` method.
122
122
 
123
123
  Args:
124
124
  num_channels:
@@ -167,7 +167,7 @@ class FixedWhiten(FittableSpectralTransform):
167
167
  Compute the PSD of channel-wise background to
168
168
  use to whiten timeseries at call time. PSDs will
169
169
  be resampled to have
170
- `self.kernel_length * self.sample_rate // 2 + 1`
170
+ ``self.kernel_length * self.sample_rate // 2 + 1``
171
171
  frequency bins.
172
172
 
173
173
  Args:
@@ -176,29 +176,29 @@ class FixedWhiten(FittableSpectralTransform):
176
176
  of the whitening filter, in seconds.
177
177
  Fit PSDs will have their spectrum truncated
178
178
  to approximate this response time.
179
- A longer `fduration` will be able to
179
+ A longer ``fduration`` will be able to
180
180
  handle narrower spikes in frequency, but
181
181
  at the expense of longer filter settle-in
182
- time. As such `fduration / 2` seconds of data
182
+ time. As such ``fduration / 2`` seconds of data
183
183
  will be removed from each edge of whitened
184
184
  timeseries.
185
185
  *background:
186
186
  1D arrays capturing the signal to be used to
187
- whiten each channel at call time. If `fftlength`
188
- is left as `None`, it will be assumed that these
187
+ whiten each channel at call time. If ``fftlength``
188
+ is left as ``None``, it will be assumed that these
189
189
  already represent frequency-domain data that will
190
190
  be possibly resampled and truncated to whiten
191
191
  timeseries at call time. Otherwise, it will be
192
192
  assumed that these represent time-domain data that
193
193
  will be converted to the frequency domain via
194
- Welch's method using the specified `fftlength`
195
- and `overlap`, with a Hann window used to window
194
+ Welch's method using the specified ``fftlength``
195
+ and ``overlap``, with a Hann window used to window
196
196
  the FFT frames by default. Should have the same
197
- number of args as `self.num_channels`.
197
+ number of args as ``self.num_channels``.
198
198
  fftlength:
199
199
  Length of frames used to convert time-domain
200
200
  data to the frequency-domain via Welch's method.
201
- If left as `None`, it will be assumed that the
201
+ If left as ``None``, it will be assumed that the
202
202
  background arrays passed already represent frequency-
203
203
  domain data and don't require any conversion.
204
204
  highpass:
@@ -206,21 +206,21 @@ class FixedWhiten(FittableSpectralTransform):
206
206
  with the fit whitening filter. This is achieved by
207
207
  setting the frequency response of the fit PSDs
208
208
  in the frequency bins below this value to 0.
209
- If left as `None`, the fit filter won't have any
209
+ If left as ``None``, the fit filter won't have any
210
210
  highpass filtering properties.
211
211
  lowpass:
212
212
  Cutoff frequency, in Hz, used for lowpass filtering
213
213
  with the fit whitening filter. This is achieved by
214
214
  setting the frequency response of the fit PSDs
215
215
  in the frequency bins above this value to 0.
216
- If left as `None`, the fit filter won't have any
216
+ If left as ``None``, the fit filter won't have any
217
217
  lowpass filtering properties.
218
218
  overlap:
219
219
  Overlap between FFT frames used to convert
220
220
  time-domain data to the frequency domain via
221
- Welch's method. If `fftlength` is `None`, this
222
- is ignored. Otherwise, if left as `None`, it will
223
- be set to half of `fftlength` by default.
221
+ Welch's method. If ``fftlength`` is ``None``, this
222
+ is ignored. Otherwise, if left as ``None``, it will
223
+ be set to half of ``fftlength`` by default.
224
224
  """
225
225
  if len(background) != self.num_channels:
226
226
  raise ValueError(
@@ -250,8 +250,8 @@ class FixedWhiten(FittableSpectralTransform):
250
250
  def forward(self, X: TimeSeries3d) -> TimeSeries3d:
251
251
  """
252
252
  Whiten the input timeseries tensor using the
253
- PSD fit by the `.fit` method, which must be
254
- called _before_ the first call to `.forward`.
253
+ PSD fit by the ``.fit`` method, which must be
254
+ called **before** the first call to ``.forward``.
255
255
  """
256
256
  expected_dim = int(self.kernel_length * self.sample_rate)
257
257
  if X.size(-1) != expected_dim:
ml4gw/utils/slicing.py CHANGED
@@ -25,9 +25,9 @@ def unfold_windows(
25
25
  Args:
26
26
  x:
27
27
  The timeseries to unfold. Can have shape
28
- `(batch_size, num_channels, length * sample_rate)`,
29
- `(num_channels, length * sample_rate)`, or
30
- `(length * sample_rate)`
28
+ ``(batch_size, num_channels, length * sample_rate)``,
29
+ ``(num_channels, length * sample_rate)``, or
30
+ ``(length * sample_rate)``
31
31
  window_size:
32
32
  The size of the windows to unfold from x
33
33
  stride:
@@ -39,12 +39,12 @@ def unfold_windows(
39
39
 
40
40
  Returns:
41
41
  A tensor of shape
42
- `(num_windows, batch_size, num_channels, kernel_size)`,
43
- `(num_windows, num_channels, kernel_size)`, or
44
- `(num_windows, kernel_size)` depending on whether the
42
+ ``(num_windows, batch_size, num_channels, kernel_size)``,
43
+ ``(num_windows, num_channels, kernel_size)``, or
44
+ ``(num_windows, kernel_size)`` depending on whether the
45
45
  input tensor is 3D, 2D, or 1D
46
46
 
47
- If `drop_last` is false, returns the remainder of the
47
+ If ``drop_last`` is false, returns the remainder of the
48
48
  timeseries, shaped to be compatible with the returned
49
49
  unfolded tensor
50
50
  """
@@ -93,34 +93,34 @@ def slice_kernels(
93
93
  multichannel timeseries, slice kernels of a given size
94
94
  from the timeseries starting at the indicated indices.
95
95
  Returns a batch of 1D or 2D kernels, and so will have
96
- one more dimension than `x`.
96
+ one more dimension than ``x``.
97
97
 
98
98
  Args:
99
99
  x:
100
100
  The timeseries tensor to slice kernels from
101
101
  idx:
102
- The indices in `x` of the first sample of each
103
- kernel. If `x` is 1D, `idx` must be 1D as well.
104
- If `x` is 2D and `idx` is 1D, `idx` is assumed
102
+ The indices in ``x`` of the first sample of each
103
+ kernel. If ``x`` is 1D, ``idx`` must be 1D as well.
104
+ If ``x`` is 2D and ``idx`` is 1D, ``idx`` is assumed
105
105
  to represent the first index of the kernels sliced
106
106
  from _all_ channels (i.e. the channels are sliced
107
- coincidentally). If `x` is 2D and `idx` is also 2D,
108
- `idx` should have shape `(batch_size, num_channels)`,
107
+ coincidentally). If ``x`` is 2D and ``idx`` is also 2D,
108
+ ``idx`` should have shape ``(batch_size, num_channels)``,
109
109
  and its values are assumed to represent the first index
110
110
  of the kernel sliced from each channel _independently_.
111
- If `x` is 3D, `idx` _must_ be 1D, and have the same length
112
- as `x`. In this case, it is assumed that the elements of
113
- `idx` represent the starting index in the last dimension
114
- of `x` from which to sample a batch of kernels
111
+ If ``x`` is 3D, ``idx`` _must_ be 1D, and have the same length
112
+ as ``x``. In this case, it is assumed that the elements of
113
+ ``idx`` represent the starting index in the last dimension
114
+ of ``x`` from which to sample a batch of kernels
115
115
  coincidentally among the channels.
116
116
  kernel_size:
117
117
  The length of the kernels to slice from the timeseries
118
118
 
119
119
  Returns:
120
- A tensor of shape `(batch_size, kernel_size)` if `x` is
121
- 1D and `(batch_size, num_channels, kernel_size)` if `x`
122
- is 2D, where `batch_size = idx.shape[0]` and
123
- `num_channels = x.shape[0]` if `x` is 2D.
120
+ A tensor of shape ``(batch_size, kernel_size)`` if ``x`` is
121
+ 1D and ``(batch_size, num_channels, kernel_size)`` if ``x``
122
+ is 2D, where ``batch_size = idx.shape[0]`` and
123
+ ``num_channels = x.shape[0]`` if ``x`` is 2D.
124
124
  """
125
125
 
126
126
  # create the indices all the slices will be built around,
@@ -239,14 +239,14 @@ def sample_kernels(
239
239
 
240
240
  For a tensor representing one or multiple channels of
241
241
  timeseries data, randomly slice kernels of a fixed
242
- length from the timeseries. If `X` is 1D, kernels will
243
- be sampled uniformly from `X`. If `X` is 2D, kernels
244
- will be sampled from the first dimension of `X` (assumed
242
+ length from the timeseries. If ``X`` is 1D, kernels will
243
+ be sampled uniformly from ``X``. If ``X`` is 2D, kernels
244
+ will be sampled from the first dimension of ``X`` (assumed
245
245
  to be the time dimension) in a manner that depends on the
246
- values of the `max_center_offset` and `coincident` kwargs.
247
- If `X` is 3D, one kernel will be sampled coincidentally from
248
- each element along the 0th axis of `X`. In this case, `N` must
249
- either be `None` or be equal to `len(X)`.
246
+ values of the ``max_center_offset`` and ``coincident`` kwargs.
247
+ If ``X`` is 3D, one kernel will be sampled coincidentally from
248
+ each element along the 0th axis of ``X``. In this case, ``N`` must
249
+ either be ``None`` or be equal to ``len(X)``.
250
250
 
251
251
  Args:
252
252
  X:
@@ -254,12 +254,12 @@ def sample_kernels(
254
254
  kernel_size: The size of the kernels to sample
255
255
  N:
256
256
  The number of kernels to sample. Can be left as
257
- `None` if `X` is 3D, otherwise must be specified
257
+ ``None`` if ``X`` is 3D, otherwise must be specified
258
258
  max_center_offeset:
259
- If `X` is 2D, this indicates the maximum distance
259
+ If ``X`` is 2D, this indicates the maximum distance
260
260
  from the center of the timeseries the edge of
261
- sampled kernels may fall. If left as `None`, kernels
262
- will be sampled uniformly across all of `X`'s time
261
+ sampled kernels may fall. If left as ``None``, kernels
262
+ will be sampled uniformly across all of ``X``'s time
263
263
  dimension. If greater than 0, defines the maximum
264
264
  distance that the rightmost edge of the kernel may
265
265
  fall from the center of the timeseries (the leftmost
@@ -269,19 +269,19 @@ def sample_kernels(
269
269
  of the timeseries, which may fall anywhere within the
270
270
  kernel with uniform probability. If less than 0, defines
271
271
  the minimum distance that the center of the timeseries
272
- must fall from either edge of the kernel. If `X` is
272
+ must fall from either edge of the kernel. If ``X`` is
273
273
  1D, this argument is ignored.
274
274
  coincident:
275
- If `X` is 2D, determines whether the individual channels
276
- of `X` sample the same kernels or different kernels
275
+ If ``X`` is 2D, determines whether the individual channels
276
+ of ``X`` sample the same kernels or different kernels
277
277
  independently, i.e. whether the channels of each batch
278
278
  element in the output will contain coincident data. If
279
- `X` is 1D, this argument is ignored.
279
+ ``X`` is 1D, this argument is ignored.
280
280
  Returns:
281
- A batch of sampled kernels. If `X` is 1D, this will have
282
- shape `(N, kernel_size)`. If `X` is 2D, this will have
283
- shape `(N, num_channels, kernel_size)`, where
284
- `num_channels = X.shape[0]`.
281
+ A batch of sampled kernels. If ``X`` is 1D, this will have
282
+ shape ``(N, kernel_size)``. If ``X`` is 2D, this will have
283
+ shape ``(N, num_channels, kernel_size)``, where
284
+ ``num_channels = X.shape[0]``.
285
285
  """
286
286
 
287
287
  if X.shape[-1] < kernel_size:
@@ -56,14 +56,15 @@ class IMRPhenomD(TaylorF2):
56
56
  """
57
57
  # shape assumed (n_batch, params)
58
58
  if (
59
- chirp_mass.shape[0] != mass_ratio.shape[0]
60
- or mass_ratio.shape[0] != chi1.shape[0]
61
- or chi1.shape[0] != chi2.shape[0]
62
- or chi2.shape[0] != distance.shape[0]
63
- or distance.shape[0] != phic.shape[0]
64
- or phic.shape[0] != inclination.shape[0]
59
+ not chirp_mass.shape[0]
60
+ == mass_ratio.shape[0]
61
+ == chi1.shape[0]
62
+ == chi2.shape[0]
63
+ == distance.shape[0]
64
+ == phic.shape[0]
65
+ == inclination.shape[0]
65
66
  ):
66
- raise RuntimeError("Tensors should have same batch size")
67
+ raise ValueError("Tensors must have same batch size")
67
68
  cfac = torch.cos(inclination)
68
69
  pfac = 0.5 * (1.0 + cfac * cfac)
69
70
 
@@ -104,16 +105,18 @@ class IMRPhenomD(TaylorF2):
104
105
 
105
106
  fRD, fDM = self.fring_fdamp(eta, eta2, chi1, chi2)
106
107
  Mf_peak = self.fmaxCalc(fRD, fDM, gamma2, gamma3)
107
- _, t0 = self.phenom_d_mrd_phase(Mf_peak, eta, eta2, chi1, chi2, xi)
108
+ _, t0 = self.phenom_d_mrd_phase(
109
+ Mf_peak, eta, eta2, chi1, chi2, xi, fRD, fDM
110
+ )
108
111
 
109
112
  Mf = torch.outer(M_s, f)
110
113
  Mf_ref = torch.outer(M_s, f_ref * torch.ones_like(f))
111
114
 
112
115
  Psi, _ = self.phenom_d_phase(
113
- Mf, mass_1, mass_2, eta, eta2, chi1, chi2, xi
116
+ Mf, mass_1, mass_2, eta, eta2, chi1, chi2, xi, fRD, fDM
114
117
  )
115
118
  Psi_ref, _ = self.phenom_d_phase(
116
- Mf_ref, mass_1, mass_2, eta, eta2, chi1, chi2, xi
119
+ Mf_ref, mass_1, mass_2, eta, eta2, chi1, chi2, xi, fRD, fDM
117
120
  )
118
121
 
119
122
  Psi = (Psi.mT - 2 * phic).mT
@@ -133,6 +136,8 @@ class IMRPhenomD(TaylorF2):
133
136
  chi22,
134
137
  xi,
135
138
  distance,
139
+ fRD,
140
+ fDM,
136
141
  )
137
142
 
138
143
  amp_0 = self.taylorf2_amplitude(
@@ -157,8 +162,8 @@ class IMRPhenomD(TaylorF2):
157
162
  chi22,
158
163
  xi,
159
164
  distance,
160
- fRD=None, # used for passing ringdown frequency from phenom_p
161
- fDM=None, # used for passing damping frequency from phenom_p
165
+ fRD,
166
+ fDM,
162
167
  ):
163
168
  ins_amp, ins_Damp = self.phenom_d_inspiral_amp(
164
169
  Mf, eta, eta2, Seta, xi, chi1, chi2, chi12, chi22
@@ -173,14 +178,6 @@ class IMRPhenomD(TaylorF2):
173
178
  gamma2 = self.gamma2_fun(eta, eta2, xi)
174
179
  gamma3 = self.gamma3_fun(eta, eta2, xi)
175
180
 
176
- # merger ringdown
177
- if (fRD is None) != (fDM is None):
178
- raise ValueError(
179
- "Both fRD and fDM must either be provided or both be None"
180
- )
181
- if (fRD is None) and (fDM is None):
182
- fRD, fDM = self.fring_fdamp(eta, eta2, chi1, chi2)
183
-
184
181
  Mf_peak = self.fmaxCalc(fRD, fDM, gamma2, gamma3)
185
182
  # Geometric peak and joining frequencies
186
183
  Mf_peak = (torch.ones_like(Mf).mT * Mf_peak).mT
@@ -221,17 +218,9 @@ class IMRPhenomD(TaylorF2):
221
218
  chi12,
222
219
  chi22,
223
220
  xi,
224
- fRD=None, # used for passing ringdown frequency from phenom_p
225
- fDM=None, # used for passing damping frequency from phenom_p
221
+ fRD,
222
+ fDM,
226
223
  ):
227
- # merger ringdown
228
- if (fRD is None) != (fDM is None):
229
- raise ValueError(
230
- "Both fRD and fDM must either be provided or both be None"
231
- )
232
- if (fRD is None) and (fDM is None):
233
- fRD, fDM = self.fring_fdamp(eta, eta2, chi1, chi2)
234
-
235
224
  # Geometric frequency definition from PhenomD header file
236
225
  AMP_fJoin_INS = 0.014
237
226
 
@@ -268,19 +257,7 @@ class IMRPhenomD(TaylorF2):
268
257
  )
269
258
  return amp, Damp
270
259
 
271
- # fRD and fDM are to be passed for generating phenom_p waveforms
272
- # and remain None for phenom_d
273
- def phenom_d_mrd_amp(
274
- self, Mf, eta, eta2, chi1, chi2, xi, fRD=None, fDM=None
275
- ):
276
- # merger ringdown
277
- if (fRD is None) != (fDM is None):
278
- raise ValueError(
279
- "Both fRD and fDM must either be provided or both be None"
280
- )
281
- if (fRD is None) and (fDM is None):
282
- fRD, fDM = self.fring_fdamp(eta, eta2, chi1, chi2)
283
-
260
+ def phenom_d_mrd_amp(self, Mf, eta, eta2, chi1, chi2, xi, fRD, fDM):
284
261
  gamma1 = self.gamma1_fun(eta, eta2, xi)
285
262
  gamma2 = self.gamma2_fun(eta, eta2, xi)
286
263
  gamma3 = self.gamma3_fun(eta, eta2, xi)
@@ -422,10 +399,8 @@ class IMRPhenomD(TaylorF2):
422
399
 
423
400
  return amp, Damp
424
401
 
425
- # fRD and fDM are to be passed for generating phenom_p waveforms
426
- # and remain None for phenom_d
427
402
  def phenom_d_phase(
428
- self, Mf, mass_1, mass_2, eta, eta2, chi1, chi2, xi, fRD=None, fDM=None
403
+ self, Mf, mass_1, mass_2, eta, eta2, chi1, chi2, xi, fRD, fDM
429
404
  ):
430
405
  ins_phase, ins_Dphase = self.phenom_d_inspiral_phase(
431
406
  Mf, mass_1, mass_2, eta, eta2, xi, chi1, chi2
@@ -435,13 +410,6 @@ class IMRPhenomD(TaylorF2):
435
410
  Mf, eta, eta2, chi1, chi2, xi, fRD, fDM
436
411
  )
437
412
 
438
- # merger ringdown
439
- if (fRD is None) != (fDM is None):
440
- raise ValueError(
441
- "Both fRD and fDM must either be provided or both be None"
442
- )
443
- if (fRD is None) and (fDM is None):
444
- fRD, fDM = self.fring_fdamp(eta, eta2, chi1, chi2)
445
413
  # definitions in Eq. (35) of arXiv:1508.07253
446
414
  # PHI_fJoin_INS in header LALSimIMRPhenomD.h
447
415
  # C1 continuity at intermediate region i.e. f_1
@@ -501,25 +469,13 @@ class IMRPhenomD(TaylorF2):
501
469
 
502
470
  return phasing, Dphasing
503
471
 
504
- # fRD and fDM are to be passed for generating phenom_p waveforms
505
- # and remain None for phenom_d
506
- def phenom_d_mrd_phase(
507
- self, Mf, eta, eta2, chi1, chi2, xi, fRD=None, fDM=None
508
- ):
472
+ def phenom_d_mrd_phase(self, Mf, eta, eta2, chi1, chi2, xi, fRD, fDM):
509
473
  alpha1 = self.alpha1Fit(eta, eta2, xi)
510
474
  alpha2 = self.alpha2Fit(eta, eta2, xi)
511
475
  alpha3 = self.alpha3Fit(eta, eta2, xi)
512
476
  alpha4 = self.alpha4Fit(eta, eta2, xi)
513
477
  alpha5 = self.alpha5Fit(eta, eta2, xi)
514
478
 
515
- # merger ringdown
516
- if (fRD is None) != (fDM is None):
517
- raise ValueError(
518
- "Both fRD and fDM must either be provided or both be None"
519
- )
520
- if (fRD is None) and (fDM is None):
521
- fRD, fDM = self.fring_fdamp(eta, eta2, chi1, chi2)
522
-
523
479
  f_minus_alpha5_fRD = (Mf.t() - alpha5 * fRD).t()
524
480
  # Leading 1/eta is not multiplied at this stage
525
481
  mrd_phasing = (Mf.t() * alpha1).t()
@@ -403,13 +403,17 @@ class IMRPhenomPv2(IMRPhenomD):
403
403
  with given data points :math:`(xp, fp)`, evaluated at :math:`x`
404
404
 
405
405
  Args:
406
- x: the :math:`x`-coordinates at which to evaluate the interpolated
407
- values.
408
- xp: the :math:`x`-coordinates of data points, must be increasing.
409
- fp: the :math:`y`-coordinates of data points, same length as `xp`.
406
+ x:
407
+ the :math:`x`-coordinates at which to evaluate the
408
+ interpolated values.
409
+ xp:
410
+ the :math:`x`-coordinates of data points, must be increasing.
411
+ fp:
412
+ the :math:`y`-coordinates of data points, same length as
413
+ ``xp``.
410
414
 
411
415
  Returns:
412
- the interpolated values, same size as `x`.
416
+ the interpolated values, same size as ``x``.
413
417
  """
414
418
  original_shape = x.shape
415
419
  x = x.flatten()
@@ -54,14 +54,15 @@ class TaylorF2(torch.nn.Module):
54
54
 
55
55
  # shape assumed (n_batch, params)
56
56
  if (
57
- chirp_mass.shape[0] != mass_ratio.shape[0]
58
- or chirp_mass.shape[0] != chi1.shape[0]
59
- or chi1.shape[0] != chi2.shape[0]
60
- or chi2.shape[0] != distance.shape[0]
61
- or distance.shape[0] != phic.shape[0]
62
- or phic.shape[0] != inclination.shape[0]
57
+ not chirp_mass.shape[0]
58
+ == mass_ratio.shape[0]
59
+ == chi1.shape[0]
60
+ == chi2.shape[0]
61
+ == distance.shape[0]
62
+ == phic.shape[0]
63
+ == inclination.shape[0]
63
64
  ):
64
- raise RuntimeError("Tensors should have same batch size")
65
+ raise ValueError("Tensors must have same batch size")
65
66
 
66
67
  mass1, mass2 = chirp_mass_and_mass_ratio_to_components(
67
68
  chirp_mass, mass_ratio
@@ -37,10 +37,11 @@ def chirp_mass_and_mass_ratio_to_components(
37
37
  ):
38
38
  """
39
39
  Compute component masses from chirp mass and mass ratio.
40
+
40
41
  Args:
41
42
  chirp_mass: Tensor of chirp mass values
42
43
  mass_ratio:
43
- Tensor of mass ratio values, `m2 / m1`,
44
+ Tensor of mass ratio values, ``m2 / m1``,
44
45
  where m1 >= m2, so that mass_ratio <= 1
45
46
  """
46
47
  total_mass = chirp_mass * (1 + mass_ratio) ** 1.2 / mass_ratio**0.6