Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't mutate data structures #1317

Open
stevenrbrandt opened this issue Feb 15, 2021 · 5 comments
Open

Can't mutate data structures #1317

stevenrbrandt opened this issue Feb 15, 2021 · 5 comments

Comments

@stevenrbrandt
Copy link
Member

stevenrbrandt commented Feb 15, 2021

The following code

from phylanx import Phylanx

@Phylanx
def foo():
    a={"groups":1,"fish":2}
    b={"LEFT":a, "RIGHT":[3,4]}
    b["LEFT"]["groups"]=None

foo()

Throws this exception

Traceback (most recent call last):
  File "x.py", line 18, in <module>
    foo()
  File "/home/jovyan/.local/lib/python3.8/site-packages/phylanx-0.0.1-py3.8-linux-x86_64.egg/phylanx/ast/transducer.py", line 191, in __call__
    result = self.backend.call(*mapped_args, **mapped_kwargs)
  File "/home/jovyan/.local/lib/python3.8/site-packages/phylanx-0.0.1-py3.8-linux-x86_64.egg/phylanx/ast/physl.py", line 598, in call
    result = phylanx.execution_tree.eval(
RuntimeError:
<stack frames>
  [1]: x.py: foo2:: (Python)
  [2]: x.py(13, 0): lambda:: (PhySL)
  [3]: x.py(15, 4): variable$b:: (PhySL)
target object does not hold a numeric data type and as such does not support slicing: HPX(invalid_status)
@stevenrbrandt
Copy link
Member Author

Also, this variation is important

from phylanx import Phylanx

@Phylanx
def foo2(a):
    a["groups"] = None

@Phylanx
def foo():
    a={"groups":1,"fish":2}
    b={"LEFT":a, "RIGHT":[3,4]}
    foo2(b["LEFT"])

foo()

which yields

Traceback (most recent call last):
  File "x.py", line 13, in <module>
    foo()
  File "/home/jovyan/.local/lib/python3.8/site-packages/phylanx-0.0.1-py3.8-linux-x86_64.egg/phylanx/ast/transducer.py", line 191, in __call__
    result = self.backend.call(*mapped_args, **mapped_kwargs)
  File "/home/jovyan/.local/lib/python3.8/site-packages/phylanx-0.0.1-py3.8-linux-x86_64.egg/phylanx/ast/physl.py", line 598, in call
    result = phylanx.execution_tree.eval(
RuntimeError:
<stack frames>
  [1]: x.py: foo2:: (Python)
  [2]: x.py(8, 0): lambda:: (PhySL)
  [3]: x.py(4, 0): lambda:: (PhySL)
  [4]: x.py(5, 4): access-argument$a:: (PhySL)

storing a value to a local value has no effect: HPX(bad_parameter)

@hkaiser
Copy link
Member

hkaiser commented Feb 16, 2021

@stevenrbrandt currently parameters are always passed by value. So I'm not sure if we can solve this easily.

@stevenrbrandt
Copy link
Member Author

@hkaiser and I don't think the Random Forest code can be made to work unless it is solved. :(

@hkaiser
Copy link
Member

hkaiser commented Feb 18, 2021

@hkaiser and I don't think the Random Forest code can be made to work unless it is solved. :(

Any suggestions you might have would be welcome.

@stevenrbrandt
Copy link
Member Author

Maybe a less ambitious random forest, one which leaves the dictionary manipulation to Python, might be possible.
--Steve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants