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

Redesign signatures of compilation targets #294

Merged
merged 1 commit into from
Apr 23, 2021

Conversation

jakobj
Copy link
Member

@jakobj jakobj commented Mar 20, 2021

This PR aims at making the usage of the results from various to_... functions more intuitive. It also improves their documentation. In the following the new usage is described in more detail.

to_func -> f:

  • f expects the same number of arguments as the graph has input
  • each argument must be a single value
  • f returns a list of values, one for each output
  • if only one output is present it'll return only it's output value; not a list with one entry
    example usage:
f = ind.to_func()
y = f(1.0, 2.0)

to_numpy -> f:

  • f expects the same number of arguments as the graph has input
  • each argument must be a single numpy array of identical lengths
  • f returns a list of arrays, one for each output; each array will have the same length as all input arrays
  • if only one output is present it'll return only it's output array; not a list with one array
    example usage:
f = ind.to_numpy()
y = f(np.array([1.0, 1.1]), np.array([2.0, 2.1]))

to_sympy -> List[sympy expr] or single sympy expr

  • depending on the number of outputs, either a list of sympy expressions is returned or, for a single output, a single sympy expression

closes #287

@coveralls
Copy link
Collaborator

Coverage Status

Coverage decreased (-0.05%) to 94.332% when pulling 13c8362 on jakobj:enh/redesign-call-sig into 3411cba on Happy-Algorithms-League:master.

@mschmidt87
Copy link
Member

I think this branch needs to be rebased on master to pull in the changes in the continuous integration and make the checks run.

@jakobj
Copy link
Member Author

jakobj commented Apr 7, 2021

I think this branch needs to be rebased on master to pull in the changes in the continuous integration and make the checks run.

i rebased, thanks! ready for review :)

@jakobj
Copy link
Member Author

jakobj commented Apr 13, 2021

ping @mschmidt87 @HenrikMettler

Copy link
Contributor

@HenrikMettler HenrikMettler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two minor formulations which might be improved

cgp/cartesian_graph.py Outdated Show resolved Hide resolved
cgp/cartesian_graph.py Outdated Show resolved Hide resolved
cgp/cartesian_graph.py Outdated Show resolved Hide resolved
Copy link
Member

@mschmidt87 mschmidt87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in principle, thanks for doing this, looks like a tedious job. Added some suggestions.

cgp/cartesian_graph.py Outdated Show resolved Hide resolved
cgp/cartesian_graph.py Outdated Show resolved Hide resolved
cgp/cartesian_graph.py Outdated Show resolved Hide resolved
@jakobj
Copy link
Member Author

jakobj commented Apr 19, 2021

thanks @mschmidt87 @HenrikMettler for your comments, i've included most of them. please have another look.

@jakobj
Copy link
Member Author

jakobj commented Apr 22, 2021

ok, simplified the code in question @mschmidt87

also squashed all commits, let's see what CI thinks

@jakobj jakobj merged commit 8fa9888 into Happy-Algorithms-League:master Apr 23, 2021
@jakobj jakobj deleted the enh/redesign-call-sig branch April 23, 2021 14:15
@mschmidt87 mschmidt87 added the API change The label that should be avoided label May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change The label that should be avoided
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redesign call signatures of compilation targets
4 participants