<commit_before>import numpy
import pytest
import pytac
from pytac.element import Element
from pytac.lattice import Lattice

from constants import DUMMY_ARRAY, LATTICE_NAME


@pytest.fixture
def simple_lattice(simple_element):
    lat = Lattice(LATTICE_NAME, 1)
    lat.add_element(simple_element)
    return lat


def test_create_lattice():
    lat = Lattice(LATTICE_NAME, 1)
    assert(len(lat)) == 0
    assert lat.get_energy() == 1
    assert lat.name == LATTICE_NAME


def test_get_element_devices(simple_lattice):
    devices = simple_lattice.get_element_devices('family', 'x')
    assert len(devices) == 1
    assert devices[0].name == 'x_device'


def test_get_element_devices_returns_empty_list_if_family_not_matched(simple_lattice):
    devices = simple_lattice.get_element_devices('not-a-family', 'x')
    assert devices == []


def test_get_element_devices_returns_empty_list_if_field_not_matched(simple_lattice):
    devices = simple_lattice.get_element_devices('family', 'not-a-field')
    assert devices == []
<commit_msg>Add model and device to test lattice, an d add not-a-device test.<commit_after>import numpy
import pytest
import pytac
from pytac.element import Element
from pytac.lattice import Lattice

from constants import DUMMY_ARRAY, LATTICE_NAME


@pytest.fixture
def simple_lattice(simple_element):
    lat = Lattice(LATTICE_NAME, 1)
    lat.add_element(simple_element)
    lat.set_model(DeviceModel(), pytac.LIVE)
    lat.add_device('x', x_device, unit_uc)
    return lat


def test_create_lattice():
    lat = Lattice(LATTICE_NAME, 1)
    assert(len(lat)) == 0
    assert lat.get_energy() == 1
    assert lat.name == LATTICE_NAME

#new tests
def test_device_raises_KeyError_if_device_not_present(lat)
    with pytest.rasises(KeyError):
        lat.get_device('not-a-device')


def test_get_element_devices(simple_lattice):
    devices = simple_lattice.get_element_devices('family', 'x')
    assert len(devices) == 1
    assert devices[0].name == 'x_device'


def test_get_element_devices_returns_empty_list_if_family_not_matched(simple_lattice):
    devices = simple_lattice.get_element_devices('not-a-family', 'x')
    assert devices == []


def test_get_element_devices_returns_empty_list_if_field_not_matched(simple_lattice):
    devices = simple_lattice.get_element_devices('family', 'not-a-field')
    assert devices == []

{'fraction_non_alphanumeric': 0.09673313534153585, 'fraction_numerical': 0.005091217649554518, 'mean_word_length': 5.254641909814324, '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': '1737856', 'n_tokens_mistral': 812, 'n_tokens_neox': 796, 'n_words': 155}