Repository: kymatio/kymatio

Issue:
Remove assertions in `core/scattering1d`
Currently there are a set of assertion statements in the core scattering1d algorithm. we should either remove these or move them somewhere more appropriate, like filterbank construction. 


Discussion:
These assertions require `oversampling` to become immutable, which i absolutely support. It will make our lives so much easier in core
in support of

Resolving patch:
diff --git a/kymatio/frontend/base_frontend.py b/kymatio/frontend/base_frontend.py
--- a/kymatio/frontend/base_frontend.py
+++ b/kymatio/frontend/base_frontend.py
@@ -1,4 +1,5 @@
 import importlib
+import itertools
 
 
 class ScatteringBase():
@@ -13,6 +14,21 @@ def build(self):
         self.filters = self.create_filters() """
         raise NotImplementedError
 
+    def _check_filterbanks(psi1s, psi2s):
+        # Check for absence of aliasing at the first order
+        # that the Nyquist frequency of each filter, 2**(-j), is at least
+        # one octave above its frequency xi
+        assert all((psi1["xi"] < 0.5/(2**psi1["j"])) for psi1 in psi1s)
+
+        # Check for absence of aliasing at the second order
+        # The filter function selects the (psi1, psi2) pairs such that j1<j2.
+        # The map function evaluates whether those pairs also satisfy xi1>xi2.
+        # Hence, the "assert all" statement guarantees that (j1<j2) => (xi1>xi2)
+        psi_generator = itertools.product(psi1s, psi2s)
+        condition = lambda psi1_or_2: psi1_or_2[0]['j'] < psi1_or_2[1]['j']
+        implication = lambda psi1_or_2: psi1_or_2[0]['xi'] > psi1_or_2[1]['xi']
+        assert all(map(implication, filter(condition, psi_generator)))
+
     def _instantiate_backend(self, import_string):
         """ This function should instantiate the backend to be used if not already
         specified"""
diff --git a/kymatio/scattering1d/core/scattering1d.py b/kymatio/scattering1d/core/scattering1d.py
--- a/kymatio/scattering1d/core/scattering1d.py
+++ b/kymatio/scattering1d/core/scattering1d.py
@@ -88,7 +88,6 @@ def scattering1d(x, backend, psi1, psi2, phi, pad_left=0,
         sub1_adj = min(j1, log2_T) if average else j1
         k1 = max(sub1_adj - oversampling, 0)
 
-        assert psi1[n1]['xi'] < 0.5 / (2**k1)
         U_1_c = cdgmm(U_0_hat, psi1[n1]['levels'][0])
         U_1_hat = subsample_fourier(U_1_c, 2**k1)
         U_1_c = ifft(U_1_hat)
@@ -120,8 +119,6 @@ def scattering1d(x, backend, psi1, psi2, phi, pad_left=0,
                 j2 = psi2[n2]['j']
 
                 if j2 > j1:
-                    assert psi2[n2]['xi'] < psi1[n1]['xi']
-
                     # convolution + downsampling
                     sub2_adj = min(j2, log2_T) if average else j2
                     k2 = max(sub2_adj - k1 - oversampling, 0)
diff --git a/kymatio/scattering1d/frontend/base_frontend.py b/kymatio/scattering1d/frontend/base_frontend.py
--- a/kymatio/scattering1d/frontend/base_frontend.py
+++ b/kymatio/scattering1d/frontend/base_frontend.py
@@ -81,6 +81,7 @@ def create_filters(self):
         self.phi_f, self.psi1_f, self.psi2_f = scattering_filter_factory(
             self.J_pad, self.J, self.Q, self.T,
             r_psi=self.r_psi, sigma0=self.sigma0, alpha=self.alpha)
+        ScatteringBase._check_filterbanks(self.psi1_f, self.psi2_f)
 
     def meta(self):
         """Get meta information on the transform


Test patch: