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

Convenience: shorter code to build decor. #1903

Merged

Conversation

thorstenhater
Copy link
Contributor

@thorstenhater thorstenhater commented Jun 9, 2022

Add method chaining to decor::{place, paint, set_default}, so that we can now write

auto decor = arb::decor{}
  .paint("soma"_lab, arb::density("hh"))
  .paint("dend"_lab, arb::density("pas"))
  .set_default(arb::axial_resistivity{100}) // [Ω·cm]

to save some redundant typing. Adds the same to Python. Also modernise Python examples
where obvious.

Related to: #1862

@brenthuisman
Copy link
Contributor

brenthuisman commented Jun 9, 2022

One nice task left is to go through the tutorials and correct all the line numbers :)

@schmitts
Copy link
Contributor

schmitts commented Jun 9, 2022

I like! Ack to checking the line numbers for the generated docu.

Copy link
Collaborator

@Helveg Helveg left a comment

Choose a reason for hiding this comment

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

This is why method chaining never took off in Python 😛 We should pick a format and stick with it though, so let's hash this out :) There's more occurences, but I just picked 2 archetypal ones to propose my solution.

python/example/gap_junctions.py Outdated Show resolved Hide resolved
python/example/network_ring.py Outdated Show resolved Hide resolved
@thorstenhater
Copy link
Contributor Author

One nice task left is to go through the tutorials and correct all the line numbers :)

I'll address that separatly, since there is more in the pipeline breaking them again.

Copy link
Contributor

@brenthuisman brenthuisman left a comment

Choose a reason for hiding this comment

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

  1. The comments left on examples generalize to the other examples, so as soon as we agree, let's update them all.

  2. Then also update line numbers in the tutorials.

doc/concepts/decor.rst Outdated Show resolved Hide resolved
doc/concepts/decor.rst Outdated Show resolved Hide resolved
example/dryrun/branch_cell.hpp Outdated Show resolved Hide resolved
example/dryrun/branch_cell.hpp Outdated Show resolved Hide resolved
example/dryrun/branch_cell.hpp Outdated Show resolved Hide resolved
python/cells.cpp Show resolved Hide resolved
python/cells.cpp Show resolved Hide resolved
python/example/gap_junctions.py Outdated Show resolved Hide resolved
python/example/two_cell_gap_junctions.py Outdated Show resolved Hide resolved
@thorstenhater
Copy link
Contributor Author

thorstenhater commented Jun 10, 2022

This is why method chaining never took off in Python 😛 We should pick a format and stick with it though, so let's hash this out :) There's more occurences, but I just picked 2 archetypal ones to propose my solution.

Yes, I think, I'll add in another layer like this before we are done here (another PR)

d = A.decor(paint=[('(all)', A.density('hh'), ...],
            place=[('(location 0 0.5)', A.spike_detector(-40)), ...],
            ...)

where you could pass anything iterable that yields tuples of locations and paintables/placeables.

EDIT: Checked that out, result is discouraging.

@thorstenhater
Copy link
Contributor Author

thorstenhater commented Jun 11, 2022

  1. The comments left on examples generalize to the other examples, so as soon as we agree, let's update them all.

    1. Then also update line numbers in the tutorials.

Again, the other convenience PR breaks numbers as well. Introducing black will do it again.
I am not going to fix it three times. Let's do it together with black. If we feel uncomfortable with
having an inconsistent state for a day or so, I'll rebase all three PR's together. That is, if we agree
on merging.

@@ -0,0 +1,37 @@
#!/usr/bin/env python3
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this file used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You hand it a .py in our tutorial style and it will hand you back a list of

.. literalinclude::

with the line numbers between # (N) Section blocks.

Copy link
Contributor

@brenthuisman brenthuisman Jul 28, 2022

Choose a reason for hiding this comment

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

Good that you remind me: you can add that or at least one line up top stating what this file can do.

My question was though where it is used. Or is it meant as a helper wrt the tutorial/notebook situation later on?

@brenthuisman brenthuisman merged commit e0710c3 into arbor-sim:master Aug 2, 2022
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.

4 participants