/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_transformer.py in visit_Call(self, node)
577 elif isinstance(node.func, ast.Attribute):
--> 578 if not node.starargs is None or not node.kwargs is None:
579 raise UnsupportedFeatureException("Only arguments without default values are supported in calls")
AttributeError: 'Call' object has no attribute 'starargs'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_transformer.py in body_visit(self, stmts)
641 try:
--> 642 self.exprs.append(self.visit(stmt))
643 except Exception as ex:
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_tosource.py in visit_Call(self, node)
440 self.visit(keyword.value)
--> 441 if node.starargs is not None:
442 write_comma()
AttributeError: 'Call' object has no attribute 'starargs'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
in ()
9 def hope_exp(X,Y,Z,A):
10 A[:] = hope.exp((X**2+Y**2)/Z)
---> 11 hope_exp(x,y,z,out)
12 np.exp((x**2 + y**2)/z)
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_wrapper.py in _hope_callback(*args)
69
70 def _hope_callback(*args):
---> 71 return self(*args) if self.cache is None else self.cache(*args)
72 self.callback = _hope_callback
73 setattr(cache, str(id(self.callback)), fkt)
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_wrapper.py in __call__(self, *args)
75
76 def __call__(self, *args):
---> 77 ASTTransformer(self.modtoken).module_visit(self.fkt, args)
78
79 if config.optimize:
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_transformer.py in module_visit(self, fkt, args, argid)
690 if argid is None or not argid in self.modtoken.functions[fkt.__name__]:
691 #Create the HOPE AST from the builtin AST
--> 692 parsed = self.visit(fktast)
693 if not parsed.getId() in [arg.getId() for arg in self.modtoken.functions[fkt.__name__]]:
694 self.modtoken.functions[fkt.__name__].append(parsed)
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/ast.py in visit(self, node)
251 method = 'visit_' + node.__class__.__name__
252 visitor = getattr(self, method, self.generic_visit)
--> 253 return visitor(node)
254
255 def generic_visit(self, node):
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_transformer.py in visit_FunctionDef(self, node)
627
628 # TODO: how do we parse recursive subfuncitons?
--> 629 self.token.body = self.body_visit(node.body)
630 AllocateVisitor(self.variables).visit(self.token.body)
631 merged = {}
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_transformer.py in body_visit(self, stmts)
644 if "\nin body " not in (ex.args[0] if ex.args else ""):
645 from hope._tosource import tosource
--> 646 ex.args = ((ex.args[0] if ex.args else "") + "\nin body " + tosource(stmt),) + ex.args[1:]
647 raise
648 for expr in self.exprs:
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_tosource.py in tosource(node, indent_with, add_line_information)
76
77 generator = SourceGenerator(indent_with, add_line_information)
---> 78 generator.visit(node)
79
80 return ''.join(generator.result)
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/ast.py in visit(self, node)
251 method = 'visit_' + node.__class__.__name__
252 visitor = getattr(self, method, self.generic_visit)
--> 253 return visitor(node)
254
255 def generic_visit(self, node):
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_tosource.py in visit_Assign(self, node)
172 self.visit(target)
173 self.write(' = ')
--> 174 self.visit(node.value)
175
176 def visit_AugAssign(self, node):
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/ast.py in visit(self, node)
251 method = 'visit_' + node.__class__.__name__
252 visitor = getattr(self, method, self.generic_visit)
--> 253 return visitor(node)
254
255 def generic_visit(self, node):
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_tosource.py in visit_Call(self, node)
439 self.write(keyword.arg + '=')
440 self.visit(keyword.value)
--> 441 if node.starargs is not None:
442 write_comma()
443 self.write('*')
AttributeError: 'Call' object has no attribute 'starargs'
Readme example:
Additionally, the standard sum example from the readme gives this error in 3.6.1 but works in 2.7:
TypeError Traceback (most recent call last)
in ()
4 def sums(x, y):
5 return x + y
----> 6 sums(x,y)
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_wrapper.py in _hope_callback(*args)
69
70 def _hope_callback(*args):
---> 71 return self(*args) if self.cache is None else self.cache(*args)
72 self.callback = _hope_callback
73 setattr(cache, str(id(self.callback)), fkt)
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_wrapper.py in __call__(self, *args)
102 fp.write(code)
103
--> 104 so_filename = _compile(tempfolder, localfilename, self.fkt.__name__)
105
106 self._store_state(tempfolder, localfilename)
/Users/edouglas/anaconda/envs/astroconda/lib/python3.6/site-packages/hope/_wrapper.py in _compile(target, localfilename, fkt_name)
271 try:
272 #trying to encode utf-8 to support AstroPy
--> 273 warnings.warn("A warning has been issued during compilation:\n{0}".format(out).encode('utf-8'))
274 except UnicodeError:
275 #encoding fails on Linux
TypeError: cannot use a string pattern on a bytes-like object
Hope doesn't support python3.6 and is no longer officially supported. However, there is an incomplete PR that attempts to support the lastest python release: https://github.com/jakeret/hope/pull/56
The following code works in Python 2.7 on in macOS 10.13:
but in Python 3.6.1 it returns the following error:
Readme example:
Additionally, the standard sum example from the readme gives this error in 3.6.1 but works in 2.7: