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

Enable random functions to return arrays #309

Closed
enekomartinmartinez opened this issue Feb 10, 2022 · 0 comments · Fixed by #312
Closed

Enable random functions to return arrays #309

enekomartinmartinez opened this issue Feb 10, 2022 · 0 comments · Fixed by #312
Assignees

Comments

@enekomartinmartinez
Copy link
Collaborator

Currently random functions work returning a float

dim1: A,B,C~~|
var[dim1] = RANDOM UNIFORM(1,3) ~~|

returns a length 3 vector with different random numbers, however this is translated in PySD as:

@(["dim1"], _subscript_dict)
def var():
    return np.random.uniform(1, 3)

which will produce a unique random value and repeat it to generate a vector.

This should be done as:

@(["dim1"], _subscript_dict)
def var():
    return xr.DataArray(np.random.uniform(1, 3, size=(3,)), {"dim1": ["A", "B", "C"]}, ["dim1"])

I am working on it for a future release.

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

Successfully merging a pull request may close this issue.

1 participant