a :jgã@s¬dZddlmZdd„Zdd„ZGdd„deƒZeGd d „d eƒƒZeGd d „d eƒƒZeGd d„deƒƒZ eGdd„de ƒƒZ eGdd„de ƒƒZ eGdd„de ƒƒZ dS)zÚ Various richly-typed exceptions, that also help us deal with string formatting in python where it's easier. By putting the formatting in `__str__`, we also avoid paying the cost for users who silence the exceptions. é)Ú set_modulecCst|ƒdkr|dS|SdS)Néé)Úlen)Útup©rúA/usr/local/lib/python3.9/site-packages/numpy/_core/_exceptions.pyÚ _unpack_tuple s r cCst|tƒsJ‚|jj|_|S)aG A decorator that makes an exception class look like its base. We use this to hide subclasses that are implementation details - the user should catch the base type, which is what the traceback will show them. Classes decorated with this decorator are subject to removal without a deprecation warning. )Ú issubclassÚ ExceptionÚ__base__Ú__name__)ÚclsrrrÚ_display_as_bases  rc@seZdZdZdd„ZdS)ÚUFuncTypeErrorz% Base class for all ufunc exceptions cCs ||_dS©N)Úufunc)ÚselfrrrrÚ__init__"szUFuncTypeError.__init__N)r Ú __module__Ú __qualname__Ú__doc__rrrrrr srcs(eZdZdZ‡fdd„Zdd„Z‡ZS)Ú_UFuncNoLoopErrorz* Thrown when a ufunc loop cannot be found cstƒ |¡t|ƒ|_dSr)ÚsuperrÚtupleÚdtypes©rrr©Ú __class__rrr)s z_UFuncNoLoopError.__init__cCs6d |jjt|jd|jj…ƒt|j|jjd…ƒ¡S)NzLufunc {!r} did not contain a loop with signature matching types {!r} -> {!r})Úformatrr r rÚnin©rrrrÚ__str__-s ÿúz_UFuncNoLoopError.__str__©r rrrrr"Ú __classcell__rrrrr&s rcs(eZdZdZ‡fdd„Zdd„Z‡ZS)Ú_UFuncBinaryResolutionErrorz' Thrown when a binary resolution fails cs$tƒ ||¡t|jƒdks J‚dS)Nr)rrrrrrrrr;sz$_UFuncBinaryResolutionError.__init__cCsdj|jjg|j¢RŽS)Nz7ufunc {!r} cannot use operands with types {!r} and {!r})rrr rr!rrrr"?s ÿýýz#_UFuncBinaryResolutionError.__str__r#rrrrr%8s r%cseZdZ‡fdd„Z‡ZS)Ú_UFuncCastingErrorcs"tƒ |¡||_||_||_dSr)rrÚcastingÚfrom_Úto)rrr'r(r)rrrrIs z_UFuncCastingError.__init__)r rrrr$rrrrr&Gsr&cs(eZdZdZ‡fdd„Zdd„Z‡ZS)Ú_UFuncInputCastingErrorz, Thrown when a ufunc input cannot be casted cstƒ ||||¡||_dSr)rrÚin_i©rrr'r(r)ÚirrrrSsz _UFuncInputCastingError.__init__cCs8|jjdkrd |j¡nd}d |jj||j|j|j¡S)Nrú{} ÚzGCannot cast ufunc {!r} input {}from {!r} to {!r} with casting rule {!r})rr rr+r r(r)r'©rZi_strrrrr"Ws ÿüz_UFuncInputCastingError.__str__r#rrrrr*Ps r*cs(eZdZdZ‡fdd„Zdd„Z‡ZS)Ú_UFuncOutputCastingErrorz- Thrown when a ufunc output cannot be casted cstƒ ||||¡||_dSr)rrÚout_ir,rrrresz!_UFuncOutputCastingError.__init__cCs8|jjdkrd |j¡nd}d |jj||j|j|j¡S)Nrr.r/zHCannot cast ufunc {!r} output {}from {!r} to {!r} with casting rule {!r})rZnoutrr2r r(r)r'r0rrrr"is ÿüz _UFuncOutputCastingError.__str__r#rrrrr1bs r1c@s8eZdZdZdd„Zedd„ƒZedd„ƒZdd „Z d S) Ú_ArrayMemoryErrorz) Thrown when an array cannot be allocatedcCs||_||_dSr)ÚshapeÚdtype)rr4r5rrrrwsz_ArrayMemoryError.__init__cCs |jj}|jD] }||9}q|Sr)r5Úitemsizer4)rÚ num_bytesÚdimrrrÚ _total_size{s  z_ArrayMemoryError._total_sizec CsÌd}d}gd¢}t| ¡ddƒ|}d||>}||}~t|ƒ|krX|d7}||}|t|ƒkrˆt|ƒd}|d|||>9}|}||}|dkr¤d ||¡St|ƒdkr¼d ||¡Sd  ||¡Sd S) z5 Convert a number of bytes into a binary size string é i)ÚbytesÚKiBÚMiBÚGiBÚTiBÚPiBÚEiBrrz {:.0f} {}ièz {:#.3g} {}z {:#.0f} {}N)ÚmaxÚ bit_lengthÚroundrr) r7Z LOG2_STEPZSTEPZunitsZunit_iZunit_valZn_unitsZ new_unit_iZ unit_namerrrÚ_size_to_string‚s(       z!_ArrayMemoryError._size_to_stringcCs| |j¡}d ||j|j¡S)NzAUnable to allocate {} for an array with shape {} and data type {})rEr9rr4r5)rÚsize_strrrrr"§s   ÿÿz_ArrayMemoryError.__str__N) r rrrrÚpropertyr9Ú staticmethodrEr"rrrrr3ts  $r3N)rZ_utilsrr rÚ TypeErrorrrr%r&r*r1Ú MemoryErrorr3rrrrÚs