#
# This file is part of Python package: `pyxarr`
#
#     https://github.com/rmvanhees/pyxarr.git
#
# Copyright (c) 2025 SRON
#    All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Test module for pyxarr class `Dataset`."""

from __future__ import annotations

import numpy as np

from pyxarr import DataArray, Dataset


# - test module ------------------------------------
def tests() -> None:
    """..."""
    xarr1 = DataArray(
        np.arange(3 * 7).reshape(3, 7),
        coords=[("y", [1, 2, 3]), ("x", list(range(7)))],
    )
    xarr2 = DataArray(
        np.arange(3 * 7).reshape(3, 7),
        coords=[("y", [1, 2, 3]), ("x", list(range(7)))],
    )

    # - empty class Dataset
    xds = Dataset()
    print(f"\nShow empty Dataset:\n{xds}")
    print("- boolean test:", bool(xds))
    print("- length:", len(xds))

    # - non-empty class Dataset
    xds["foo"] = xarr1
    xds["bar"] = xarr2
    xds.attrs["title"] = "test example"
    print(f"\nShow non-empty Dataset:\n{xds}")
    print("- boolean test:", bool(xds))
    print("- length:", len(xds))


if __name__ == "__main__":
    tests()
