Skip to content
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

feat(neuron/netpyne): use %r instead of %e or %s #110

Open
wants to merge 11 commits into
base: development
Choose a base branch
from

Conversation

sanjayankur31
Copy link
Member

when writing recorded data to file.

%r or the repr function gives the "official" string representation of an object, so of a float too, while the %s or str method returns the "nicely printable string representation of an object".

Also, irrespective of which one we use, we must use the same for both NEURON and NetPyNE so that the outputs to files are of the same level of precision and same format etc.

With this PR, we get similar outputs for NEURON and NetPyNE:

image

instead of what we got before:

20231222-neuron-vs-netpyne-recording-data

I haven't checked other exports, but if they're also being exported to Python scripts, we should update them too.

when writing recorded data to file.

`%r` or the `repr` function gives the "official" string representation
of an object, so of a float too, while the `%s` or `str` method returns
the "nicely printable string representation of an object".

Also, irrespective of which one we use, we must use the same for both
NEURON and NetPyNE.
@pgleeson
Copy link
Member

Ok, sounds good. Have you tested some omv tolerance=0 tests when this change is incorporated? May well change the actual value detected in the tests...

@sanjayankur31
Copy link
Member Author

Ok, sounds good. Have you tested some omv tolerance=0 tests when this change is incorporated? May well change the actual value detected in the tests...

Testing them out now.

@sanjayankur31
Copy link
Member Author

Did quick tests on the Allen institute cells. There's some change in tolerances, but not very dramatic:

diff --git a/CellTypesDatabase/models/NeuroML2/.test.483108201.jnmlnrn.omt b/CellTypesDatabase/models/NeuroML2/.test.483108201.jnmlnrn.omt
index 5f770ec..d889c20 100644
--- a/CellTypesDatabase/models/NeuroML2/.test.483108201.jnmlnrn.omt
+++ b/CellTypesDatabase/models/NeuroML2/.test.483108201.jnmlnrn.omt
@@ -14,4 +14,4 @@ experiments:
         spike detection: 
           method: threshold
           threshold: -20
-        tolerance: 0.0141
+        tolerance: 0.014139835945066405
diff --git a/CellTypesDatabase/models/NeuroML2/.test.486556811.jnmlnrn.omt b/CellTypesDatabase/models/NeuroML2/.test.486556811.jnmlnrn.omt
index c1954b8..2a5a36f 100644
--- a/CellTypesDatabase/models/NeuroML2/.test.486556811.jnmlnrn.omt
+++ b/CellTypesDatabase/models/NeuroML2/.test.486556811.jnmlnrn.omt
@@ -14,4 +14,4 @@ experiments:
         spike detection: 
           method: threshold
           threshold: -20
-        tolerance: 0
+        tolerance: 4.79184638209975e-05
diff --git a/CellTypesDatabase/models/NeuroML2/.test.jnmlnrn.omt b/CellTypesDatabase/models/NeuroML2/.test.jnmlnrn.omt
index e0361c8..4a661bd 100644
--- a/CellTypesDatabase/models/NeuroML2/.test.jnmlnrn.omt
+++ b/CellTypesDatabase/models/NeuroML2/.test.jnmlnrn.omt
@@ -14,7 +14,7 @@ experiments:
         spike detection: 
           method: threshold
           threshold: 0
-        tolerance: 2.2e-5
+        tolerance: 2.179620615235586e-05
   Ca:
     observables:
       spike times:
@@ -25,4 +25,4 @@ experiments:
         spike detection: 
           method: threshold
           threshold: 0.0014
-        tolerance: 0.00021
+        tolerance: 0.00020718032716604502
diff --git a/CellTypesDatabase/models/NeuroML2/.test.kv2like.jnmlnrn.omt b/CellTypesDatabase/models/NeuroML2/.test.kv2like.jnmlnrn.omt
index 797aa53..439f91d 100644
--- a/CellTypesDatabase/models/NeuroML2/.test.kv2like.jnmlnrn.omt
+++ b/CellTypesDatabase/models/NeuroML2/.test.kv2like.jnmlnrn.omt
@@ -14,7 +14,7 @@ experiments:
         spike detection: 
           method: threshold
           threshold: 0.885
-        tolerance: 1e-5
+        tolerance: 3.1032996127945875e-06
   h1:
     observables:
       spike times:
@@ -25,7 +25,7 @@ experiments:
         spike detection: 
           method: threshold
           threshold: 0.885
-        tolerance: 1e-5
+        tolerance: 8.696556449203658e-06
   h2:
     observables:
       spike times:
@@ -36,4 +36,4 @@ experiments:
         spike detection: 
           method: threshold
           threshold: 0.885
-        tolerance: 4e-5
+        tolerance: 4.1525039775804706e-05
diff --git a/CellTypesDatabase/models/NeuroML2/.test.nav.jnmlnrn.omt b/CellTypesDatabase/models/NeuroML2/.test.nav.jnmlnrn.omt
index ed785ae..2ab22de 100644
--- a/CellTypesDatabase/models/NeuroML2/.test.nav.jnmlnrn.omt
+++ b/CellTypesDatabase/models/NeuroML2/.test.nav.jnmlnrn.omt
@@ -14,7 +14,7 @@ experiments:
         spike detection: 
           method: threshold
           threshold: 0.2
-        tolerance: 2e-5
+        tolerance: 4.90571147973973e-06
   I4:
     observables:
       spike times:
@@ -25,4 +25,4 @@ experiments:
         spike detection: 
           method: threshold
           threshold: 0.03
-        tolerance: 2e-5
+        tolerance: 1.984186110237916e-05

There may be other things in the neuron export I guess? Also worth looking into next?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

2 participants