
    phV
                     ^    S r SSKrSSKJr  SSKJr  S rS r " S S\R                  5      r	g)	z4
Helper class representing labels of network nodes.
    N)validate)cmpc                 $    SR                  U 5      $ )zDefault label for a node.zn{})format)indexs    F/home/james-whalen/.local/lib/python3.13/site-packages/pyphi/labels.pydefault_labelr	      s    <<    c                 &    [        S U  5       5      $ )z"Default labels for serveral nodes.c              3   8   #    U  H  n[        U5      v   M     g 7fN)r	   ).0is     r   	<genexpr>!default_labels.<locals>.<genexpr>   s     37aq!!7s   tuple)indicess    r   default_labelsr      s    37333r
   c                   ~    \ rS rSrSrS rS rS rS rS r	S r
\R                  S	 5       rS
 rS rS rS rS rSrg)
NodeLabels   a  Text labels for nodes in a network.

Labels can either be instantiated as a tuple of strings:

    >>> NodeLabels(('A', 'IN'), (0, 1))
    NodeLabels(('A', 'IN'))

Or, if all labels are a single character, as a string:

    >>> NodeLabels('AB', (0, 1))
    NodeLabels(('A', 'B'))
c                 T   Uc  [        U5      n[        S U 5       5      U l        X l        [        R
                  " U R                  U5        [        [        U R                  U R                  5      5      U l        [        [        U R                  U R                  5      5      U l	        g )Nc              3   $   #    U  H  ov   M     g 7fr    )r   labels     r   r   &NodeLabels.__init__.<locals>.<genexpr>*   s     6veEvs   )
r   r   labelsnode_indicesr   node_labelsdictzip_l2i_i2l)selfr   r   s      r   __init__NodeLabels.__init__&   sy    >#L1F6v66(T[[,7 T[[$*;*;<=	T..<=	r
   c                 ,    [        U R                  5      $ r   )lenr   r%   s    r   __len__NodeLabels.__len__3   s    4;;r
   c                 ,    [        U R                  5      $ r   )iterr   r*   s    r   __iter__NodeLabels.__iter__6   s    DKK  r
   c                     XR                   ;   $ r   r   r%   xs     r   __contains__NodeLabels.__contains__9   s    KKr
   c                      U R                   U   $ r   r2   r3   s     r   __getitem__NodeLabels.__getitem__<   s    {{1~r
   c                 8    SR                  U R                  5      $ )NzNodeLabels({}))r   r   r*   s    r   __repr__NodeLabels.__repr__?   s    &&t{{33r
   c                 t    U R                   UR                   :H  =(       a    U R                  UR                  :H  $ r   r   r   )r%   others     r   __eq__NodeLabels.__eq__B   s0    u||+ 8!!U%7%77	9r
   c                 D    [        U R                  U R                  45      $ r   )hashr   r   r*   s    r   __hash__NodeLabels.__hash__G   s    T[[$"3"3455r
   c                 .   ^  [        U 4S jU 5       5      $ )z/Convert a tuple of node labels to node indices.c              3   B   >#    U  H  nTR                   U   v   M     g 7fr   )r#   )r   r   r%   s     r   r   ,NodeLabels.labels2indices.<locals>.<genexpr>L   s     :6%TYYu%6   r   )r%   r   s   ` r   labels2indicesNodeLabels.labels2indicesJ   s    :6:::r
   c                 .   ^  [        U 4S jU 5       5      $ )z/Convert a tuple of node indices to node labels.c              3   B   >#    U  H  nTR                   U   v   M     g 7fr   )r$   )r   r   r%   s     r   r   ,NodeLabels.indices2labels.<locals>.<genexpr>P   s     ;7%TYYu%7rI   r   )r%   r   s   ` r   indices2labelsNodeLabels.indices2labelsN   s    ;7;;;r
   c                     Uc  U R                   $ [        S U 5       5      (       a  U R                  U5      nO[        [        U5      n[        [        [        U5      5      5      $ )zfReturn the nodes indices for nodes, where ``nodes`` is either
already integer indices or node labels.
c              3   B   #    U  H  n[        U[        5      v   M     g 7fr   )
isinstancestr)r   nodes     r   r   /NodeLabels.coerce_to_indices.<locals>.<genexpr>Y   s     7z$$$s   )r   allrJ   mapintr   sortedset)r%   nodesr   s      r   coerce_to_indicesNodeLabels.coerce_to_indicesR   sU     =$$$7777))%0G#uoGVCL)**r
   c                 4    U R                   U R                  S.$ )Nr>   r>   r*   s    r   to_jsonNodeLabels.to_json_   s    ++t7H7HIIr
   )r$   r#   r   r   N)__name__
__module____qualname____firstlineno____doc__r&   r+   r/   r5   r8   r;   r   sametyper@   rD   rJ   rO   r]   r`   __static_attributes__r   r
   r   r   r      sW    > ! 4 	\\9 96;<+Jr
   r   )
rf   collectionspyphir   pyphi.modelsr   r	   r   Sequencer   r   r
   r   <module>rm      s5   
   
4
GJ%% GJr
   