<commit_before># Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.

"""Abstract Base Classes (ABCs) for numbers, according to PEP 3141.

TODO: Fill out more detailed documentation on the operators."""

from __future__ import division
from abc import ABCMeta, abstractmethod, abstractproperty

__all__ = ["Number", "Exact", "Inexact",
           "Complex", "Real", "Rational", "Integral",
           ]


class Number(object):
    """All numbers inherit from this class.

    If you just want to check if an argument x is a number, without
    caring what kind, use isinstance(x, Number).
    """
    __metaclass__ = ABCMeta


class Exact(Number):
    """Operations on instances of this type are exact.

    As long as the result of a homogenous operation is of the same
    type, you can assume that it was computed exactly, and there are
    no round-off errors. Laws like commutativity and associativity
    hold.
    """

Exact.register(int)
Exact.register(long)


class Inexact(Number):
    """Operations on instances of this type are inexact.

    Given X, an instance of Inexact, it is possible that (X + -X) + 3
    == 3, but X + (-X + 3) == 0. The exact form this error takes will
    vary by type, but it's generally unsafe to compare this type for
    equality.
    """

Inexact.register(complex)
Inexact.register(float)
# Inexact.register(decimal.Decimal)


## Notes on Decimal and how relates to the numeric tower
## -----------------------------------------------------
## Decimal is Real except that it does not support the real and imag properties
## or the conjugate() and complex() methods.  If those get defined at some
## point, they cannot use the default implementation which would be sensitive
## to decimal.Context and could produce different answers at different times.
##
## Decimal has some of the characteristics of Integrals.  It provides
## logical operations but not as operators.  The logical operations only apply
## to a subset of decimals (those that are non-negative, have a zero exponent,
## and have digits that are only 0 or 1).  It does provide __long__() and
## a three argument form of __pow__ that includes exactness guarantees.
## It does not provide an __index__() method.
##
## Depending on context, decimal operations may be exact or inexact.
##
## When decimal is run in a context with small precision and automatic rounding,
## it is Inexact.  See the "Floating point notes" section of the decimal docs
## for an example of losing the associative and distributive properties of
## addition.
##
## When decimal is used for high precision integer arithmetic, it is Exact.
## When the decimal used as fixed-point, it is Exact.
## When it is run with sufficient precision, it is Exact.
## When the decimal.Inexact trap is set, decimal operations are Exact.
## For an example, see the float_to_decimal() recipe in the "Decimal FAQ"
## section of the docs -- it shows an how traps are used in conjunction
## with variable precision to reliably achieve exact results.
<commit_msg>Fix typo in comments<commit_after># Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.

"""Abstract Base Classes (ABCs) for numbers, according to PEP 3141.

TODO: Fill out more detailed documentation on the operators."""

from __future__ import division
from abc import ABCMeta, abstractmethod, abstractproperty

__all__ = ["Number", "Exact", "Inexact",
           "Complex", "Real", "Rational", "Integral",
           ]


class Number(object):
    """All numbers inherit from this class.

    If you just want to check if an argument x is a number, without
    caring what kind, use isinstance(x, Number).
    """
    __metaclass__ = ABCMeta


class Exact(Number):
    """Operations on instances of this type are exact.

    As long as the result of a homogenous operation is of the same
    type, you can assume that it was computed exactly, and there are
    no round-off errors. Laws like commutativity and associativity
    hold.
    """

Exact.register(int)
Exact.register(long)


class Inexact(Number):
    """Operations on instances of this type are inexact.

    Given X, an instance of Inexact, it is possible that (X + -X) + 3
    == 3, but X + (-X + 3) == 0. The exact form this error takes will
    vary by type, but it's generally unsafe to compare this type for
    equality.
    """

Inexact.register(complex)
Inexact.register(float)
# Inexact.register(decimal.Decimal)


## Notes on Decimal and it how relates to the numeric tower
## --------------------------------------------------------
## Decimal is Real except that it does not support the real and imag properties
## or the conjugate() and complex() methods.  If those get defined at some
## point, they cannot use the default implementation which would be sensitive
## to decimal.Context and could produce different answers at different times.
##
## Decimal has some of the characteristics of Integrals.  It provides
## logical operations but not as operators.  The logical operations only apply
## to a subset of decimals (those that are non-negative, have a zero exponent,
## and have digits that are only 0 or 1).  It does provide __long__() and
## a three argument form of __pow__ that includes exactness guarantees.
## It does not provide an __index__() method.
##
## Depending on context, decimal operations may be exact or inexact.
##
## When decimal is run in a context with small precision and automatic rounding,
## it is Inexact.  See the "Floating point notes" section of the decimal docs
## for an example of losing the associative and distributive properties of
## addition.
##
## When decimal is used for high precision integer arithmetic, it is Exact.
## When the decimal used as fixed-point, it is Exact.
## When it is run with sufficient precision, it is Exact.
## When the decimal.Inexact trap is set, decimal operations are Exact.
## For an example, see the float_to_decimal() recipe in the "Decimal FAQ"
## section of the docs -- it shows an how traps are used in conjunction
## with variable precision to reliably achieve exact results.

{'fraction_non_alphanumeric': 0.09253537160513904, 'fraction_numerical': 0.004553585948934786, 'mean_word_length': 3.528718703976436, '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': '2042019', 'n_tokens_mistral': 1652, 'n_tokens_neox': 1561, 'n_words': 852}