<commit_before><commit_msg>test(containers): add test for attrs_from when building containers<commit_after>import numpy as np
import pytest

from draco.core import containers


@pytest.fixture
def ss_container():

    ss = containers.SiderealStream(
        stack=5, input=3, ra=16, freq=np.linspace(800.0, 750.0, 5)
    )
    ss.attrs["test_attr1"] = "hello"
    ss.vis.attrs["test_attr2"] = "hello2"

    return ss


def test_attrs_from(ss_container):

    ts = containers.TimeStream(time=10, axes_from=ss_container, attrs_from=ss_container)

    # Check that the attributes have been copied over properly
    assert len(ts.attrs) == 1
    assert ts.attrs["test_attr1"] == "hello"
    assert ts.vis.attrs["test_attr2"] == "hello2"

    # Check that the axis attributes on the dataasets did not get overwritten
    assert len(ts.vis.attrs) == 2
    assert len(ts.weight.attrs) == 1
    assert tuple(ts.vis.attrs["axis"]) == ("freq", "stack", "time")
    assert tuple(ts.weight.attrs["axis"]) == ("freq", "stack", "time")

{'fraction_non_alphanumeric': 0.136986301369863, 'fraction_numerical': 0.023483365949119372, 'mean_word_length': 4.08955223880597, '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': '3272704', 'n_tokens_mistral': 353, 'n_tokens_neox': 337, 'n_words': 86}