Skip to content

Commit

Permalink
creating wrapping function for particle sizes to make things faster
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmine-schoch committed Mar 7, 2024
1 parent 92defe2 commit 3be7505
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
18 changes: 16 additions & 2 deletions API/oursin/particles.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def create(num_particles):
num_particles : int
Examples
--------
--------
>>> neurons = urchin.particles.create(3)
"""
global counter
Expand Down Expand Up @@ -191,7 +191,21 @@ def set_sizes(particles_list, sizes_list):
neurons_sizes[neuron.id] = utils.sanitize_float(sizes_list[i])
else:
warnings.warn(f"Particle with id {neuron.id} does not exist in Unity, call create method first.")
client.sio.emit('SetParticleSize', neurons_sizes)

_set_sizes(neurons_sizes)

def _set_sizes(data):
"""Set particles sizes when already wrapped
Parameters
----------
neurons_sizes: dictionaryy of neuron id: float of particle size
Examples
--------
>>> urchin.particles._set_sizes({p1:0.01, p2:0.02, p3:0.03})
"""
client.sio.emit('SetParticleSize', data)

def set_colors(particles_list, colors_list):
"""Set neuron colors
Expand Down
21 changes: 21 additions & 0 deletions API/oursin/ui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Interactive components within notebooks"""


def slider_widget(function_call, slider_parameters):
"""Creates a slider in the notebook, displays results of the input function
Parameters
----------
function_call: function established earlier in code
slider_parameters: list of start, stop, and increment for slider to follow
Examples
---------
>>> urchin.ui.slider_widget(update_sizes_from_firing)
"""
try:
import ipywidgets as widgets
except ImportError:
raise ImportError("Widgets package is not installed. Please pip install ipywidgets to use this function.")
# widgets.interact(function_call, t=(slider_parameters[0],slider_parameters[1],slider_parameters[2]))

0 comments on commit 3be7505

Please sign in to comment.