
    Ed                      @    d dl mZ d dlmZ d dlmZ d dlmZ 	 ddZdS )	    )chain)Module)Dummy)FCodePrinter Nc                    |pddd}t          |          }t                      }t          | t                    rt	          d          t          |t          ||g          |           }|                    |          }dd                    d |j        	                                D                       z  }|dz  }|d	z  }|d
d                    d | D                       z  z  }|
                    |                    |          |          S )a   Creates a ``Module`` instance and renders it as a string.

    This generates Fortran source code for a module with the correct ``use`` statements.

    Parameters
    ==========

    definitions : iterable
        Passed to :class:`sympy.codegen.fnodes.Module`.
    name : str
        Passed to :class:`sympy.codegen.fnodes.Module`.
    declarations : iterable
        Passed to :class:`sympy.codegen.fnodes.Module`. It will be extended with
        use statements, 'implicit none' and public list generated from ``definitions``.
    printer_settings : dict
        Passed to ``FCodePrinter`` (default: ``{'standard': 2003, 'source_format': 'free'}``).

    i  free)standardsource_formatz7This function expects to construct a module on its own.z   %s
z   
c                 J    g | ] \  }}d |dd                     |          !S )zuse z, only: , )join).0kvs      4lib/python3.11/site-packages/sympy/codegen/futils.py
<listcomp>z$render_as_module.<locals>.<listcomp>#   sL     /U /U /U0411 FGQQ		RS/U /U /U /U    z   implicit none
z   private
z   public %s
r   c                 X    g | ]'}t          |d d          t          |j                  (S )nameN)getattrstrr   )r   nodes     r   r   z$render_as_module.<locals>.<listcomp>'   s5    3z3z3zt^efjlrtx^y^y3zC	NN3z3z3zr   )r   r   
isinstancer   
ValueErrorr   doprintr   module_usesitemsreplace)	definitionsr   declarationsprinter_settingsprinterdummymodfstrmodule_use_strs	            r   render_as_moduler(   	   s+   & (Vv+V+V+,,GGGE+v&& TRSSS
u\E733[
A
AC??3D /U /U8?8K8Q8Q8S8S/U /U /U "V "V VN**Nn$N&3z3z{3z3z3z){){{{N<<..???r   )r   N)		itertoolsr   sympy.codegen.fnodesr   sympy.core.symbolr   sympy.printing.fortranr   r(   r   r   r   <module>r-      st          ' ' ' ' ' ' # # # # # # / / / / / / B@ @ @ @ @ @r   