-
Notifications
You must be signed in to change notification settings - Fork 11
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
Allow custom functions to be used for computing cache keys #284
Allow custom functions to be used for computing cache keys #284
Conversation
This is pretty nice. However, in the spirit of trying to not add functionality without a real need: Is there a real need for this? What would be a case where the default option does not work? |
one use case arises in connection with hurdles: assume that you have two objectives which both measure performance of a plasticity rule over a number of trials (small and large respectively). you want to use the disk cache for both objectives. for the first, you use the normal numpy evaluation check. but then for the second you might actually assign identical fitness values to those individuals which achieve identical fitness on the first objective, since it's very likely that they will have identical fitness on the second as well. this is a less strict equivalence check than numpy evaluation and hence catches more functionally (in terms of fitness on objective) identical individuals. |
ping @mschmidt87 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you add a test with a custom function? I can't see it, but perhaps I just missed it?
now i have ;) pls have another look |
Thanks. I will approve, but I am thinking that if this implies an API change, shouldn't we change the milestone to 1.0? |
well, many PRs have changed to API without us bumping to 1.0, and likely many future ones will (see issues). as far as i understand prior to release 1.0 we're technically still in the beta phase, and semantic versioning doesn't require us to bump major version upon API change:
|
cc71442
to
4e23405
Compare
thx! squashed and waiting for travis |
Currently the user can choose between computing a key for the disk cache all arguments and keyword arguments to the decorated function or from the result of evaluating an individual on random numpy arrays and the remaining arguments and keyword arguments.
This PR allows users to specify a function that is used to compute the key for the cache. Two functions are provided by the library: one uses the sympy expression of an individual and the remaining arguments, one the results of evaluating the individual on random numpy arrays and the remaining arguments. In addition the user can define any custom function they like provided its first argument is an individual instance and its return value is a float.