Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_statistics.cpython-311.pyc |
�
�Ke� � �B � d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZddlZddl
mZ ddlmZmZ ddlmZ ddlmZ ddlZd� Zd� Zd � Zdzd�Z G d
� d� � Z ej ddg�� � Z ej ddg�� � Z G d� dej � � Z G d� dej � � Z G d� dej � � Z! G d� dej � � Z" G d� dej � � Z# G d� dej � � Z$ G d� d ej � � Z% G d!� d"ej � � Z& G d#� d$ej � � Z' G d%� d&ej � � Z( G d'� d(ej � � Z) G d)� d*ej � � Z* G d+� d,ej � � Z+ G d-� d.ej � � Z, G d/� d0ej � � Z- G d1� d2ej � � Z. G d3� d4ej � � Z/ G d5� d6ej � � Z0 G d7� d8ej � � Z1 G d9� d:� � Z2 G d;� d<� � Z3 G d=� d>e2e3� � Z4 G d?� d@e � � Z5 G dA� dBe � � Z6 G dC� dDe � � Z7 G dE� dFe2� � Z8 G dG� dHe e8e3� � Z9 G dI� dJe e8e3� � Z: G dK� dLe e8� � Z; G dM� dNe e3� � Z< G dO� dPe;e3� � Z= G dQ� dRe;e3� � Z> G dS� dTe;� � Z? G dU� dVe e8e3� � Z@ G dW� dXej � � ZA G dY� dZej � � ZB G d[� d\e2� � ZC G d]� d^eCe e3� � ZD G d_� d`eCe e3� � ZE G da� dbeCe � � ZF G dc� ddej � � ZG G de� dfeCe � � ZH G dg� dhej � � ZI G di� djej � � ZJ G dk� dlej � � ZK G dm� dnej � � ZL G do� dpej � � ZM G dq� dr� � ZN G ds� dtej eN� � ZO ejP edu� � G dv� dwej eN� � � � ZQdx� ZReSdyk r ejT � � dS dS ){z_Test suite for statistics module, including helper NumericTestCase and
approx_equal function.
� N)�support)�
import_helper�requires_IEEE_754)�Decimal��Fractionc �, � t j d| � � S )z:Return -1.0 for negatives, including -0.0, otherwise +1.0.� )�math�copysign��xs �>/usr/local/apps/python3/lib/python3.11/test/test_statistics.py�signr s � ��=��A���� c �8 � t | � � t |� � urdS t | t � � r(t j | � � ot j |� � S | � � � d }|� � � d }||k o|dv S )a� Return True if a and b are both the same kind of NAN.
>>> _nan_equal(Decimal('NAN'), Decimal('NAN'))
True
>>> _nan_equal(Decimal('sNAN'), Decimal('sNAN'))
True
>>> _nan_equal(Decimal('NAN'), Decimal('sNAN'))
False
>>> _nan_equal(Decimal(42), Decimal('NAN'))
False
>>> _nan_equal(float('NAN'), float('NAN'))
True
>>> _nan_equal(float('NAN'), 0.5)
False
>>> _nan_equal(float('NAN'), Decimal('NAN'))
False
NAN payloads are not compared.
F� )�n�N)�type�
isinstance�floatr �isnan�as_tuple)�a�b�aexp�bexps r �
_nan_equalr # s� � �, �A�w�w�d�1�g�g����u��!�U��� /��z�!�}�}�.���A���.��:�:�<�<��?�D��:�:�<�<��?�D��D�L�2�t�z�1�2r c � � t t | � � t |� � � � }t | |z
� � }|r||z nt d� � }||fS )z�Return the absolute and relative errors between two numbers.
>>> _calc_errors(100, 75)
(25, 0.25)
>>> _calc_errors(100, 100)
(0, 0.0)
Returns the (absolute error, relative error) between the two arguments.
�inf)�max�absr )�actual�expected�base�abs_err�rel_errs r �_calc_errorsr) B sT � � �s�6�{�{�C��M�M�*�*�D��&�8�#�$�$�G�"�4�g�d�l�l��e���G��W��r ��-���q=�H�����z>c
� � |dk s|dk rt d� � �t j | � � st j |� � rdS | |k rdS t j | � � st j |� � rdS t | |z
� � }t ||t t | � � t |� � � � z � � }||k S )a� approx_equal(x, y [, tol [, rel]]) => True|False
Return True if numbers x and y are approximately equal, to within some
margin of error, otherwise return False. Numbers which compare equal
will also compare approximately equal.
x is approximately equal to y if the difference between them is less than
an absolute error tol or a relative error rel, whichever is bigger.
If given, both tol and rel must be finite, non-negative numbers. If not
given, default values are tol=1e-12 and rel=1e-7.
>>> approx_equal(1.2589, 1.2587, tol=0.0003, rel=0)
True
>>> approx_equal(1.2589, 1.2587, tol=0.0001, rel=0)
False
Absolute error is defined as abs(x-y); if that is less than or equal to
tol, x and y are considered approximately equal.
Relative error is defined as abs((x-y)/x) or abs((x-y)/y), whichever is
smaller, provided x or y are not zero. If that figure is less than or
equal to rel, x and y are considered approximately equal.
Complex numbers are not directly supported. If you wish to compare to
complex numbers, extract their real and imaginary parts and compare them
individually.
NANs always compare unequal, even with themselves. Infinities compare
approximately equal if they have the same sign (both positive or both
negative). Infinities with different signs compare unequal; so do
comparisons of infinities with finite numbers.
r z%error tolerances must be non-negativeFT)�
ValueErrorr r �isinfr# r"