<commit_before>"""
Module to call mcsqs, distributed with AT-AT
https://www.brown.edu/Departments/Engineering/Labs/avdw/atat/
"""

import os
import subprocess
from typing import Dict, Union, List, NamedTuple

import numpy as np
from monty.tempfile import ScratchDir
from monty.dev import requires
from monty.os.path import which

from pymatgen import Structure


class Sqs(NamedTuple):
    bestsqs: Structure
    objective_function: float


@requires(which("mcsqs") and which("str2cif"),
          "run_mcsqs requires first installing AT-AT, "
          "see https://www.brown.edu/Departments/Engineering/Labs/avdw/atat/")
def run_mcsqs(
    structure: Structure,
    clusters: Dict[int, float],
    scaling: Union[int, List[int]],
    search_time: float = 0.01,
) -> Sqs:
    """
    Helper function for calling mcsqs with different arguments
    Args:
        structure (Structure): disordered pymatgen Structure object<commit_msg>Fixed type error<commit_after>"""
Module to call mcsqs, distributed with AT-AT
https://www.brown.edu/Departments/Engineering/Labs/avdw/atat/
"""

import os
import subprocess
from typing import Dict, Union, List, NamedTuple, Optional

import numpy as np
from monty.tempfile import ScratchDir
from monty.dev import requires
from monty.os.path import which

from pymatgen import Structure


class Sqs(NamedTuple):
    bestsqs: Structure
    objective_function: float


@requires(which("mcsqs") and which("str2cif"),
          "run_mcsqs requires first installing AT-AT, "
          "see https://www.brown.edu/Departments/Engineering/Labs/avdw/atat/")
def run_mcsqs(
    structure: Structure,
    clusters: Dict[int, float],
    scaling: Union[int, List[int]],
    search_time: float = 0.01,
) -> Optional[Sqs]:
    """
    Helper function for calling mcsqs with different arguments
    Args:
        structure (Structure): disordered pymatgen Structure object
{'fraction_non_alphanumeric': 0.10005293806246691, 'fraction_numerical': 0.004235044997353097, 'mean_word_length': 3.9476439790575917, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '7643742', 'n_tokens_mistral': 615, 'n_tokens_neox': 584, 'n_words': 172}