<commit_before>from __future__ import print_function

import subprocess
import os
import tempfile
import shutil

from simlammps import read_data_file


def get_particles(y_range):
    """ get particles for benchmarking

    Parameters
    ----------
    y_range : float
        range of particle domain in y

    Returns
    -------
    particle_list : iterable of ABCParticles

    """
    particles_list = None

    temp_dir = tempfile.mkdtemp()
    script_name = os.path.join(temp_dir, "script")
    data_name = os.path.join(temp_dir, "output")
    try:
        with open(script_name, "w") as script_file:
            script_file.write(lammps_script.format(y_range=y_range,
                                                   data_name=data_name))
        cmd = ("lammps -screen none"
               " -log none -echo none"
               " < {}").format(script_name)
        subprocess.check_call(cmd, shell=True)
        particles_list = read_data_file(data_name)
    finally:
        shutil.rmtree(temp_dir)
    return particles_list


lammps_script = """# create particles"
dimension	2
atom_style	atomic

# create geometry
lattice		hex .7
region		box block 0 {y_range} 0 10 -0.25 0.25
create_box	3 box
create_atoms	1 box

mass		1 1.0
mass		2 1.0
mass		3 1.0

# LJ potentials
pair_style	lj/cut 1.12246
pair_coeff	* * 1.0 1.0 1.12246

# define groups
region	     1 block INF INF INF 1.25 INF INF
group	     lower region 1
region	     2 block INF INF 8.75 INF INF INF
group	     upper region 2
group	     boundary union lower upper
group	     flow subtract all boundary

set          group lower type 2
set          group upper type 3

# initial velocities
compute      mobile flow temp
velocity     flow create 1.0 482748 temp mobile
velocity     boundary set 0.0 0.0 0.0

# write atoms to a lammps data file
write_data {data_name}"""<commit_msg>Remove unneeded steps in bench-particle creation<commit_after>from __future__ import print_function

import subprocess
import os
import tempfile
import shutil

from simlammps import read_data_file


def get_particles(y_range):
    """ get particles for benchmarking

    Parameters
    ----------
    y_range : float
        range of particle domain in y

    Returns
    -------
    particle_list : iterable of ABCParticles

    """
    particles_list = None

    temp_dir = tempfile.mkdtemp()
    script_name = os.path.join(temp_dir, "script")
    data_name = os.path.join(temp_dir, "output")
    try:
        with open(script_name, "w") as script_file:
            script_file.write(lammps_script.format(y_range=y_range,
                                                   data_name=data_name))
        cmd = ("lammps -screen none"
               " -log none -echo none"
               " < {}").format(script_name)
        subprocess.check_call(cmd, shell=True)
        particles_list = read_data_file(data_name)
    finally:
        shutil.rmtree(temp_dir)
    return particles_list


lammps_script = """# create particles"
dimension	2
atom_style	atomic

# create geometry
lattice		hex .7
region		box block 0 {y_range} 0 10 -0.25 0.25
create_box	3 box
create_atoms	1 box

mass		1 1.0
mass		2 1.0
mass		3 1.0

# define groups
region	     1 block INF INF INF 1.25 INF INF
group	     lower region 1
region	     2 block INF INF 8.75 INF INF INF
group	     upper region 2
group	     boundary union lower upper
group	     flow subtract all boundary

set          group lower type 2
set          group upper type 3

# write atoms to a lammps data file
write_data {data_name}"""
{'fraction_non_alphanumeric': 0.07380073800738007, 'fraction_numerical': 0.02838489923360772, 'mean_word_length': 2.3722488038277514, 'pattern_counts': {'":': 0, '<': 5, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3914240', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1114, 'n_words': 360}