<commit_before>"""Symbolic configuration API."""
from __future__ import absolute_import as _abs
import sys as _sys
import os as _os
import ctypes as _ctypes

from numbers import Number as _Number
from . import _base
from ._base import _LIB, check_call as _check_call
from . import _symbol_internal as _internal
from .attribute import AttrScope

# Use different verison of SymbolBase
# When possible, use cython to speedup part of computation.

try:
    if int(_os.environ.get("MXNET_ENABLE_CYTHON", True)) == 0:
        from ._ctypes.symbol import SymbolBase,  _init_symbol_module
    elif _sys.version_info >= (3, 0):
        from ._cy3.symbol import SymbolBase,  _init_symbol_module
    else:
        from ._cy2.symbol import SymbolBase,  _init_symbol_module
except ImportError:
    from ._ctypes.symbol import SymbolBase,  _init_symbol_module


class Symbol(SymbolBase):
    """Symbol is basic operation unit for symbolic graph compostion."""
    # disable dictionary storage, also do not have parent type.
    __slots__ = []

    def __add__(self, other):
        if isinstance(other, Symbol):
            return _internal.__add_symbol__(self, other)
        elif isinstance(other, _Number):
            return _internal.__add_scalar__(self, scalar=other)
        else:
            raise TypeError("type %s not supported" % str(type(other)))

    def __radd__(self, other):
        return self.__add__(other)

    def __sub__(self, other):
        if isinstance(other, Symbol):
            return _internal.__sub_symbol__(self, other)
        if isinstance(other, Number):
            return _internal.__sub_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __rsub__(self, other):
        if isinstance(other, Number):
            return _internal.__rsub_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __mul__(self, other):
        if isinstance(other, Symbol):
            return _internal.__mul_symbol__(self, other)
        if isinstance(other, _Number):
            return _internal.__mul_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __rmul__(self, other):
        return self.__mul__(other)

    def __div__(self, other):
        if isinstance(other, Symbol):
            return _internal.__div_symbol__(self, other)
        if isinstance(other, Number):
            return _internal.__div_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __rdiv__(self, other):
        if isinstance(other, Number):
            return _internal.__rdiv_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __truediv__(self, other):
        return self.__div__(other)

    def __rtruediv__(self, other):
        return self.__rdiv__(other)

    def __pow__(self, other):
        if isinstance(other, Symbol):
            return _internal.__pow_symbol__(self, other)
        if isinstance(other, Number):
            return _internal.__pow_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __neg__(self):
        return self.__mul__(-1.0)<commit_msg>add rpow & fix 'Number' to 'Number_' (#76)<commit_after>"""Symbolic configuration API."""
from __future__ import absolute_import as _abs
import sys as _sys
import os as _os
import ctypes as _ctypes

from numbers import Number as _Number
from . import _base
from ._base import _LIB, check_call as _check_call
from . import _symbol_internal as _internal
from .attribute import AttrScope

# Use different verison of SymbolBase
# When possible, use cython to speedup part of computation.

try:
    if int(_os.environ.get("MXNET_ENABLE_CYTHON", True)) == 0:
        from ._ctypes.symbol import SymbolBase,  _init_symbol_module
    elif _sys.version_info >= (3, 0):
        from ._cy3.symbol import SymbolBase,  _init_symbol_module
    else:
        from ._cy2.symbol import SymbolBase,  _init_symbol_module
except ImportError:
    from ._ctypes.symbol import SymbolBase,  _init_symbol_module


class Symbol(SymbolBase):
    """Symbol is basic operation unit for symbolic graph compostion."""
    # disable dictionary storage, also do not have parent type.
    __slots__ = []

    def __add__(self, other):
        if isinstance(other, Symbol):
            return _internal.__add_symbol__(self, other)
        elif isinstance(other, _Number):
            return _internal.__add_scalar__(self, scalar=other)
        else:
            raise TypeError("type %s not supported" % str(type(other)))

    def __radd__(self, other):
        return self.__add__(other)

    def __sub__(self, other):
        if isinstance(other, Symbol):
            return _internal.__sub_symbol__(self, other)
        if isinstance(other, _Number):
            return _internal.__sub_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __rsub__(self, other):
        if isinstance(other, _Number):
            return _internal.__rsub_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __mul__(self, other):
        if isinstance(other, Symbol):
            return _internal.__mul_symbol__(self, other)
        if isinstance(other, _Number):
            return _internal.__mul_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __rmul__(self, other):
        return self.__mul__(other)

    def __div__(self, other):
        if isinstance(other, Symbol):
            return _internal.__div_symbol__(self, other)
        if isinstance(other, _Number):
            return _internal.__div_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __rdiv__(self, other):
        if isinstance(other, _Number):
            return _internal.__rdiv_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __truediv__(self, other):
        return self.__div__(other)

    def __rtruediv__(self, other):
        return self.__rdiv__(other)

    def __pow__(self, other):
        if isinstance(other, Symbol):
            return _internal.__pow_symbol__(self, other)
        if isinstance(other, _Number):
            return _internal.__pow_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __rpow__(self, other):
        if isinstance(other, _Number):
            return _internal.__rpow_scalar__(self, scalar=other)
        else:
            raise TypeError('type %s not supported' % str(type(other)))

    def __neg__(self):
        return self.__mul__(-1.0)
{'fraction_non_alphanumeric': 0.09351904491188175, 'fraction_numerical': 0.0022740193291642978, 'mean_word_length': 2.8728673637864612, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7209907', 'n_tokens_mistral': 1979, 'n_tokens_neox': 1951, 'n_words': 579}