# Path: pypif/obj/common/value.py
# class Value(Pio):
#     """
#     Information about a scalar, vector, or matrix, or a list of one of those.
#     """
# 
#     def __init__(self, name=None, scalars=None, vectors=None, matrices=None, files=None,
#                  units=None, tags=None, **kwargs):
#         """
#         Constructor.
# 
#         :param name: String with the name of the value.
#         :param scalars: One or more dictionaries, strings, numbers, or :class:`.Scalar` objects.
#         :param vectors: One or more lists of dictionaries, strings, numbers, or :class:`.Scalar` objects,
#                 each representing a vector.
#         :param matrices: One of more lists of lists of dictionaries, strings, numbers, or :class:`.Scalar` objects,
#                 each representing a matrix with rows as the innermost lists.
#         :param files: One of more dictionaries, strings, or :class:`.FileReference` objects.
#         :param units: String with the units of the value.
#         :param tags: List of strings or numbers that are tags for this object.
#         :param kwargs: Dictionary of fields that are not supported.
#         """
#         super(Value, self).__init__(tags=tags, **kwargs)
#         self._name = None
#         self.name = name
# 
#         self._files = None
#         self.files = files
# 
#         self._scalars = None
#         if scalars is not None:
#             self.scalars = scalars
# 
#         self._vectors = None
#         if vectors is not None:
#             self.vectors = vectors
# 
#         self._matrices = None
#         if matrices is not None:
#             self.matrices = matrices
# 
#         self._units = None
#         self.units = units
# 
#     @property
#     def name(self):
#         return self._name
# 
#     @name.setter
#     def name(self, name):
#         self._validate_type('name', name, string_types)
#         self._name = name
# 
#     @name.deleter
#     def name(self):
#         self._name = None
# 
#     @property
#     def scalars(self):
#         return self._scalars
# 
#     @scalars.setter
#     def scalars(self, scalars):
#         self._validate_list_type('scalars', scalars, dict, string_types, numbers.Number, Scalar)
#         self._scalars = self._get_object(Scalar, scalars)
# 
#     @scalars.deleter
#     def scalars(self):
#         self._scalars = None
# 
#     @property
#     def vectors(self):
#         return self._vectors
# 
#     @vectors.setter
#     def vectors(self, vectors):
#         self._validate_nested_list_type('vectors', vectors, 2, dict, string_types, numbers.Number, Scalar)
#         self._vectors = self._get_object(Scalar, vectors)
# 
#     @vectors.deleter
#     def vectors(self):
#         self._vectors = None
# 
#     @property
#     def matrices(self):
#         return self._matrices
# 
#     @matrices.setter
#     def matrices(self, matrices):
#         self._validate_nested_list_type('matrices', matrices, 3, dict, string_types, numbers.Number, Scalar)
#         self._matrices = self._get_object(Scalar, matrices)
# 
#     @matrices.deleter
#     def matrices(self):
#         self._matrices = None
# 
#     @property
#     def units(self):
#         return self._units
# 
#     @units.setter
#     def units(self, units):
#         self._validate_type('units', units, string_types)
#         self._units = units
# 
#     @units.deleter
#     def units(self):
#         self._units = None
# 
#     @property
#     def files(self):
#         return self._files
# 
#     @files.setter
#     def files(self, files):
#         self._validate_list_type('files', files, dict, FileReference)
#         self._files = self._get_object(FileReference, files)
# 
#     @files.deleter
#     def files(self):
#         self._files = None
# 
# Path: pypif/pif.py
# def dump(pif, fp, **kwargs):
# def dumps(pif, **kwargs):
# def load(fp, class_=None, **kwargs):
# def loads(s, class_=None, **kwargs):
# def loado(obj, class_=None):
# def _dict_to_pio(d, class_=None):


from pypif.obj.common.value import Value
from pypif import pif
import pytest

def test_basic():
    """Test that constructor arguments are saved"""
    foo = Value(name="foo", units="eV", tags=["tag1", "tag2"])
    assert foo.name == "foo"
    assert foo.units == "eV"
    assert len(foo.tags) == 2
    assert "tag1" in foo.tags
    assert "tag2" in foo.tags


def test_round_robin():
    foo = Value(name="foo", units="eV")
    assert foo.name == "foo", "Value object couldn't store name"
    assert foo.units == "eV", "Value object couldn't store units"
    round_robin = pif.loads(pif.dumps(foo), class_=Value)
    assert round_robin.name == "foo", "Name didn't survive json round robin"
    assert round_robin.units == "eV", "Units didn't survive json round robin"


@pytest.mark.xfail
def test_convert_scalar():
    """Test that scalars are made rigid"""
    foo = Value(scalars=1.2)
    assert foo.scalars[0].value == 1.2


@pytest.mark.xfail
def test_convert_setter():
    """Test that scalars are made rigid"""

# Path: pypif/obj/common/value.py
# class Value(Pio):
#     """
#     Information about a scalar, vector, or matrix, or a list of one of those.
#     """
# 
#     def __init__(self, name=None, scalars=None, vectors=None, matrices=None, files=None,
#                  units=None, tags=None, **kwargs):
#         """
#         Constructor.
# 
#         :param name: String with the name of the value.
#         :param scalars: One or more dictionaries, strings, numbers, or :class:`.Scalar` objects.
#         :param vectors: One or more lists of dictionaries, strings, numbers, or :class:`.Scalar` objects,
#                 each representing a vector.
#         :param matrices: One of more lists of lists of dictionaries, strings, numbers, or :class:`.Scalar` objects,
#                 each representing a matrix with rows as the innermost lists.
#         :param files: One of more dictionaries, strings, or :class:`.FileReference` objects.
#         :param units: String with the units of the value.
#         :param tags: List of strings or numbers that are tags for this object.
#         :param kwargs: Dictionary of fields that are not supported.
#         """
#         super(Value, self).__init__(tags=tags, **kwargs)
#         self._name = None
#         self.name = name
# 
#         self._files = None
#         self.files = files
# 
#         self._scalars = None
#         if scalars is not None:
#             self.scalars = scalars
# 
#         self._vectors = None
#         if vectors is not None:
#             self.vectors = vectors
# 
#         self._matrices = None
#         if matrices is not None:
#             self.matrices = matrices
# 
#         self._units = None
#         self.units = units
# 
#     @property
#     def name(self):
#         return self._name
# 
#     @name.setter
#     def name(self, name):
#         self._validate_type('name', name, string_types)
#         self._name = name
# 
#     @name.deleter
#     def name(self):
#         self._name = None
# 
#     @property
#     def scalars(self):
#         return self._scalars
# 
#     @scalars.setter
#     def scalars(self, scalars):
#         self._validate_list_type('scalars', scalars, dict, string_types, numbers.Number, Scalar)
#         self._scalars = self._get_object(Scalar, scalars)
# 
#     @scalars.deleter
#     def scalars(self):
#         self._scalars = None
# 
#     @property
#     def vectors(self):
#         return self._vectors
# 
#     @vectors.setter
#     def vectors(self, vectors):
#         self._validate_nested_list_type('vectors', vectors, 2, dict, string_types, numbers.Number, Scalar)
#         self._vectors = self._get_object(Scalar, vectors)
# 
#     @vectors.deleter
#     def vectors(self):
#         self._vectors = None
# 
#     @property
#     def matrices(self):
#         return self._matrices
# 
#     @matrices.setter
#     def matrices(self, matrices):
#         self._validate_nested_list_type('matrices', matrices, 3, dict, string_types, numbers.Number, Scalar)
#         self._matrices = self._get_object(Scalar, matrices)
# 
#     @matrices.deleter
#     def matrices(self):
#         self._matrices = None
# 
#     @property
#     def units(self):
#         return self._units
# 
#     @units.setter
#     def units(self, units):
#         self._validate_type('units', units, string_types)
#         self._units = units
# 
#     @units.deleter
#     def units(self):
#         self._units = None
# 
#     @property
#     def files(self):
#         return self._files
# 
#     @files.setter
#     def files(self, files):
#         self._validate_list_type('files', files, dict, FileReference)
#         self._files = self._get_object(FileReference, files)
# 
#     @files.deleter
#     def files(self):
#         self._files = None
# 
# Path: pypif/pif.py
# def dump(pif, fp, **kwargs):
# def dumps(pif, **kwargs):
# def load(fp, class_=None, **kwargs):
# def loads(s, class_=None, **kwargs):
# def loado(obj, class_=None):
# def _dict_to_pio(d, class_=None):


# Path: pypif/obj/common/tests/test_value.py
from pypif.obj.common.value import Value
from pypif import pif
import pytest


def test_basic():
    """Test that constructor arguments are saved"""
    foo = Value(name="foo", units="eV", tags=["tag1", "tag2"])
    assert foo.name == "foo"
    assert foo.units == "eV"
    assert len(foo.tags) == 2
    assert "tag1" in foo.tags
    assert "tag2" in foo.tags


def test_round_robin():
    foo = Value(name="foo", units="eV")
    assert foo.name == "foo", "Value object couldn't store name"
    assert foo.units == "eV", "Value object couldn't store units"
    round_robin = pif.loads(pif.dumps(foo), class_=Value)
    assert round_robin.name == "foo", "Name didn't survive json round robin"
    assert round_robin.units == "eV", "Units didn't survive json round robin"


@pytest.mark.xfail
def test_convert_scalar():
    """Test that scalars are made rigid"""
    foo = Value(scalars=1.2)
    assert foo.scalars[0].value == 1.2


@pytest.mark.xfail
def test_convert_setter():
    """Test that scalars are made rigid"""

    foo = Value()