Comments (4)
In this case, the problem isn't that the Distance
instance is used as a class default for termination_measure
, it's that there is an instance created as the default argument to termination_measure
in __init__
:
This is created once on import, and then used for every TransferMechanism without that argument specified. In general, the exact object passed in to a constructor will be used as the parameter value. The exception is for the function
parameter, which would make a copy of the object if it was already used by another Mechanism
(the function's owner
is not None).
A quick fix would be to just set the default argument value in TransferMechanism.__init__
above to None. This would have the default set properly for termination_measure
, (And in general, they should be None, so the _user_specified
Parameter flag is set correctly, so this would be a good change regardless) but it would still leave this example with the current behavior:
>>> dist = pnl.Distance()
>>> a = pnl.TransferMechanism(termination_measure=dist)
>>> b = pnl.TransferMechanism(termination_measure=dist)
>>> a.defaults.termination_measure is b.defaults.termination_measure
True
I think in general though, the function
behavior should be expanded to other "subfunction" parameters
from psyneulink.
is the change in init a one-liner that should work, or does it trigger changes elsewhere? Do you have plans to work on it?
The example is OK. It probably won't work with compilation, but the sharing is clearly intended.
from psyneulink.
The change should work, because the Parameter default will be used when the argument to init is None. Using None should be the correct pattern in general because it will let us know if the user passed in an argument or not. It's been a low priority task to go through and change all those, but it can be bumped up as necessary. I have a commit that will make the change in this case, but it looks like I haven't pushed it yet.
I guess I'm not sure what's the best thing to do with the example. For function
we definitely wanted protection from instances being shared; I'm not sure if the same pattern should hold for other parameters that happen to take functions.
from psyneulink.
Fixed in ded82bf
from psyneulink.
Related Issues (20)
- Behavior for conflicts between shared parameters
- Potential for false-passing tests due to np.allclose use
- Integrate more optimization algorithms into PEC HOT 2
- MCMC
- using torch<1.12.0 fails cross_entropy tests
- Support for Python 3.11 HOT 2
- Components should be reset when state changes are not due to execution
- Standardize component constructor params/param_defaults/kwargs
- TransferWithCosts: Intensity cost is `[1]` even when intensity cost is disabled HOT 1
- TransferWithCosts: Shape of the variable of the combination function is always single element array
- Missing line from documentation comment HOT 1
- ControlSignal costs are calculated twice HOT 7
- incorrect warning about missing afferent projections
- log nparray() drops entries with duplicate time points. HOT 2
- Intermittent failures in `test_parameter_optimization_ddm[LLVM-optuna_cmaes_sampler]` HOT 5
- [Python 3.12] Embedded versioneer doesn't support Python 3.12 HOT 1
- Add support for Python 3.12 HOT 1
- Failures in mdf test using numpy 1.25+ HOT 1
- Learning resources HOT 9
- PEC not working with new stability flexibility version HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psyneulink.