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

[MRG] check section lengths match L-parameter #373

Merged
merged 2 commits into from
Jun 24, 2021

Conversation

cjayb
Copy link
Collaborator

@cjayb cjayb commented Jun 23, 2021

Closes #330 by adding a test to check sec.L matches the difference in sec.z3d(1) - sec.z3d(0).

I added a few lines to Cell based on the NEURON docs for pt3dadd:

h.pt3dconst(0, sec=sec)
...
h.define_shape()

@cjayb cjayb changed the title TST check section lengths match L-parameter [MRG] check section lengths match L-parameter Jun 23, 2021
@codecov-commenter
Copy link

codecov-commenter commented Jun 23, 2021

Codecov Report

Merging #373 (ad1a73c) into master (572b3fe) will decrease coverage by 0.11%.
The diff coverage is 100.00%.

❗ Current head ad1a73c differs from pull request most recent head 48298e1. Consider uploading reports for the commit 48298e1 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #373      +/-   ##
==========================================
- Coverage   89.93%   89.81%   -0.12%     
==========================================
  Files          16       15       -1     
  Lines        2930     2897      -33     
==========================================
- Hits         2635     2602      -33     
  Misses        295      295              
Impacted Files Coverage Δ
hnn_core/cell.py 97.38% <100.00%> (+0.02%) ⬆️
hnn_core/__init__.py 100.00% <0.00%> (ø)
hnn_core/network_models.py
hnn_core/network.py 93.38% <0.00%> (+1.46%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 572b3fe...48298e1. Read the comment docs.

for pt in p_secs[sec_name]['sec_pts']:
h.pt3dadd(pt[0] + dx,
pt[1] + dy,
pt[2] + dz, 1, sec=sec)
# with pt3dconst==0, these will alter the 3d points defined above!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I suppose this essentially functions to define the direction in which the section points?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That must be it, yes, though the documentation manages to be pretty unclear...

@@ -1,6 +1,7 @@
import pytest

from neuron import h
from numpy import allclose, abs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from numpy import allclose, abs
import numpy as np

more standard

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the other issue is that you are overriding the abs that comes natively from python that may lead to unexpected issues.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, bad form...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix this and I'll merge :)

Comment on lines 22 to 31
# check that after building, the vertical sections have the length
# specified in get_L5Pyr_params_default (or overriden in a params file).
# Note that the lengths implied by _secs_L5Pyr are completely ignored:
# NEURON extends the sections as needed to match the sec.L 's
vertical_secs = ['basal_1', 'soma', 'apical_trunk', 'apical_1', 'apical_2',
'apical_tuft']
for sec_name in vertical_secs:
sec = l5p.sections[sec_name]
vert_len = abs(sec.z3d(1) - sec.z3d(0))
assert allclose(vert_len, sec.L)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test passes on master ... in other words it's not testing the new functionality

this is why I suggest starting by writing the test first

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or I suppose the point of this PR is only to clarify the code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this is intended to allow us to close #330 knowing that it won't bite us in the rear end when we start accepting section points other than those hard-coded in the private functions _secs_*{Pyr|Basket}

@@ -325,10 +325,12 @@ def _create_sections(self, p_secs, topology):
self.sections[sec_name] = sec

h.pt3dclear(sec=sec)
h.pt3dconst(0, sec=sec) # be explicit, see documentation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed when there is h.define_shape? I feel one is enough ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither are really needed (as you pointed out, the code worked before)

  • pt3dconst is set to '0' by default; I thought I'd make it explicit here to remind ourselves.
  • from the doc of pt3dadd:

Note: When L is changed, h.define_shape() should be executed to adjust the 3-d info so that branches appear connected.

I think it hasn't been a problem because none of our dendrites branch. Or do the last too basal ones...? I'm uncertain.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can I just put it on record that I hate strongly dislike Neuron documentation :) Instead of raising sane errors, the onus is on the user to make sure things are executed in certain order with statements like "this may happen if you do this, but it may not be so bad ...".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll counter-sign that one, and you can pick an even stronger word if you'd like ;)

@jasmainak jasmainak merged commit fe9cfb8 into jonescompneurolab:master Jun 24, 2021
@jasmainak
Copy link
Collaborator

Thanks @cjayb !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

section points and lengths don't match
4 participants