Changeset 13515


Ignore:
Timestamp:
Sep 18, 2019 8:56:12 AM (3 months ago)
Author:
randersson
Message:

#5819 Replaced tabs with spaces because they are causing TabError in Python 3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-5819/Python/src/tests_jmodelica/optimization/test_greybox.py

    r13461 r13515  
    7575    # input data
    7676    for inp in list(inputs.keys()):
    77         evaluated_input = ext_data.eliminated[inp].eval(time)
    78         N.array_equal(inputs[inp], evaluated_input)
     77        evaluated_input = ext_data.eliminated[inp].eval(time)
     78        N.array_equal(inputs[inp], evaluated_input)
    7979    # measurement data
    8080    for meas in list(measurements.keys()):
    81         evaluated_meas = ext_data.eliminated['GreyBox_measured_'+meas].eval(time)
    82         N.array_equal(measurements[meas], evaluated_meas)
    83        
    84     # Assert objective and objective integrand
     81        evaluated_meas = ext_data.eliminated['GreyBox_measured_'+meas].eval(time)
     82        N.array_equal(measurements[meas], evaluated_meas)
     83       
     84    # Assert objective and objective integrand
    8585    assert strnorm(GB.op.getObjectiveIntegrand().getDescription()) == strnorm('(((0.499*sq((E-GreyBox_measured_E)))/GreyBox_r_E)+((0.499*sq((P-GreyBox_measured_P)))/GreyBox_r_P))')
    8686    assert strnorm(GB.op.getObjective().getDescription()) == strnorm('((((500*log(GreyBox_r_E))+(sq((E(0.000000)-133.837))/GreyBox_r_E))+(500*log(GreyBox_r_P)))+(sq((P(0.000000)-138))/GreyBox_r_P))')
     
    124124    ext_data = GB.options['external_data']
    125125    for inp in list(inputs.keys()):
    126         evaluated_input = ext_data.eliminated[inp].eval(time)
    127         N.array_equal(inputs[inp], evaluated_input)
    128 
    129     # Assert objective and objective integrand
     126        evaluated_input = ext_data.eliminated[inp].eval(time)
     127        N.array_equal(inputs[inp], evaluated_input)
     128
     129       # Assert objective and objective integrand
    130130    assert strnorm(GB.op.getObjectiveIntegrand().getDescription()) == strnorm('0')
    131131    print(strnorm(GB.op.getObjective().getDescription()))
     
    173173   
    174174    for par in nullModelFree:
    175         assert identification.greybox.op.getVariable(par).getAttribute('free').getValue() == 1.0
    176        
     175        assert identification.greybox.op.getVariable(par).getAttribute('free').getValue() == 1.0
     176       
    177177    #Assert value of free variables
    178178    res = identification.result
     
    196196    # remove every third measurement to get nonuniform distribution of measurements
    197197    for var in list(measurements.keys()):
    198         measurements[var] = N.delete(measurements[var], slice(None, None, 3))
     198        measurements[var] = N.delete(measurements[var], slice(None, None, 3))
    199199   
    200200    time = N.delete(time, slice(None, None, 3)) 
     
    282282    #Assert that parameters are really free
    283283    for par in freeParam1:
    284         assert identification.greybox.op.getVariable(par).getAttribute('free').getValue() == 1.0
     284        assert identification.greybox.op.getVariable(par).getAttribute('free').getValue() == 1.0
    285285   
    286286   
     
    297297    #Assert that parameters are really free
    298298    for par in freeParam2:
    299         assert identification.greybox.op.getVariable(par).getAttribute('free').getValue() == 1.0
     299        assert identification.greybox.op.getVariable(par).getAttribute('free').getValue() == 1.0
    300300   
    301301    # Assert that 'TD' is no longer free
     
    317317@testattr(casadi_base = True)
    318318def test_risk_calculation():
    319    
     319   
    320320    idObj = Identification([],[],[],0)
    321321   
     
    324324
    325325def get_test_data():
    326    
     326   
    327327    return OrderedDict([('measurements', OrderedDict([('E', N.array([ 133.83652165,  132.49324086,  129.12398945,  124.58144881,
    328328        123.86837942,  122.8498228 ,  120.6938312 ,  119.34490856,
Note: See TracChangeset for help on using the changeset viewer.