
     i                         d dl mZ ddlmZmZ ddlmZmZ  G d d          Z G d d          Z	 G d	 d
          Z
 G d d          Z G d d          Z G d d          Z G d d          ZdS )    )
converters   )delta_decoderun_length_decode)delta_encoderun_length_encodec                   >    e Zd ZdZed             Zed             ZdS )DeltaRecursiveFloatzCovert an array of floats to integers, perform delta
    encoding and then use recursive indexing to store as 2
    byte integers in a byte array.c           
          t          j        t          t          j        t          j        | d                              |          S N   )r   convert_ints_to_floatsr   recursive_index_decodeconvert_bytes_to_intsin_arrayparams     \/srv/www/vhosts/g4struct/public_html/venv/lib/python3.11/site-packages/mmtf/codecs/codecs.pydecodezDeltaRecursiveFloat.decode	   sN    014Xa@@B BC CCHJ J 	J    c           
          t          j        t          j        t          t          j        | |                              d          S r   )r   convert_ints_to_bytesrecursive_index_encoder   convert_floats_to_intsr   s     r   encodezDeltaRecursiveFloat.encode   sN    /-5huEEG GH HHIK K 	Kr   N__name__
__module____qualname____doc__staticmethodr   r    r   r   r
   r
      s\        & & J J \J
 K K \K K Kr   r
   c                   >    e Zd ZdZed             Zed             ZdS )RunLengthFloatz|Covert an array of floats to integers, perform run-length
    encoding and then store as four byte integers in a byte array.c                 l    t          j        t          t          j        | d                    |          S N   )r   r   r   r   r   s     r   r   zRunLengthFloat.decode   s<    0!4Xa@@B BBGI I 	Ir   c                 l    t          j        t          t          j        | |                    d          S r&   )r   r   r   r   r   s     r   r   zRunLengthFloat.encode   s<    /1(5AAC CCDF F 	Fr   Nr   r"   r   r   r$   r$      s\        F FI I \I F F \F F Fr   r$   c                   >    e Zd ZdZed             Zed             ZdS )RunLengthDeltaIntzDelta encode an array of integers and then perform run-length
    encoding on this and then store as four byte integers in a byte array.c                 `    t          t          t          j        | d                              S r&   )r   r   r   r   r   s     r   r   zRunLengthDeltaInt.decode'   s4    01==? ?@ @ 	@r   c                 `    t          j        t          t          |                     d          S r&   )r   r   r   r   r   s     r   r   zRunLengthDeltaInt.encode,   s2    /X&&( (()+ + 	+r   Nr   r"   r   r   r*   r*   $   sW        N N@ @ \@ + + \+ + +r   r*   c                   >    e Zd ZdZed             Zed             ZdS )RunLengthCharzpConvert chars to integers and run-length encoode these and then store as
    four byte integers in a byte array.c                 j    t          j        t          t          j        | d                              S r&   )r   convert_ints_to_charsr   r   r   s     r   r   zRunLengthChar.decode5   s7    /01==? ?@ @ 	@r   c                 j    t          j        t          t          j        |                     d          S r&   )r   r   r   convert_chars_to_intsr   s     r   r   zRunLengthChar.encode:   s5    /0::< <<=? ? 	?r   Nr   r"   r   r   r.   r.   2   sU        + +@ @ \@ ? ? \? ? ?r   r.   c                   >    e Zd ZdZed             Zed             ZdS )EncodeStringzConvert strings to set length byte arrays (in this case four). If
    a string is of lenght less than four a null byte is used instead.c                 *    t          j        |           S N)r   decode_chain_listr   s     r   r   zEncodeString.decodeC       +H555r   c                 *    t          j        |           S r6   )r   encode_chain_listr   s     r   r   zEncodeString.encodeF   r8   r   Nr   r"   r   r   r4   r4   @   sR        I I6 6 \66 6 \6 6 6r   r4   c                   >    e Zd ZdZed             Zed             ZdS )	ByteToIntz9Convert integers to single bytes and store in byte array.c                 ,    t          j        | d          S Nr   r   r   r   s     r   r   zByteToInt.decodeM       /!<<<r   c                 ,    t          j        | d          S r>   r   r   r   s     r   r   zByteToInt.encodeP   s    /;;;r   Nr   r"   r   r   r<   r<   K   sL        CC= = \=< < \< < <r   r<   c                   >    e Zd ZdZed             Zed             ZdS )FourByteToIntz7Convert integers to four bytes and store in byte array.c                 ,    t          j        | d          S r&   r?   r   s     r   r   zFourByteToInt.decodeW   r@   r   c                 ,    t          j        | d          S r&   rB   r   s     r   r   zFourByteToInt.encodeZ   r@   r   Nr   r"   r   r   rD   rD   U   sL        AA= = \== = \= = =r   rD   N)mmtfr   decodersr   r   encodersr   r   r
   r$   r*   r.   r4   r<   rD   r"   r   r   <module>rJ      sy         4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4K K K K K K K K"F F F F F F F F+ + + + + + + +? ? ? ? ? ? ? ?6 6 6 6 6 6 6 6< < < < < < < <= = = = = = = = = =r   