0

I'm new to Python (and to stackoverflow) and my first task is to convert an energy flow simulation program from Python 2.7 to Python 3.6 and get it running on 3.6. I already used the 2to3 converter and solved some other errors but now I'm hitting a wall with this error, not knowing if it's an error of the existing program or if I use the wrong syntax etc. The code apparently worked in Python 2. If I additionaly put in house_atrs in the function it will start the function but throws a long list of other errors. So I hope for your help and would like to understand the reason of this error in 3.6 compared to 2.7.

Error:

Traceback (most recent call last):
  File "D:\Users\hs\workspace\selfsuffbat\vpp_interface_refpool_noPCR_161026.py",
  line 85, in <module>
    analyze(sim_atrs, output_folder, output_subfolder, economic=True, binary=True)
TypeError: analyze() missing 1 required positional argument: 'output_subfolder'

Code of vpp_interface_refpool_noPCR161026.py:

from pool_builder import pool_df
from main import simulate
from main import analyze    

if __name__ == '__main__':

  output_folder = 'output/data/'
  output_subfolder = 'refpool_noPCR'

[...]

  simulate(house_atrs, sim_atrs, sim_args, output_folder, output_subfolder)
  analyze(sim_atrs, output_folder, output_subfolder, economic=True, binary=True)

Code of the function analyze() in main.py:

def analyze(sim_atrs, house_atrs, output_folder, output_subfolder, economic=True, economic_standalone=False, binary=False):
  print('started analyzing')
  analysis(folder=output_folder, subfolder=output_subfolder, fileindata=None, firstloop=True, binary=binary,
         usegreengrey=sim_atrs['use_greengrey'], usedegradation=sim_atrs['use_degradation'],
         uselocalbalance=sim_atrs['use_localbalance'], providePCR=sim_atrs['provide_pcr'],
         usethermal=sim_atrs['use_thermal_load'])
  if economic:
    assert economic_standalone is False, 'Set "economic" to False and "economic_standalone" to True for standalone calculations'
    economic_calc(output_folder, output_subfolder, year=2015, useselfsufficiency=sim_atrs['use_localbalance'])

  elif economic_standalone:
    assert economic is False, 'Set "economic" to True and "economic_standalone" to False for pooled calculations'
    economic_standalone_calc(output_folder, output_subfolder, year=2015, useselfsufficiency=sim_atrs['use_localbalance'])

  print('finished analyzing')

if __name__ == '__main__':
  pass
Hen Ren
  • 29
  • 6
  • 2
    The error is quite descriptive. Seems you need to pass ``house_atrs`` as the second argument, which would then make it 4/4 positional arguments, where you're currently only passing 3/4. – Mike Scotty May 25 '18 at 12:02
  • 1
    This problem has nothing to do with the Python 3 migration--it's obvious that the code wouldn't work in Python 2 either. – John Zwinck May 25 '18 at 12:03
  • 1
    Unfortunately your edit makes this question quite different and no information to address the new one is given (as error message). – guidot May 25 '18 at 12:07
  • I'm wondering because all other old (2.7) interfaces have the same line of code without house_atrs in analyze(). So I get a step further but I don't know if this is intended. Anyway thank you very much for your help to a total beginner. – Hen Ren May 25 '18 at 12:20

0 Answers0