<commit_before>"""
This recreates @stuwilkins' scan api from ophyd using the bluesky message API.
All of these are deprecated. See bluesky/scans.py for new versions.
"""


import warnings
from .scans import LinDscan, LinAscan, Count

def _deprecation_warning(replacement):
    warnings.warn("ascan is deprecated, and it does not provide "
                  "the latest functionality. Use %s instead." % replacement,
                  UserWarning)


class _LegacyScan:
    _shared_config = {'default_detectors': [],
                      'detectors': []}

    @property
    def default_detectors(self):
        return self._shared_config['default_detectors']

    @default_detectors.setter
    def default_detectors(self, val):
        self._shared_config['default_detectors'] = val

    @property
    def detectors(self):
        return self._shared_config['detectors']

    @detectors.setter
    def detectors(self, val):
        self._shared_config['detectors'] = val

    def __init__(self, RE):
        self.RE = RE

    def _run(self, curried):
        dets = set(self.detectors) | set(self.default_detectors)
        self.RE(curried(dets))


class LegacyAscan(_LegacyScan):
    def __call__(self, motor, start, stop, num):
        _deprecation_warning('LinAscan')
        curried = lambda dets: LinAscan(motor, dets, start, stop, num)
        super()._run(curried)


class LegacyDscan(_LegacyScan):
    def __call__(self, motor, start, stop, num):
        _deprecation_warning('LinDscan')
        dets = set(self.detectors) | set(self.default_detectors)
        curried = lambda dets: LinDscan(motor, dets, start, stop, num)
        super()._run(curried)


class LegacyCount(_LegacyScan):
    def __call__(self):
        _deprecation_warning('Count')
        curried = lambda dets: Count(dets)
        super()._run(curried)<commit_msg>FIX: Deprecation message had 'ascan' hard-coded.<commit_after>"""
This recreates @stuwilkins' scan api from ophyd using the bluesky message API.
All of these are deprecated. See bluesky/scans.py for new versions.
"""


import warnings
from .scans import LinDscan, LinAscan, Count

def _deprecation_warning(old, new):
    warnings.warn("{old} is deprecated, and it does not provide "
                  "the latest functionality. Use {new} instead.".format(
                      old=old, new=new),
                  UserWarning)


class _LegacyScan:
    _shared_config = {'default_detectors': [],
                      'detectors': []}

    @property
    def default_detectors(self):
        return self._shared_config['default_detectors']

    @default_detectors.setter
    def default_detectors(self, val):
        self._shared_config['default_detectors'] = val

    @property
    def detectors(self):
        return self._shared_config['detectors']

    @detectors.setter
    def detectors(self, val):
        self._shared_config['detectors'] = val

    def __init__(self, RE):
        self.RE = RE

    def _run(self, curried):
        dets = set(self.detectors) | set(self.default_detectors)
        self.RE(curried(dets))


class LegacyAscan(_LegacyScan):
    def __call__(self, motor, start, stop, num):
        _deprecation_warning('ascan', 'LinAscan')
        curried = lambda dets: LinAscan(motor, dets, start, stop, num)
        super()._run(curried)


class LegacyDscan(_LegacyScan):
    def __call__(self, motor, start, stop, num):
        _deprecation_warning('dscan', 'LinDscan')
        dets = set(self.detectors) | set(self.default_detectors)
        curried = lambda dets: LinDscan(motor, dets, start, stop, num)
        super()._run(curried)


class LegacyCount(_LegacyScan):
    def __call__(self):
        _deprecation_warning('ct', 'Count')
        curried = lambda dets: Count(dets)
        super()._run(curried)
{'fraction_non_alphanumeric': 0.10993377483443709, 'fraction_numerical': 0.0, 'mean_word_length': 3.0645855758880516, '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': '4476092', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1150, 'n_words': 283}