File: //usr/local/lib/python3.7/test/__pycache__/test_statistics.cpython-37.pyc
B
��gc) � @ sT d Z ddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl
mZ ddlZdd� Z
dd� Zd d
� Zd`d
d�ZG dd� d�ZG dd� dej�ZG dd� dej�ZG dd� dej�ZG dd� dej�ZG dd� dej�ZG dd� dej�ZG dd� dej�ZG dd � d ej�ZG d!d"� d"ej�ZG d#d$� d$ej�ZG d%d&� d&ej�ZG d'd(� d(ej�ZG d)d*� d*ej�ZG d+d,� d,ej�Z G d-d.� d.ej�Z!G d/d0� d0ej�Z"G d1d2� d2ej�Z#G d3d4� d4ej�Z$G d5d6� d6�Z%G d7d8� d8�Z&G d9d:� d:e%e&�Z'G d;d<� d<e�Z(G d=d>� d>e�Z)G d?d@� d@e�Z*G dAdB� dBe%�Z+G dCdD� dDee+e&�Z,G dEdF� dFee+e&�Z-G dGdH� dHee+�Z.G dIdJ� dJee&�Z/G dKdL� dLe.e&�Z0G dMdN� dNe.e&�Z1G dOdP� dPe.�Z2G dQdR� dRee+e&�Z3G dSdT� dTe%�Z4G dUdV� dVe4ee&�Z5G dWdX� dXe4ee&�Z6G dYdZ� dZe4e�Z7G d[d\� d\e4e�Z8d]d^� Z9e:d_k�rPe�;� dS )az_Test suite for statistics module, including helper NumericTestCase and
approx_equal function.
� N)�Decimal)�Fractionc C s t �d| �S )z:Return -1.0 for negatives, including -0.0, otherwise +1.0.� )�math�copysign)�x� r �0/usr/local/lib/python3.7/test/test_statistics.py�sign s r
c C sZ t | �t |�k rdS t| t�r2t�| �o0t�|�S | �� d }|�� d }||koX|dkS )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 �isnanZas_tuple)�a�bZaexpZbexpr r r �
_nan_equal s
r c C s: t t| �t|��}t| | �}|r*|| ntd�}||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_errr r r �_calc_errors<