コード例 #1
0
ファイル: mf_newforms.py プロジェクト: roed314/beantheory2
 def check_self_dual_by_embeddings(self):
     """
     if is_self_dual is present but field_poly is not present,
     check that embedding data in mf_hecke_cc is consistent with
     is_self_dual
     """
     # TIME > 1300s
     # I expect this to take about 3/4h
     # we a create a temp table as we can't use aggregates under WHERE
     db._execute(SQL("CREATE TEMP TABLE tmp_cc AS SELECT t1.hecke_orbit_code, every(0 = all(t1.an_normalized[:][2:2] )) self_dual FROM mf_hecke_cc t1, mf_newforms t2 WHERE t1.hecke_orbit_code=t2.hecke_orbit_code AND t2.is_self_dual AND t2.field_poly is NULL GROUP BY t1.hecke_orbit_code"))
     query = SQL("SELECT t1.label FROM mf_newforms t1, tmp_cc t2 WHERE NOT t2.self_dual AND t1.hecke_orbit_code = t2.hecke_orbit_code")
     return self._run_query(query=query)
コード例 #2
0
 def rename_hyphens(self, execute=False):
     selecter = SQL("SELECT DISTINCT ON (id) id FROM kwl_knowls WHERE id LIKE %s")
     bad_names = [rec[0] for rec in db._execute(selecter, ['%-%'])]
     if execute:
         for kid in bad_names:
             new_kid = kid.replace('-', '_')
             print("Renaming %s -> %s" % (kid, new_kid))
             self.rename(kid, new_kid)
     else:
         print(bad_names)
コード例 #3
0
ファイル: verification.py プロジェクト: roed314/beantheory2
    def _run_query(self,
                   condition=None,
                   constraint={},
                   values=None,
                   table=None,
                   query=None,
                   ratio=1):
        """
        Run a query to check a condition.

        The number of returned failures will be limited by the
        ``_cur_limit`` attribute of this ``TableChecker``.  If
        ``_cur_label`` is set, only that label will be checked.

        INPUT:

        - ``condition`` -- an SQL object giving a condition on the search table
        - ``constraint`` -- a dictionary, as passed to the search method, or an SQL object
        - ``values`` -- a list of values to fill in for ``%s`` in the condition.
        - ``table`` -- an SQL object or string giving the table to execute this query on.
            Defaults to the table for this TableChecker.
        - ``query`` -- an SQL object giving the whole query, leaving out only the
            ``_cur_label`` and ``_cur_limit`` parts.  Note that ``condition``,
            ``constraint``, ``table`` and ``ratio`` will be ignored if query is provided.
        - ``ratio`` -- the ratio of rows in the table to run this query on.

        """
        if values is None:
            values = []
        label_col = Identifier(self.label_col)
        if query is None:
            if table is None:
                table = self.table.search_table
            if isinstance(table, string_types):
                if ratio == 1:
                    table = Identifier(table)
                else:
                    table = SQL("{0} TABLESAMPLE SYSTEM({1})").format(
                        Identifier(table), Literal(ratio))

            # WARNING: the following is not safe from SQL injection, so be careful if you copy this code
            query = SQL("SELECT {0} FROM {1} WHERE {2}").format(
                label_col, table, condition)
            if not isinstance(constraint, Composable):
                constraint, cvalues = self.table._parse_dict(constraint)
                if constraint is not None:
                    values = values + cvalues
            if constraint is not None:
                query = SQL("{0} AND {1}").format(query, constraint)
        if self._cur_label is not None:
            query = SQL("{0} AND {1} = %s").format(query, label_col)
            values += [self._cur_label]
        query = SQL("{0} LIMIT %s").format(query)
        cur = db._execute(query, values + [self._cur_limit])
        return [rec[0] for rec in cur]
コード例 #4
0
ファイル: mf_newforms.py プロジェクト: asym57/lmfdb
 def check_self_dual_lfunctions(self):
     """
     check that the lfunction self_dual attribute is consistent with newforms
     """
     # TIME > 1200s
     db._execute(
         SQL("CREATE TEMP TABLE temp_mftbl AS SELECT label, string_to_array(label,'.'), is_self_dual FROM mf_newforms"
             ))
     db._execute(
         SQL("CREATE TEMP TABLE temp_ltbl AS SELECT (string_to_array(origin,'/'))[5:8], every(self_dual) self_dual FROM lfunc_lfunctions WHERE origin LIKE 'ModularForm/GL2/Q/holomorphic%' and degree=2 GROUP BY (string_to_array(origin,'/'))[5:8]"
             ))
     db._execute(
         SQL("CREATE INDEX temp_ltbl_string_to_array_index on temp_ltbl using HASH(string_to_array)"
             ))
     db._execute(
         SQL("CREATE INDEX temp_mftbl_string_to_array_index on temp_mftbl using HASH(string_to_array)"
             ))
     query = SQL(
         "SELECT t1.label FROM temp_mftbl t1, temp_ltbl t2 WHERE t1.is_self_dual != t2.self_dual AND t2.string_to_array = t1.string_to_array"
     )
     res = self._run_query(query=query)
     db._execute(SQL("DROP TABLE temp_mftbl"))
     db._execute(SQL("DROP TABLE temp_ltbl"))
     return res
コード例 #5
0
ファイル: mf_newforms.py プロジェクト: asym57/lmfdb
 def check_analytic_rank(self):
     """
     if analytic_rank is present, check that matches
     order_of_vanishing in lfunctions record, and is are constant
     across the orbit
     """
     # TIME about 1200s
     db._execute(
         SQL("CREATE TEMP TABLE temp_mftbl AS SELECT label, string_to_array(label,'.'), analytic_rank, dim FROM mf_newforms WHERE analytic_rank is NOT NULL"
             ))
     db._execute(
         SQL("CREATE TEMP TABLE temp_ltbl AS SELECT order_of_vanishing,(string_to_array(origin,'/'))[5:8],degree FROM lfunc_lfunctions WHERE origin LIKE 'ModularForm/GL2/Q/holomorphic%' and degree=2"
             ))
     db._execute(
         SQL("CREATE INDEX temp_ltbl_string_to_array_index on temp_ltbl using HASH(string_to_array)"
             ))
     db._execute(
         SQL("CREATE INDEX temp_mftbl_string_to_array_index on temp_mftbl using HASH(string_to_array)"
             ))
     query = SQL(
         "SELECT label FROM temp_mftbl t1 WHERE array_fill(t1.analytic_rank::smallint, ARRAY[t1.dim]) != ARRAY(SELECT t2.order_of_vanishing FROM temp_ltbl t2 WHERE t2.string_to_array = t1.string_to_array )"
     )
     res = self._run_query(query=query)
     db._execute(SQL("DROP TABLE temp_mftbl"))
     db._execute(SQL("DROP TABLE temp_ltbl"))
     return res