Beispiel #1
0
def TEST_arithmetics():
    fieldProxy0 = FieldProxy(fieldHandlerList[0])
    fieldProxy1 = FieldProxy(fieldHandlerList[1])

    # Standard operations where operandes are fields
    res = fieldProxy0 + fieldProxy1
    if res is None: return False
    res = fieldProxy0 - fieldProxy1
    if res is None: return False
    res = fieldProxy0 * fieldProxy1
    if res is None: return False
    res = fieldProxy0 / fieldProxy1

    # Standard operations with scalar operandes
    res = fieldProxy0 + 3.4
    if res is None: return False
    res = 3.4 + fieldProxy0
    if res is None: return False
    res = fieldProxy0 - 3.4
    if res is None: return False
    res = 3.4 - fieldProxy0
    if res is None: return False
    res = fieldProxy0 * 3.4
    if res is None: return False
    res = 3.4 * fieldProxy0
    if res is None: return False
    res = fieldProxy0 / 3.4
    if res is None: return False
    res = 3.4 / fieldProxy0
    if res is None: return False

    return True
def TEST_modification_of_attributes():
    fieldProxy0 = FieldProxy(fieldHandlerList[0])
    id_ref = fieldProxy0.id
    fieldname_ref = fieldProxy0.fieldname
    meshname_ref = fieldProxy0.meshname

    #
    # This operations are not allowed, or not that way
    #
    # This should print that it is not allowed:
    fieldProxy0.id = id_ref+3
    if fieldProxy0.id != id_ref:
        print "ERR: the id should be %d (%d found)"%(id_ref,fieldProxy0.id)
        return False
    # This should print that it must be done using the command update
    fieldProxy0.fieldname = fieldname_ref+"toto"
    if fieldProxy0.fieldname != fieldname_ref:
        print "ERR: the fieldname should be %s (%s found)"%(fieldname_ref,fieldProxy0.fieldname)
        return False
    # This should print that it is not allowed:
    fieldProxy0.meshname = meshname_ref+"titi"
    if fieldProxy0.meshname != meshname_ref:
        print "ERR: the meshname should be %s (%s found)"%(meshname_ref,fieldProxy0.meshname)
        return False

    return True
Beispiel #3
0
def TEST_modification_of_attributes():
    fieldProxy0 = FieldProxy(fieldHandlerList[0])
    id_ref = fieldProxy0.id
    fieldname_ref = fieldProxy0.fieldname
    meshname_ref = fieldProxy0.meshname

    #
    # This operations are not allowed, or not that way
    #
    # This should print that it is not allowed:
    fieldProxy0.id = id_ref + 3
    if fieldProxy0.id != id_ref:
        print "ERR: the id should be %d (%d found)" % (id_ref, fieldProxy0.id)
        return False
    # This should print that it must be done using the command update
    fieldProxy0.fieldname = fieldname_ref + "toto"
    if fieldProxy0.fieldname != fieldname_ref:
        print "ERR: the fieldname should be %s (%s found)" % (
            fieldname_ref, fieldProxy0.fieldname)
        return False
    # This should print that it is not allowed:
    fieldProxy0.meshname = meshname_ref + "titi"
    if fieldProxy0.meshname != meshname_ref:
        print "ERR: the meshname should be %s (%s found)" % (
            meshname_ref, fieldProxy0.meshname)
        return False

    return True
Beispiel #4
0
def TEST_composition():
    # In this test, we combine operandes that are supposed
    # to be compatible. We expect that no error occur.
    fieldProxy0 = FieldProxy(fieldHandlerList[0])
    fieldProxy1 = FieldProxy(fieldHandlerList[1])

    res = pow(fieldProxy0, 2) + fieldProxy1
    if res is None: return False

    return True
Beispiel #5
0
def setup():
    """
    This function defines a set of field variable for quick tests in
    the python console. You just have to execute the function to get
    the variables defined in the global context.
    """
    fh1 = fieldHandlerList[0]
    fh2 = fieldHandlerList[1]
    f1 = FieldProxy(fh1)
    f2 = FieldProxy(fh2)
    return fh1, fh2, f1, f2
Beispiel #6
0
def TEST_unary_operations():
    fieldProxy0 = FieldProxy(fieldHandlerList[0])

    res = fieldProxy0.dup()
    if res is None: return False
    res = xmed.dup(fieldProxy0)
    if res is None: return False
    res = pow(fieldProxy0, 2)
    if res is None: return False

    return True
def TEST_unary_operations():
    fieldProxy0 = FieldProxy(fieldHandlerList[0])

    res = fieldProxy0.dup()
    if res is None: return False
    res = xmed.dup(fieldProxy0)
    if res is None: return False
    res = pow(fieldProxy0,2)
    if res is None: return False

    return True
Beispiel #8
0
def TEST_update_metadata():
    fieldProxyRef = FieldProxy(fieldHandlerList[0])
    id = fieldProxyRef.id

    name_ref = "toto"
    fieldProxyRef.update(name=name_ref)

    fieldProxyRes = xmed.get(id)
    name_res = fieldProxyRes.fieldname
    if name_res != name_ref:
        print "ERR: the fieldname should be %s (%s found)"%(name_ref,name_res)
        return False
    return True
Beispiel #9
0
def TEST_addition():
    fieldHandler0 = fieldHandlerList[0]
    fieldHandler1 = fieldHandlerList[1]

    # The addition can be done using field handler directly
    addFieldHandler = xmed.calculator.add(fieldHandler0, fieldHandler1)
    print addFieldHandler

    # Or with a field proxy that ease the writing of operations
    fieldProxy0 = FieldProxy(fieldHandler0)
    fieldProxy1 = FieldProxy(fieldHandler1)

    res = fieldProxy0 + fieldProxy1
    if res is None: return False

    return True
Beispiel #10
0
def TEST_use_restriction():
    fieldProxy0 = FieldProxy(fieldHandlerList[0])
    res = fieldProxy0("c=1;g='toto'")
    if res is None: return False
    return True
Beispiel #11
0
def TEST_litteral_equation():
    fieldProxy0 = FieldProxy(fieldHandlerList[0])
    res = fieldProxy0.ope("abs(u)^2")
    if res is None: return False
    return True
def TEST_litteral_equation():
    fieldProxy0 = FieldProxy(fieldHandlerList[0])
    res = fieldProxy0.ope("abs(u)^2")
    if res is None: return False
    return True