MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / dict2string

Method dict2string

dev/scripts/examples/example_generator.py:832–867  ·  view source on GitHub ↗
(self, d)

Source from the content-addressed store, hash-verified

830 return out
831
832 def dict2string(self, d):
833 if d['type'] == 'comment':
834 l = '% ' + d['comment']
835 elif d['type'] == 'function':
836 l = self.map_function(d['function']) + '(' + ', '.join(self.parse_arguments(d['arguments'])) + ')'
837 elif d['type'] == 'print':
838 args = self.parse_arguments(d['arguments'])
839 args = ['num2str(' + arg + ')' for arg in args]
840 l = 'disp([' + ', \' \', '.join(args) + '])'
841 elif d['type'] == 'vector':
842 args = self.parse_arguments(d['arguments'])
843 l = '[' + ', '.join(args) + ']'
844 elif d['type'] == 'enum':
845 l = self.enum_name_mapping[d['enum']] + '.' + d['key']
846 elif d['type'] == 'class_dereference':
847 l = d['name'] + '.' + self.dict2string(d['RHS'])
848 elif d['type'] == 'custom_assignment':
849 type_name = self.type_name_mapping[d['variable_type']]
850 if type_name:
851 LHS = type_name + ' ' + d['variable_name']
852 else:
853 LHS = d['variable_name']
854 # Custom processing for vector assignment
855 if d['RHS']['type'] != 'vector':
856 RHS = self.dict2string(d['RHS'])
857 else: # vector
858 pushes = [d['variable_name'] + '.push_back(' + arg + ');' for arg in d['RHS']['arguments']]
859 RHS = 'CoolProp.DoubleVector(); ' + ' '.join(pushes)
860
861 l = ' '.join([LHS, '=', RHS])
862 else:
863 l = '??????????????????????????????'
864
865 if 'EOL' in d and d['EOL']:
866 l += ';'
867 return l
868
869 def header(self):
870 return ''

Callers 1

parse_argumentsMethod · 0.95

Calls 2

parse_argumentsMethod · 0.95
map_functionMethod · 0.80

Tested by

no test coverage detected