| Server IP : 217.160.0.135 / Your IP : 216.73.217.37 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/scipy/cluster/__pycache__/ |
Upload File : |
�
d�c�C � � � d Z ddlZddlZddlmZ ddlZddlmZm Z ddl
mc mZ ddl
mZ ddddd d
dd�Zd
Zg d�Z G d� de� � Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� ZdYd�Z G d � d!� � Z e d� � Z! e"e � � Z#d"� Z$dZd#�Z%d[d$�Z&d\d%�Z'd&� Z(d'� Z)d]d(�Z*d^d)�Z+d*� Z,d+� Z-d,� Z.d_d-�Z/d_d.�Z0d/� Z1d0� Z2d1� Z3d2� Z4d3� Z5d`d5�Z6 dad6�Z7d7� Z8d8d9d:d;d<d=d>dej9 d
iZ:d8dd?d@ej9 dAiZ; e<e:�= � � � � Z>e>�? � � e<e;�= � � � � Z@e@�? � � dB� ZAdC� ZBdD� ZC dbdF�ZDdGZE e<eE� � aFdH� ZG dcdK�ZHdL� ZIdM� ZJdN� ZKdO� ZLdP� ZMej9 dIdJdddddQdRg dg g ddg g g dddddEfdS�ZNdT� ZOdU� ZPdV� ZQdW� ZRdX� ZSdS )da]
Hierarchical clustering (:mod:`scipy.cluster.hierarchy`)
========================================================
.. currentmodule:: scipy.cluster.hierarchy
These functions cut hierarchical clusterings into flat clusterings
or find the roots of the forest formed by a cut by providing the flat
cluster ids of each observation.
.. autosummary::
:toctree: generated/
fcluster
fclusterdata
leaders
These are routines for agglomerative clustering.
.. autosummary::
:toctree: generated/
linkage
single
complete
average
weighted
centroid
median
ward
These routines compute statistics on hierarchies.
.. autosummary::
:toctree: generated/
cophenet
from_mlab_linkage
inconsistent
maxinconsts
maxdists
maxRstat
to_mlab_linkage
Routines for visualizing flat clusters.
.. autosummary::
:toctree: generated/
dendrogram
These are data structures and routines for representing hierarchies as
tree objects.
.. autosummary::
:toctree: generated/
ClusterNode
leaves_list
to_tree
cut_tree
optimal_leaf_ordering
These are predicates for checking the validity of linkage and
inconsistency matrices as well as for checking isomorphism of two
flat cluster assignments.
.. autosummary::
:toctree: generated/
is_valid_im
is_valid_linkage
is_isomorphic
is_monotonic
correspond
num_obs_linkage
Utility routines for plotting:
.. autosummary::
:toctree: generated/
set_link_color_palette
Utility classes:
.. autosummary::
:toctree: generated/
DisjointSet -- data structure for incremental connectivity queries
� N)�deque� )�
_hierarchy�_optimal_leaf_ordering)�DisjointSet� � � � � )�single�complete�average�centroid�median�ward�weighted)r r r ) �ClusterNoder r r r �cophenet�
correspond�cut_tree�
dendrogram�fcluster�fclusterdata�from_mlab_linkage�inconsistent�
is_isomorphic�is_monotonic�is_valid_im�is_valid_linkage�leaders�leaves_list�linkage�maxRstat�maxdists�maxinconstsr �num_obs_linkage�optimal_leaf_ordering�set_link_color_paletter
�to_mlab_linkage�to_treer r c � � e Zd ZdS )�ClusterWarningN)�__name__�
__module__�__qualname__� � �9/usr/lib/python3/dist-packages/scipy/cluster/hierarchy.pyr- r- � s � � � � � ��Dr2 r- c �D � t j d| z t d�� � d S )Nzscipy.cluster: %sr )�
stacklevel)�warnings�warnr- )�ss r3 �_warningr9 � s% � ��M�%��)�>�a�H�H�H�H�H�Hr2 c � � | j �| � � � S t j | t j � � r t j | t j �� � S | S )z>
Copy the array if its base points to a parent array.
N��dtype)�base�copy�np�issubsctype�float32�array�double)�as r3 �_copy_array_if_base_presentrE � sK � � �v���v�v�x�x�� ���2�:� &� &� ��x����+�+�+�+��r2 c � � d� | D � � }|S )z�
Accept a tuple of arrays T. Copies the array T[i] if its base array
points to an actual array. Otherwise, the reference is just copied.
This is useful if the arrays are being passed to a C function that
does not do proper striding.
c �, � g | ]}t |� � ��S r1 )rE )�.0rD s r3 �
<listcomp>z0_copy_arrays_if_base_present.<locals>.<listcomp>� s! � �3�3�3�A� $�Q� '� '�3�3�3r2 r1 )�T�ls r3 �_copy_arrays_if_base_presentrL � s � � 4�3��3�3�3�A��Hr2 c � � | dk r)t j � | | dz
z dz � � }nt d� � �|S )a%
Generate a random distance matrix stored in condensed form.
Parameters
----------
pnts : int
The number of points in the distance matrix. Has to be at least 2.
Returns
-------
D : ndarray
A ``pnts * (pnts - 1) / 2`` sized vector is returned.
r r z?The number of points in the distance matrix must be at least 2.)r? �random�rand�
ValueError)�pnts�Ds r3 �_randdmrS � sL � � �q�y�y��I�N�N�4�4�!�8�,�q�0�1�1���� /� 0� 0� 0��Hr2 c �&