sim-ballena 0.1.2__tar.gz → 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sim-ballena might be problematic. Click here for more details.

@@ -4,7 +4,7 @@ version = 4
4
4
 
5
5
  [[package]]
6
6
  name = "SimBallenaSNN"
7
- version = "0.1.2"
7
+ version = "0.1.3"
8
8
  dependencies = [
9
9
  "pyo3",
10
10
  "rand",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "SimBallenaSNN"
3
- version = "0.1.2"
3
+ version = "0.1.3"
4
4
  edition = "2024"
5
5
 
6
6
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sim_ballena
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -8,6 +8,7 @@ const MAX_PRECISION :f64 = 100_000.0;
8
8
  /* ======= OBJECTS ========= */
9
9
  /* ========================== */
10
10
  #[derive(Clone)]
11
+ #[derive(Debug)]
11
12
  struct VoltageMarker{
12
13
  pub t : f64,
13
14
  pub v : f64,
@@ -198,13 +199,13 @@ impl Response{
198
199
  let tau_list = self.tau_list.as_ref().unwrap();
199
200
  let v_rest_list = self.v_rest_list.as_ref().unwrap();
200
201
 
201
- for i in 0..self.outputs.len(){
202
+ for (o_idx,o) in self.outputs.iter().enumerate(){
202
203
  let markers_serie:Vec<&VoltageMarker> = self.voltages.iter()
203
- .filter(|vm|vm.id==i)
204
+ .filter(|vm|vm.id==*o)
204
205
  .collect();
205
206
 
206
- let tau = *tau_list.get(i).unwrap();
207
- let v_rest = *v_rest_list.get(i).unwrap();
207
+ let tau = *tau_list.get(o_idx).unwrap();
208
+ let v_rest = *v_rest_list.get(o_idx).unwrap();
208
209
  voltages.push( self.extract_voltage_serie(markers_serie, simulation_times, tau, v_rest) );
209
210
  }
210
211
 
@@ -0,0 +1,37 @@
1
+ import sim_ballena as ballena
2
+ import matplotlib.pyplot as plt
3
+
4
+
5
+ net = (ballena.Network( [ballena.Lif().tau(5),ballena.Lif().tau(0.2)] )
6
+ .synapses_net([])
7
+ .weights_net([])
8
+ .outputs([1])
9
+ .mode(['VOLTAGES','SPIKES']))
10
+
11
+
12
+
13
+ # ==========
14
+ # STEP 1
15
+ # ==========
16
+ net = net.synapses_in([(0,0),(0,1)])
17
+ net = net.weights_in([10,10])
18
+
19
+ times = [ (1, 0) ]
20
+ instance = ballena.Instance( times )
21
+ res = net.simulate( instance, 2 )
22
+
23
+ time = res.time()
24
+ volt = res.voltages()
25
+
26
+ plt.figure(figsize=(10,5))
27
+ plt.subplot(121)
28
+ plt.ylim(-80,-55)
29
+ plt.plot( time, volt[0], label='true')
30
+ # plt.subplot(122)
31
+ # plt.ylim(-80,-55)
32
+ # plt.plot( time, volt[1], label='true')
33
+
34
+ plt.show()
35
+
36
+
37
+
@@ -1,49 +0,0 @@
1
- import sim_ballena as ballena
2
- import matplotlib.pyplot as plt
3
-
4
-
5
- net = (ballena.Network( ballena.Lif().tau(5).t_refractory(0).repeat(2) )
6
- .synapses_net([])
7
- .weights_net([])
8
- .outputs([0,1])
9
- .mode(['VOLTAGES','SPIKES']))
10
-
11
-
12
-
13
- # ==========
14
- # STEP 1
15
- # ==========
16
- net = net.synapses_in([(0,0),(0,1),(1,0),(1,1)])
17
- net = net.weights_in([16,0,-16,0])
18
-
19
- times = [ (1, 0), (5, 1) ]
20
- instance = ballena.Instance( times )
21
- res = net.simulate( instance, 10 )
22
-
23
- time = res.time()
24
- volt = res.voltages()
25
- plt.figure(figsize=(10,4))
26
- plt.subplot(121)
27
- plt.plot( time, volt[0], label='true')
28
- plt.subplot(122)
29
- plt.plot( time, volt[1], label='false')
30
- plt.show()
31
-
32
- # ==========
33
- # STEP 1
34
- # ==========
35
- net = net.weights_in([16,0,-16,0])
36
-
37
- times = [ (1, 0), (5, 1) ]
38
- instance = ballena.Instance( times )
39
- res = net.simulate( instance, 10 )
40
-
41
- time = res.time()
42
- volt = res.voltages()
43
- plt.figure(figsize=(10,4))
44
- plt.subplot(121)
45
- plt.plot( time, volt[0], label='true')
46
- plt.subplot(122)
47
- plt.plot( time, volt[1], label='false')
48
- plt.show()
49
-
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes