<commit_before># coding: utf-8

""" Generate a grid of initial conditions for freqmap'ing """

from __future__ import division, print_function

__author__ = "adrn <<EMAIL>>"

# Standard library
import os
import sys

# Third-party
from astropy import log as logger
import gary.potential as gp
import matplotlib.pyplot as plt
import numpy as np

# Project
from streammorphology import project_path
import streammorphology.initialconditions as ic

def main(potential_name, E, ic_func, run_name=None, output_path=None, overwrite=False, plot=False, **kwargs):
    """ Calls one of the grid-making utility functions to generate a
        grid of initial conditions for frequency mapping, and saves the
        grid to a file.
    """

    # read the potential from the registry
    potential_path = os.path.join(project_path, "potentials/{0}.yml".format(potential_name))
    potential = gp.load(potential_path)

    # create path
    if output_path is None:
        output_path = os.path.join(project_path, "output")

    if run_name is None:
        run_name = 'E{:.3f}_{}'.format(E, ic_func.func_name)
    path = os.path.join(output_path, 'freqmap', potential_name, run_name)

    logger.info("Caching to: {}".format(path))
    if not os.path.exists(path):
        os.makedirs(path)

    # path to initial conditions cache
    w0path = os.path.join(path, 'w0.npy')
    pot_path = os.path.join(path, 'potential.yml')

    if os.path.exists(w0path) and overwrite:
        os.remove(w0path)

    if not os.path.exists(w0path):
        # initial conditions
        w0 = ic_func(E=E, potential=potential, **kwargs)
        np.save(w0path, w0)
        logger.info("Create initial conditions file:\n\t{}".format(w0path))

        # save potential
        potential.save(pot_path)

    else:
        w0 = np.load(w0path)
        logger.info("Initial conditions file already exists!\n\t{}".format(w0path))
<commit_msg>treat output path as full path if specified<commit_after># coding: utf-8

""" Generate a grid of initial conditions for freqmap'ing """

from __future__ import division, print_function

__author__ = "adrn <<EMAIL>>"

# Standard library
import os
import sys

# Third-party
from astropy import log as logger
import gary.potential as gp
import matplotlib.pyplot as plt
import numpy as np

# Project
from streammorphology import project_path
import streammorphology.initialconditions as ic

def main(potential_name, E, ic_func, run_name=None, output_path=None, overwrite=False, plot=False, **kwargs):
    """ Calls one of the grid-making utility functions to generate a
        grid of initial conditions for frequency mapping, and saves the
        grid to a file.
    """

    # read the potential from the registry
    potential_path = os.path.join(project_path, "potentials/{0}.yml".format(potential_name))
    potential = gp.load(potential_path)

    # create path
    if output_path is None:
        output_path = os.path.join(project_path, "output")

        if run_name is None:
            run_name = 'E{:.3f}_{}'.format(E, ic_func.func_name)
        path = os.path.join(output_path, 'freqmap', potential_name, run_name)
    else:
        path = output_path

    logger.info("Caching to: {}".format(path))
    if not os.path.exists(path):
        os.makedirs(path)

    # path to initial conditions cache
    w0path = os.path.join(path, 'w0.npy')
    pot_path = os.path.join(path, 'potential.yml')

    if os.path.exists(w0path) and overwrite:
        os.remove(w0path)

    if not os.path.exists(w0path):
        # initial conditions
        w0 = ic_func(E=E, potential=potential, **kwargs)
        np.save(w0path, w0)
        logger.info("Create initial conditions file:\n\t{}".format(w0path))

        # save potential
        potential.save(pot_path)

    else:
        w0 = np.load(w0path)
        logger.info("Initial conditions file already exists!\n\t{}".format(w0path))

{'fraction_non_alphanumeric': 0.10748264335304705, 'fraction_numerical': 0.007714065312419645, 'mean_word_length': 3.3222222222222224, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3473332', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1208, 'n_words': 344}