<commit_before>#! /usr/bin/env python
"""Provides a Dakota interface to the HydroTrend component."""

import os
import shutil
import subprocess
import numpy as np
from .base import PluginBase
from csdms.dakota.utils import get_response_descriptors, write_results, \
    compute_statistic


classname = 'HydroTrend'


def is_installed():
    """Check whether HydroTrend is in the execution path."""
    try:
        subprocess.call(['hydrotrend', '--version'])
    except OSError:
        return False
    else:
        return True


class HydroTrend(PluginBase):

    """Represent a HydroTrend simulation in a Dakota experiment."""

    def __init__(self, input_dir='HYDRO_IN',
                 output_dir='HYDRO_OUTPUT', input_file='HYDRO.IN',
                 input_template='HYDRO.IN.dtmpl',
                 hypsometry_file='HYDRO0.HYPS', output_files=None,
                 output_statistics=None, **kwargs):
        """Define default files and directories."""
        PluginBase.__init__(self, **kwargs)
        self.input_dir = input_dir
        self.output_dir = output_dir
        self.input_file = input_file
        self.input_template = input_template
        self.hypsometry_file = hypsometry_file
        self.output_files = output_files
        self.output_statistics = output_statistics
        self.output_values = []

    def setup(self, config):
        """Configure HydroTrend inputs.

        Sets attributes using information from the run configuration
        file. The Dakota parsing utility ``dprepro`` reads parameters
        from Dakota to create a new HydroTrend input file from a
        template.

        Parameters
        ----------
        config : dict
          Stores configuration settings for a Dakota experiment.

        """
        self.setup_files(config)
        self.setup_directories(config)
        subprocess.call(['dprepro', config['parameters_file'],
                         self.input_template,
                         self.input_file])
        shutil.copy(self.input_file, self.input_dir)
        shutil.copy(self.hypsometry_file, self.input_dir)

    def setup_files(self, config):
        """Configure HydroTrend input and output files.

        Parameters
        ----------
        config : dict
          Configuration settings for a Dakota experiment.

        """
        self.input_template = config['template_file']
        self.hypsometry_file, = config['input_files']
        self.output_files = config['response_files']
        self.output_statistics = config['response_statistics']

    def setup_directories(self, config):
        """Configure HydroTrend input and output directories.

        Parameters
        ----------
        config : dict
          Configuration settings for a Dakota experiment.

        """<commit_msg>Use new 'auxiliary_files' instead of 'input_files'<commit_after>#! /usr/bin/env python
"""Provides a Dakota interface to the HydroTrend component."""

import os
import shutil
import subprocess
import numpy as np
from .base import PluginBase
from csdms.dakota.utils import (get_response_descriptors,
                                write_results, compute_statistic)


classname = 'HydroTrend'


def is_installed():
    """Check whether HydroTrend is in the execution path."""
    try:
        subprocess.call(['hydrotrend', '--version'])
    except OSError:
        return False
    else:
        return True


class HydroTrend(PluginBase):

    """Represent a HydroTrend simulation in a Dakota experiment."""

    def __init__(self,
                 input_dir='HYDRO_IN',
                 output_dir='HYDRO_OUTPUT',
                 input_file='HYDRO.IN',
                 input_template='HYDRO.IN.dtmpl',
                 hypsometry_file='HYDRO0.HYPS',
                 output_files=None,
                 output_statistics=None,
                 **kwargs):
        """Define default files and directories."""
        PluginBase.__init__(self, **kwargs)
        self.input_dir = input_dir
        self.output_dir = output_dir
        self.input_file = input_file
        self.input_template = input_template
        self.hypsometry_file = hypsometry_file
        self.output_files = output_files
        self.output_statistics = output_statistics
        self.output_values = []

    def setup(self, config):
        """Configure HydroTrend inputs.

        Sets attributes using information from the run configuration
        file. The Dakota parsing utility ``dprepro`` reads parameters
        from Dakota to create a new HydroTrend input file from a
        template.

        Parameters
        ----------
        config : dict
          Stores configuration settings for a Dakota experiment.

        """
        self.setup_files(config)
        self.setup_directories(config)
        subprocess.call(['dprepro', config['parameters_file'],
                         self.input_template,
                         self.input_file])
        shutil.copy(self.input_file, self.input_dir)
        shutil.copy(self.hypsometry_file, self.input_dir)

    def setup_files(self, config):
        """Configure HydroTrend input and output files.

        Parameters
        ----------
        config : dict
          Configuration settings for a Dakota experiment.

        """
        self.input_template = config['template_file']
        self.hypsometry_file, = config['auxiliary_files']
        self.output_files = config['response_files']
        self.output_statistics = config['response_statistics']

    def setup_directories(self, config):
        """Configure HydroTrend input and output directories.

        Parameters
        ----------
        config : dict
          Configuration settings for a Dakota experiment.

        """
{'fraction_non_alphanumeric': 0.09090909090909091, 'fraction_numerical': 0.00034897923573547375, 'mean_word_length': 2.253121452894438, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7039003', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1463, 'n_words': 391}