Comments (4)
Pathos looks good to me! Agree that it could be an optional extra - the boilerplate for throwing the error when the function is called instead of on import would only need to be written in the decorator definition.
I'm aware of dill but am not very familiar with it - with any luck it allows out-of-band data like pickle 5 does. That significantly speeds up the ser/deser of numpy arrays. The default pickle has been 4 since python 3.8, so I suspect that's what the multiprocessing queues use 👎 .
An alternative way of dispatching operations over neuronlists would be something like this, implementing the parallelisation on the neuronlist:
def prune_neuron(neuron, param, more_params=None):
...
return changed_neuron
class NeuronList:
...
def map(self, fn, *args, parallel=None, **kwargs):
if parallel:
...
else:
neurons = [fn(n, *args, **kwargs) for n in self]
return type(self)(neurons)
You could still have a decorator as you suggest, it could just delegate its parallelism to NeuronList.map
. I don't have strong feelings about which one to prefer!
In general I think it's a great step to factor out the dataframe/treeneuron/neuronlist into some shared implementation; same for handling parallelism setup (e.g. None
for serial, 0
for max(1, (os.cpu_count() or 0) - 1)
), although that might be a bit more tricky as sometimes you want more spare CPUs, or you prefer to use threading or whatever.
from navis.
Actually your other suggestion already exists in NeuronList.apply
:)
I was thinking of keeping that because it generalizes to any function - including non-navis functions. The advantage of the decorator is that we know that the output will be a NeuronList which makes some things easier.
from navis.
Aha! My Ctrl+f was insufficient. Yes, that makes sense!
from navis.
Implemented with 1c8ffe6
from navis.
Related Issues (20)
- cut_skeleton memory issues HOT 2
- Minor: documentation on navis.Volume HOT 1
- Thoughts on synblast HOT 1
- Set DYLD_LIBRARY_PATH for elastix on MacOS HOT 2
- Custom colored connectors in plot2d is broken
- New numpy version leads to AttributeError HOT 5
- Traversal model make new nodes which is not in edges HOT 5
- downsample_neuron does not reassign connectors
- split_axon_dendrite fails for big neurons HOT 2
- Handle symlinked `transformix` executables HOT 1
- Excitatory / Inhibitory information about synapses in neuprint HOT 2
- Advice for M1 mac installation HOT 8
- Mapping TreeNeuron presynapses to postsynaptic bodyID HOT 2
- improve strahler_index HOT 4
- read_swc: strange behaviour when file path contains typo HOT 2
- New feature: split connectivity HOT 3
- Bug changing connector size in navis.2d_plot() HOT 2
- Make function signatures more consistent
- New system for ultrastructural features
- Make nbl.smat.LookupNdBuilder more generic HOT 2
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 navis.