Repository: kymatio/kymatio

Issue:
Simplify 1D constructor
Right now, there are several arguments to the `Scattering1D` class that are not used: `criterion_amplitude`, `r_psi`, `sigma0`, `alpha`, `P_max`, `eps`. Another argument, `normalize`, is used in one of the tests, but set to its default value (`'l1'`). While it is good to have flexibility, there is currently no evidence that the defaults give unsatisfactory results. Furthermore, having these options make it harder to follow what's going on and increases the burden for us in maintaining backwards compatibility.

This last point is important because there is likely some reduction and refactoring possible here. For example, `criterion_amplitude` and `eps` both refer to a precision in computing the filter bank, while `P_max` refers to the number of periods to use in computing a filter. These could probably be computed from a single tolerance value. Further, `alpha` is the "aliasing tolerance after subsampling" and may be calculated from the `oversampling` parameter (or vice versa). The other parameters, `r_psi`, `sigma0`, and `normalize`, are more independent, but the question remains how to specify them in a way that's simple and compatible with the other transforms.

Until we have decided how to structure these interfaces, I think it's a good idea to fix these parameters to their default values and bring them back into the interface when it's time.


Discussion:
I agree with this. For the first release I'd propose to either not do anything or, as you suggest, fix the parameters, maybe for the moment in the `build` method as class attributes
Ok. I like the idea of putting these as attributes and using them during `build`. I'd still keep them out of the docs, though, for now.

Resolving patch:
diff --git a/kymatio/scattering1d/scattering1d.py b/kymatio/scattering1d/scattering1d.py
--- a/kymatio/scattering1d/scattering1d.py
+++ b/kymatio/scattering1d/scattering1d.py
@@ -90,31 +90,6 @@ class Scattering1D(object):
     Q : int >= 1
         The number of first-order wavelets per octave (second-order wavelets
         are fixed to one wavelet per octave).
-    normalize : string, optional
-        Normalization of the wavelets: `'l1'`, corresponding to
-        :math:`\\ell^1`-normalization, or `'l2'`, corresponding to
-        :math:`\\ell^2`-normalization. Defaults to `'l1'`.
-    criterion_amplitude : float, optional
-        Controls the padding size (the larger this value, the smaller the
-        padding size). Measures the amount of the Gaussian mass (in the
-        :math:`\\ell^1` norm) which can be ignored after padding. Defaults
-        to `1e-3`.
-    r_psi : float, optional
-        Controls the redundancy of the filters (the larger this value, the
-        larger the overlap between adjacent wavelets). Must be between zero
-        and one. Defaults to `math.sqrt(0.5)`.
-    sigma0 : float, optional
-        Controls the frequency bandwidth of the lowpass filter
-        :math:`\\phi_J(t)`, which is given by `sigma0/2**J`. Defaults to
-        `1e-1`.
-    alpha : float, optional
-        Aliasing tolerance after subsampling. The larger this value, the more
-        conservative the subsampling during the transform. Defaults to `5`.
-    P_max : int > 1, optional
-        Maximum number of periods to use to ensure that the Fourier transform
-        of the filters is periodic. Defaults to `5`.
-    eps : float, optional
-        Required precision for the periodization. Defaults to `1e-7`.
     max_order : int, optional
         The maximum order of scattering coefficients to compute. Must be either
         `1` or `2`. Defaults to `2`.
@@ -184,29 +159,22 @@ class Scattering1D(object):
         or collected into a dictionary. For more details, see the
         documentation for `forward()`.
     """
-    def __init__(self, J, shape, Q, normalize='l1', criterion_amplitude=1e-3,
-                 r_psi=math.sqrt(0.5), sigma0=0.1, alpha=5.,
-                 P_max=5, eps=1e-7, max_order=2, average=True,
+    def __init__(self, J, shape, Q, max_order=2, average=True,
                  oversampling=0, vectorize=True):
         super(Scattering1D, self).__init__()
         # Store the parameters
         self.J = J
         self.shape = shape
         self.Q = Q
-        self.r_psi = r_psi
-        self.sigma0 = sigma0
-        self.alpha = alpha
-        self.P_max = P_max
-        self.eps = eps
-        self.criterion_amplitude = criterion_amplitude
-        self.normalize = normalize
-        # Build internal values
-        self.build()
+
         self.max_order = max_order
         self.average = average
         self.oversampling = oversampling
         self.vectorize = vectorize
 
+        # Build internal values
+        self.build()
+
     def build(self):
         """Set up padding and filters
 
@@ -217,6 +185,16 @@ def build(self):
         therefore needed.
         """
 
+        # Set these default values for now. In the future, we'll want some
+        # flexibility for these, but for now, let's keep them fixed.
+        self.r_psi = math.sqrt(0.5)
+        self.sigma0 = 0.1
+        self.alpha = 5.
+        self.P_max = 5
+        self.eps = 1e-7
+        self.criterion_amplitude = 1e-3
+        self.normalize = 'l1'
+
         # check the shape
         if isinstance(self.shape, numbers.Integral):
             self.T = self.shape


Test patch:
diff --git a/kymatio/scattering1d/tests/test_scattering1d.py b/kymatio/scattering1d/tests/test_scattering1d.py
--- a/kymatio/scattering1d/tests/test_scattering1d.py
+++ b/kymatio/scattering1d/tests/test_scattering1d.py
@@ -23,7 +23,7 @@ def test_simple_scatterings(random_state=42):
     J = 6
     Q = 8
     T = 2**12
-    scattering = Scattering1D(J, T, Q, normalize='l1')
+    scattering = Scattering1D(J, T, Q)
     if force_gpu:
         scattering = scattering.cuda()
     # zero signal
@@ -102,7 +102,7 @@ def test_computation_Ux(random_state=42):
     J = 6
     Q = 8
     T = 2**12
-    scattering = Scattering1D(J, T, Q, normalize='l1', average=False,
+    scattering = Scattering1D(J, T, Q, average=False,
                               max_order=1, vectorize=False)
     # random signal
     x = torch.from_numpy(rng.randn(1, T)).float()