
    qiz                         d dl mZmZmZmZ d dlmZ g dZd Z	d Z
d Zd Z eee      d        Zd	 Z eeee      d
        Zy)   )_reify_unifyreifyunify)dispatch)	unifiablereify_objectunify_objectc                     t        j                  | | t        ft               t	        j                  | t        ft
               | S )a  Register standard unify and reify operations on class
    This uses the type and __dict__ or __slots__ attributes to define the
    nature of the term
    See Also:
    >>> # xdoctest: +SKIP
    >>> class A(object):
    ...     def __init__(self, a, b):
    ...         self.a = a
    ...         self.b = b
    >>> unifiable(A)
    <class 'unification.more.A'>
    >>> x = var("x")
    >>> a = A(1, 2)
    >>> b = A(1, x)
    >>> unify(a, b, {})
    {~x: 2}
    )
core_unifyadddictr
   
core_reifyr	   )clss    l/home/ubuntu/crypto_trading_bot/.venv/lib/python3.12/site-packages/torch/fx/experimental/unification/more.pyr   r      s0    $ NNCd#\2NNC;-J    c                 J    t        | d      rt        | |      S t        | |      S )a  Reify a Python object with a substitution
    >>> # xdoctest: +SKIP
    >>> class Foo(object):
    ...     def __init__(self, a, b):
    ...         self.a = a
    ...         self.b = b
    ...
    ...     def __str__(self):
    ...         return "Foo(%s, %s)" % (str(self.a), str(self.b))
    >>> x = var("x")
    >>> f = Foo(1, x)
    >>> print(f)
    Foo(1, ~x)
    >>> print(reify_object(f, {x: 2}))
    Foo(1, 2)
    	__slots__)hasattr_reify_object_slots_reify_object_dictoss     r   r	   r	   +   s(    " q+"1a((!!Q''r   c                     t         j                  t        |             }t        | j                  |      }|| j                  k(  r| S |j                  j                  |       |S N)object__new__typer   __dict__update)r   r   objds       r   r   r   B   sK    
..a
!Cajj!AAJJLLJr   c                    | j                   D cg c]  }t        | |       }}t        ||      }||k(  r| S t        j	                  t        |             }t        | j                   |      D ]  \  }}t        |||        |S c c}w r   )r   getattrr   r   r   r   zipsetattr)r   r   attrattrs	new_attrsnewobjslots          r   r   r   K   s~    *+++6$WQ6E6eQI	Q(akk95 	(JD$FD$'	( 7s   Bc                 h    t        t        | j                  | j                  | j                  f|       S )zReify a Python ``slice`` object)slicer   startstopstepr   s     r   r   r   W   s)     %!&&!&&11566r   c           
      @   t        |       t        |      uryt        | d      rQt        | j                  D cg c]  }t	        | |       c}|j                  D cg c]  }t	        ||       c}|      S t        | j
                  |j
                  |      S c c}w c c}w )a  Unify two Python objects
    Unifies their type and ``__dict__`` attributes
    >>> # xdoctest: +SKIP
    >>> class Foo(object):
    ...     def __init__(self, a, b):
    ...         self.a = a
    ...         self.b = b
    ...
    ...     def __str__(self):
    ...         return "Foo(%s, %s)" % (str(self.a), str(self.b))
    >>> x = var("x")
    >>> f = Foo(1, x)
    >>> g = Foo(1, 2)
    >>> unify_object(f, g, {})
    {~x: 2}
    Fr   )r   r   r   r   r%   r    )uvr   r,   s       r   r
   r
   c   s    " Awd1gq+*+++6$WQ6*+++6$WQ6
 	
 QZZQ// 76s   BB
c                     t        | j                  | j                  | j                  f|j                  |j                  |j                  f|      S )zUnify a Python ``slice`` object)r   r/   r0   r1   )r3   r4   r   s      r   r   r      s9     !''166166*QWWaffaff,EqIIr   N)corer   r   r   r   r   r   r   __all__r   r	   r   r   r.   r   r
    r   r   <module>r9      sn      8:(.	 
%7 70: 
%J Jr   