<commit_before><%= @generator.render_partial('base_header_partial.py.erb') %>

import numpy as np
from numpy import nan, inf

import openmdao.api as om
<% if @impl.nonlinear_solver.reckless? -%>
from openmdao_extensions.reckless_nonlinear_block_gs import RecklessNonlinearBlockGS
<% else -%>
from openmdao.api import <%= @impl.nonlinear_solver.name %>
<% end -%>
from openmdao.api import <%= @impl.linear_solver.name %>
from openmdao import __version__ as OPENMDAO_VERSION

<% @mda.sub_analyses.each do |a| -%>
from <%= a.py_full_modulename %> import <%= a.py_classname %>
<% end -%>

<% @mda.all_plain_disciplines.each do |disc| -%>
<% if @check_only || disc.local?(@remote_ip) -%>
from <%= disc.py_full_modulename %> import <%= disc.py_classname %> 
<% else %>
from <%= @server_module %>.remote_discipline import Remote<%= disc.py_classname %>
<% end -%>
<% end -%>

class <%= @mda.py_classname %>FactoryBase():
    """ 
    A factory for all plain disciplines of <%= @mda.name %> analysis.

    One can override methods in a subclass to take control over disciplines creation 
    and pass that subclass to the analysis constructor as a factory argument.
    """
<% @mda.all_plain_disciplines.each do |disc| %>
    def create_<%= disc.snake_modulename %>(self):
<% if (@check_only || disc.local?(@remote_ip)) -%>
        return <%= disc.py_classname %>()
<% else -%>
        """ 
        <%= disc.py_classname %> is expected to be run on remote host <%= disc.host %>.
        """
        return Remote<%= disc.py_classname %>()
<% end -%>
<% end %>

class <%= @mda.py_classname %>Base(<%= @impl.parallel_group ? "om.ParallelGroup" : "om.Group" %>):
    """ An OpenMDAO base component to encapsulate <%= @mda.py_classname %> MDA """

    def initialize(self):
        self.options.declare('factory', default=<%= @mda.py_classname %>FactoryBase(), 
                             types=object)

        self.nonlinear_solver = <%= @impl.nonlinear_solver.name %>()
<% unless @impl.nonlinear_solver.runonce? -%>
        self.nonlinear_solver.options['atol'] = <%= @impl.nonlinear_solver.atol %>
        self.nonlinear_solver.options['rtol'] = <%= @impl.nonlinear_solver.rtol %>
        self.nonlinear_solver.options['err_on_non_converge'] = <%= @impl.to_code(:nonlinear_solver, :err_on_non_converge) %>
        self.nonlinear_solver.options['maxiter'] = <%= @impl.nonlinear_solver.maxiter %>
<% end -%>
        self.nonlinear_solver.options['iprint'] = <%= @impl.nonlinear_solver.iprint %>

<% unless @impl.linear_solver.runonce? || @impl.linear_solver.direct? -%>
        self.linear_solver = <%= @impl.linear_solver.name %>()
        self.linear_solver.options['atol'] = <%= @impl.linear_solver.atol %>
        self.linear_solver.options['rtol'] = <%= @impl.linear_solver.rtol %>
        self.linear_solver.options['err_on_non_converge'] = <%= @impl.to_code(:linear_solver, :err_on_non_converge) %>
        self.linear_solver.options['maxiter'] = <%= @impl.linear_solver.maxiter %>
<% end %>
        self.linear_solver.options['iprint'] = <%= @impl.linear_solver.iprint %>

    def setup(self):<% @mda.input_variables.each do |dv| %>
        self.set_input_defaults('<%= dv.name %>', val=<%= dv.init_py_value %><%= @impl.use_units && !dv.units.blank? ? ", units='#{dv.units}'":"" %>)<% end -%>
<% @mda.disciplines.nodes.each do |d| %>
        self.add_subsystem('<%= d.py_classname %>', self.create_<%= d.basename %>(),
                           promotes=[<%= d.variables.map(&:py_varname).map{|v| "'#{v}'"}.join(', ') %>])<% end -%>

<% @mda.sub_analyses.each do |a| %>
    def create_<%= a.basename %>(self):
        """ 
        User can override this method in a subclass 
        to take control over <%= a.py_classname %> sub analysis creation.
        """
        return <%= a.py_classname %>(factory=self.options["factory"])
<% end -%>
<% @mda.plain_disciplines.each do |disc| %>
    def create_<%= disc.basename %>(self):
        return self.options["factory"].create_<%= disc.snake_modulename %>()
<% end %>
<commit_msg>Use snake_case to register OpenMDAO systems<commit_after><%= @generator.render_partial('base_header_partial.py.erb') %>

import numpy as np
from numpy import nan, inf

import openmdao.api as om
<% if @impl.nonlinear_solver.reckless? -%>
from openmdao_extensions.reckless_nonlinear_block_gs import RecklessNonlinearBlockGS
<% else -%>
from openmdao.api import <%= @impl.nonlinear_solver.name %>
<% end -%>
from openmdao.api import <%= @impl.linear_solver.name %>
from openmdao import __version__ as OPENMDAO_VERSION

<% @mda.sub_analyses.each do |a| -%>
from <%= a.py_full_modulename %> import <%= a.py_classname %>
<% end -%>

<% @mda.all_plain_disciplines.each do |disc| -%>
<% if @check_only || disc.local?(@remote_ip) -%>
from <%= disc.py_full_modulename %> import <%= disc.py_classname %> 
<% else %>
from <%= @server_module %>.remote_discipline import Remote<%= disc.py_classname %>
<% end -%>
<% end -%>

class <%= @mda.py_classname %>FactoryBase():
    """ 
    A factory for all plain disciplines of <%= @mda.name %> analysis.

    One can override methods in a subclass to take control over disciplines creation 
    and pass that subclass to the analysis constructor as a factory argument.
    """
<% @mda.all_plain_disciplines.each do |disc| %>
    def create_<%= disc.snake_modulename %>(self):
<% if (@check_only || disc.local?(@remote_ip)) -%>
        return <%= disc.py_classname %>()
<% else -%>
        """ 
        <%= disc.py_classname %> is expected to be run on remote host <%= disc.host %>.
        """
        return Remote<%= disc.py_classname %>()
<% end -%>
<% end %>

class <%= @mda.py_classname %>Base(<%= @impl.parallel_group ? "om.ParallelGroup" : "om.Group" %>):
    """ An OpenMDAO base component to encapsulate <%= @mda.py_classname %> MDA """

    def initialize(self):
        self.options.declare('factory', default=<%= @mda.py_classname %>FactoryBase(), 
                             types=object)

        self.nonlinear_solver = <%= @impl.nonlinear_solver.name %>()
<% unless @impl.nonlinear_solver.runonce? -%>
        self.nonlinear_solver.options['atol'] = <%= @impl.nonlinear_solver.atol %>
        self.nonlinear_solver.options['rtol'] = <%= @impl.nonlinear_solver.rtol %>
        self.nonlinear_solver.options['err_on_non_converge'] = <%= @impl.to_code(:nonlinear_solver, :err_on_non_converge) %>
        self.nonlinear_solver.options['maxiter'] = <%= @impl.nonlinear_solver.maxiter %>
<% end -%>
        self.nonlinear_solver.options['iprint'] = <%= @impl.nonlinear_solver.iprint %>

<% unless @impl.linear_solver.runonce? || @impl.linear_solver.direct? -%>
        self.linear_solver = <%= @impl.linear_solver.name %>()
        self.linear_solver.options['atol'] = <%= @impl.linear_solver.atol %>
        self.linear_solver.options['rtol'] = <%= @impl.linear_solver.rtol %>
        self.linear_solver.options['err_on_non_converge'] = <%= @impl.to_code(:linear_solver, :err_on_non_converge) %>
        self.linear_solver.options['maxiter'] = <%= @impl.linear_solver.maxiter %>
<% end %>
        self.linear_solver.options['iprint'] = <%= @impl.linear_solver.iprint %>

    def setup(self):<% @mda.input_variables.each do |dv| %>
        self.set_input_defaults('<%= dv.name %>', val=<%= dv.init_py_value %><%= @impl.use_units && !dv.units.blank? ? ", units='#{dv.units}'":"" %>)<% end -%>
<% @mda.disciplines.nodes.each do |d| %>
        self.add_subsystem('<%= d.py_modulename %>', self.create_<%= d.basename %>(),
                           promotes=[<%= d.variables.map(&:py_varname).map{|v| "'#{v}'"}.join(', ') %>])<% end -%>

<% @mda.sub_analyses.each do |a| %>
    def create_<%= a.py_modulename %>(self):
        """ 
        User can override this method in a subclass 
        to take control over <%= a.py_classname %> sub analysis creation.
        """
        return <%= a.py_classname %>(factory=self.options["factory"])
<% end -%>
<% @mda.plain_disciplines.each do |disc| %>
    def create_<%= disc.py_modulename %>(self):
        return self.options["factory"].create_<%= disc.snake_modulename %>()
<% end %>

{'fraction_non_alphanumeric': 0.1839279101345513, 'fraction_numerical': 0.0, 'mean_word_length': 3.6886574074074074, 'pattern_counts': {'":': 2, '<': 143, '<?xml version=': 0, '>': 143, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4040770', 'n_tokens_mistral': 3082, 'n_tokens_neox': 2769, 'n_words': 495}