<commit_before># Copyright 2015 by <NAME> Technologies Corp.  All Rights Reserved.

"""
Unroll for loops (and possibly other conditional/iterative statements)
within a "with concur" block.
"""

import ast
import os
import sys

from copy import deepcopy

import pyqgl2.ast_util

from pyqgl2.ast_qgl2 import is_concur, is_infunc, is_seq
from pyqgl2.ast_util import ast2str, expr2ast, NodeError, value2ast
from pyqgl2.debugmsg import DebugMsg
from pyqgl2.importer import collapse_name
from pyqgl2.inline import QubitPlaceholder
from pyqgl2.lang import QGL2

def find_all_channels(node, local_vars=None):
    """
    Wrapper for find_all_channels_worker, which checks that the result
    returned matches the value of node.qgl2_referenced_qbits,
    which is what we want to use in the future.

    Use of find_all_channels* is deprecated.
    """

    channels = find_all_channels_worker(node, local_vars=local_vars)

    # for debugging/testing only

    if hasattr(node, 'qgl2_referenced_qbits'):
        if channels != node.qgl2_referenced_qbits:
            DebugMsg.log("channels != node.qgl2_referenced_qbits",
                    level=HIGH)
    else:
        DebugMsg.log("node lacks a qgl2_referenced_qbits",
                level=HIGH)

    return channels

def find_all_channels_worker(node, local_vars=None):
    """
    Reinitialze the set of all_channels to be the set of
    all channels referenced in the AST rooted at the given
    node.

    This is a hack, because we assume we can identify all
    channels lexically.  FIXME
    """

    if not local_vars:
        local_vars = dict()

    all_channels = set()

    for subnode in ast.walk(node):
        if isinstance(subnode, ast.Name):<commit_msg>fix typos in DebugMsg constants<commit_after># Copyright 2015 by <NAME> Technologies Corp.  All Rights Reserved.

"""
Unroll for loops (and possibly other conditional/iterative statements)
within a "with concur" block.
"""

import ast
import os
import sys

from copy import deepcopy

import pyqgl2.ast_util

from pyqgl2.ast_qgl2 import is_concur, is_infunc, is_seq
from pyqgl2.ast_util import ast2str, expr2ast, NodeError, value2ast
from pyqgl2.debugmsg import DebugMsg
from pyqgl2.importer import collapse_name
from pyqgl2.inline import QubitPlaceholder
from pyqgl2.lang import QGL2

def find_all_channels(node, local_vars=None):
    """
    Wrapper for find_all_channels_worker, which checks that the result
    returned matches the value of node.qgl2_referenced_qbits,
    which is what we want to use in the future.

    Use of find_all_channels* is deprecated.
    """

    channels = find_all_channels_worker(node, local_vars=local_vars)

    # for debugging/testing only

    if hasattr(node, 'qgl2_referenced_qbits'):
        if channels != node.qgl2_referenced_qbits:
            DebugMsg.log("channels != node.qgl2_referenced_qbits",
                    level=DebugMsg.HIGH)
    else:
        DebugMsg.log("node lacks a qgl2_referenced_qbits",
                level=DebugMsg.HIGH)

    return channels

def find_all_channels_worker(node, local_vars=None):
    """
    Reinitialze the set of all_channels to be the set of
    all channels referenced in the AST rooted at the given
    node.

    This is a hack, because we assume we can identify all
    channels lexically.  FIXME
    """

    if not local_vars:
        local_vars = dict()

    all_channels = set()

    for subnode in ast.walk(node):
        if isinstance(subnode, ast.Name):
{'fraction_non_alphanumeric': 0.06628242074927954, 'fraction_numerical': 0.012103746397694525, 'mean_word_length': 3.4443021766965427, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2996210', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1064, 'n_words': 345}