<commit_before># -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2015 by Ecpy Authors, see AUTHORS for more details.
#
# Distributed under the terms of the BSD license.
#
# The full license is in the file LICENCE, distributed with this software.
# -----------------------------------------------------------------------------
"""Base classes for pulse sequences.

"""
from __future__ import (division, unicode_literals, print_function,
                        absolute_import)

from traceback import format_exc
from copy import deepcopy
from collections import Mapping
from numbers import Real

from atom.api import (Int, Instance, Unicode, Dict, Bool, List,
                      Signal, set_default, Typed)
from ecpy.utils.container_change import ContainerChange
from ecpy.utils.atom_util import (update_members_from_preferences)

from ..contexts.base_context import BaseContext
from ..utils.entry_eval import eval_entry, MissingLocalVars
from ..utils.validators import SkipEmpty
from ..item import Item
from ..pulse import Pulse


class AbstractSequence(Item):
    """ Base class for all sequences.

    This class defines the basic of a sequence but with only a very limited
    child support : only construction is supported, indexing is not handled
    nor is child insertion, deletion or displacement (This is because
    TemplateSequence inherits from AbstractSequence, while everything else
    inherits from BaseSequence which supports insertion/deletion/displacement).

    """

    #: Name of the sequence (help make a sequence more readable)
    name = Unicode().tag(pref=True)

    #: List of items this sequence consists of.
    items = List(Instance(Item)).tag(child=100)

    #: Signal emitted when the list of items in this sequence changes. The
    #: payload will be a ContainerChange instance.
    items_changed = Signal().tag(child_notifier='items')

    #: Dict of variables whose scope is limited to the sequence. Each key/value
    #: pair represents the name and definition of the variable.
    local_vars = Dict(Unicode()).tag(pref=True)

    #: String representing the item first element of definition : according
    #: to the selected mode it evaluated value will either be used for the
    #: start instant, or duration of the item.
    def_1 = Unicode().tag(pref=True, feval=SkipEmpty(types=Real))

    #: String representing the item second element of definition : according
    #: to the selected mode it evaluated value will either be used for the
    #: duration, or stop instant of the item.
    def_2 = Unicode().tag(pref=True, feval=SkipEmpty(types=Real))

    def clean_cached_values(self):
        """ Clear all internal caches.

        This should be called before evaluating a sequence.

        """
        super(AbstractSequence, self).clean_cached_values()
        self._evaluated = []
        for i in self.items:
            i.clean_cached_values()<commit_msg>pulses.sequences : fix local vars edition<commit_after># -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2015 by Ecpy Authors, see AUTHORS for more details.
#
# Distributed under the terms of the BSD license.
#
# The full license is in the file LICENCE, distributed with this software.
# -----------------------------------------------------------------------------
"""Base classes for pulse sequences.

"""
from __future__ import (division, unicode_literals, print_function,
                        absolute_import)

from traceback import format_exc
from copy import deepcopy
from collections import Mapping
from numbers import Real

from atom.api import (Int, Instance, Unicode, Dict, Bool, List,
                      Signal, set_default, Typed)
from ecpy.utils.container_change import ContainerChange
from ecpy.utils.atom_util import (update_members_from_preferences)

from ..contexts.base_context import BaseContext
from ..utils.entry_eval import eval_entry, MissingLocalVars
from ..utils.validators import SkipEmpty
from ..item import Item
from ..pulse import Pulse


class AbstractSequence(Item):
    """ Base class for all sequences.

    This class defines the basic of a sequence but with only a very limited
    child support : only construction is supported, indexing is not handled
    nor is child insertion, deletion or displacement (This is because
    TemplateSequence inherits from AbstractSequence, while everything else
    inherits from BaseSequence which supports insertion/deletion/displacement).

    """

    #: Name of the sequence (help make a sequence more readable)
    name = Unicode().tag(pref=True)

    #: List of items this sequence consists of.
    items = List(Instance(Item)).tag(child=100)

    #: Signal emitted when the list of items in this sequence changes. The
    #: payload will be a ContainerChange instance.
    items_changed = Signal().tag(child_notifier='items')

    #: Dict of variables whose scope is limited to the sequence. Each key/value
    #: pair represents the name and definition of the variable.
    local_vars = Dict().tag(pref=True)

    #: String representing the item first element of definition : according
    #: to the selected mode it evaluated value will either be used for the
    #: start instant, or duration of the item.
    def_1 = Unicode().tag(pref=True, feval=SkipEmpty(types=Real))

    #: String representing the item second element of definition : according
    #: to the selected mode it evaluated value will either be used for the
    #: duration, or stop instant of the item.
    def_2 = Unicode().tag(pref=True, feval=SkipEmpty(types=Real))

    def clean_cached_values(self):
        """ Clear all internal caches.

        This should be called before evaluating a sequence.

        """
        super(AbstractSequence, self).clean_cached_values()
        self._evaluated = []
        for i in self.items:
            i.clean_cached_values()
{'fraction_non_alphanumeric': 0.12129334896967667, 'fraction_numerical': 0.0033506449991623386, 'mean_word_length': 2.829377806286081, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6532171', 'n_tokens_mistral': 1510, 'n_tokens_neox': 1405, 'n_words': 615}