def test_BaseClass():
    b = Base(1, 's')
    base_checker(b)
    assert b['header'] == 'Undefined'
    assert b['tooltip'] == ''
    assert b['url'] == ''
    assert b['mapping'] is None
Пример #2
0
    def fromPars(cls,
                 atom_site_label: str,
                 type_symbol: str,
                 scat_length_neutron: complex,
                 fract_x: float,
                 fract_y: float,
                 fract_z: float,
                 occupancy: float,
                 adp_type: str,
                 U_iso_or_equiv: float,
                 ADp: list = None,
                 MSp: list = None) -> 'Atom':
        """
        Atom constructor from parameters

        :param atom_site_label: The unique name of the atom in the phase
        :param type_symbol: The type of atom
        :param scat_length_neutron: Neutron scattering length
        :param fract_x: X position
        :param fract_y: Y position
        :param fract_z: Z position
        :param occupancy: Site occupancy
        :param adp_type: ADP type code
        :param U_iso_or_equiv: Isotropic atomic displacement parameter
        :return: Fully formed atom data store
        """
        type_symbol = Base(type_symbol,
                           ATOM_DETAILS['type_symbol']['default'][1])
        scat_length_neutron = Base(
            scat_length_neutron,
            ATOM_DETAILS['scat_length_neutron']['default'][1])
        occupancy = Base(occupancy, ATOM_DETAILS['occupancy']['default'][1])
        adp_type = Base(adp_type, ATOM_DETAILS['adp_type']['default'][1])
        U_iso_or_equiv = Base(U_iso_or_equiv,
                              ATOM_DETAILS['U_iso_or_equiv']['default'][1])
        fract_x = Base(fract_x, ATOM_DETAILS['fract']['default'][1])
        fract_y = Base(fract_y, ATOM_DETAILS['fract']['default'][1])
        fract_z = Base(fract_z, ATOM_DETAILS['fract']['default'][1])

        if not isinstance(ADp, ADP):
            if ADp is not None:
                ADp = ADP.fromPars(*ADp)
            else:
                ADp = ADP.default()

        if not isinstance(MSp, MSP):
            if MSp is not None:
                MSp = MSP.fromPars(*MSp)
            else:
                MSp = MSP.default()

        return cls(atom_site_label, type_symbol, scat_length_neutron, fract_x,
                   fract_y, fract_z, occupancy, adp_type, U_iso_or_equiv, ADp,
                   MSp)
Пример #3
0
    def default(cls) -> 'MSP':
        MSPtype = Base(None, '')

        chi_11 = Base(*ATOM_DETAILS['MSP']['default'])
        chi_12 = Base(*ATOM_DETAILS['MSP']['default'])
        chi_13 = Base(*ATOM_DETAILS['MSP']['default'])

        chi_22 = Base(*ATOM_DETAILS['MSP']['default'])
        chi_23 = Base(*ATOM_DETAILS['MSP']['default'])

        chi_33 = Base(*ATOM_DETAILS['MSP']['default'])

        return cls(MSPtype, chi_11, chi_22, chi_33, chi_12, chi_13, chi_23)
Пример #4
0
    def default(cls) -> 'ADP':
        u_11 = Base(*ATOM_DETAILS['ADP']['default'])
        u_12 = Base(*ATOM_DETAILS['ADP']['default'])
        u_13 = Base(*ATOM_DETAILS['ADP']['default'])

        u_22 = Base(*ATOM_DETAILS['ADP']['default'])
        u_23 = Base(*ATOM_DETAILS['ADP']['default'])

        u_33 = Base(*ATOM_DETAILS['ADP']['default'])

        return cls(u_11, u_22, u_33, u_12, u_13, u_23)
Пример #5
0
    def fromPars(cls, MSPtype: str, chi_11: float, chi_22: float,
                 chi_33: float, chi_12: float, chi_13: float,
                 chi_23: float) -> 'MSP':
        MSPtype = Base(MSPtype, '')

        chi_11 = Base(chi_11, ATOM_DETAILS['MSP']['default'][1])
        chi_12 = Base(chi_12, ATOM_DETAILS['MSP']['default'][1])
        chi_13 = Base(chi_13, ATOM_DETAILS['MSP']['default'][1])

        chi_22 = Base(chi_22, ATOM_DETAILS['MSP']['default'][1])
        chi_23 = Base(chi_23, ATOM_DETAILS['MSP']['default'][1])

        chi_33 = Base(chi_33, ATOM_DETAILS['MSP']['default'][1])

        return cls(MSPtype, chi_11, chi_22, chi_33, chi_12, chi_13, chi_23)
Пример #6
0
    def fromPars(cls, u_11: float, u_12: float, u_13: float, u_22: float,
                 u_23: float, u_33: float) -> 'ADP':
        u_11 = Base(u_11, ATOM_DETAILS['ADP']['default'][1])
        u_12 = Base(u_12, ATOM_DETAILS['ADP']['default'][1])
        u_13 = Base(u_13, ATOM_DETAILS['ADP']['default'][1])

        u_22 = Base(u_22, ATOM_DETAILS['ADP']['default'][1])
        u_23 = Base(u_23, ATOM_DETAILS['ADP']['default'][1])

        u_33 = Base(u_33, ATOM_DETAILS['ADP']['default'][1])

        return cls(u_11, u_22, u_33, u_12, u_13, u_23)
Пример #7
0
    def default(cls, atom_site_label: str) -> 'Atom':
        """
        Default constructor for an atom given a unique name in the phase

        :param atom_site_label: The atoms unique name in the phase
        :return: Default atom with a given name
        """
        type_symbol = Base(*ATOM_DETAILS['type_symbol']['default'])
        scat_length_neutron = Base(
            *ATOM_DETAILS['scat_length_neutron']['default'])
        fract_x = Base(*ATOM_DETAILS['fract']['default'])
        fract_y = Base(*ATOM_DETAILS['fract']['default'])
        fract_z = Base(*ATOM_DETAILS['fract']['default'])
        occupancy = Base(*ATOM_DETAILS['occupancy']['default'])
        adp_type = Base(*ATOM_DETAILS['adp_type']['default'])
        U_iso_or_equiv = Base(*ATOM_DETAILS['U_iso_or_equiv']['default'])
        ADp = ADP.default()
        MSp = MSP.default()

        return cls(atom_site_label, type_symbol, scat_length_neutron, fract_x,
                   fract_y, fract_z, occupancy, adp_type, U_iso_or_equiv, ADp,
                   MSp)
def test_Base_set_max():
    b = Base(1, 's')
    b.max = 10
    assert b.max == 10
    assert b['store']['max'] == 10
def test_Base_set_min():
    b = Base(1, 's')
    b.min = -10
    assert b.min == -10
    assert b['store']['min'] == -10
def test_Base_set_refine():
    b = Base(1, 's')
    b.refine = True
    assert b.refine is True
    assert b['store']['refine'] is True
def test_Base_get_value():
    b = Base(1, 's')
    assert b.value == 1
    assert b['store']['value'] == 1
def test_Base_value_in_unit():
    b = Base(1, 's')
    val = b.valueInUnit('h')
    assert val == 1 / 3600
def test_Base_convert_units():
    b = Base(1, 's')
    b.convertUnits('h')
    base_checker(b)
    assert b.value == 1 / 3600
    assert str(b['store']['unit']) == 'h'
def test_Base_unit_conversion_factor():
    b = Base(1, 's')
    fac = b.unitConversionFactor('h')
    assert fac == 1 / 3600
def test_Base_set():
    b = Base(1, 's')
    b.set('hide', False)
    assert b.get('hide') is False
def test_Base_get():
    b = Base(1, 's')
    assert b.get('hide') is True
def test_Base_set_value():
    b = Base(1, 's')
    b.value = 2
    assert b.value == 2
    assert b['store']['value'] == 2
def test_Base_get_refine():
    b = Base(1, 's')
    assert b.refine is False
    assert b['store']['refine'] is False