Skip to content

Conversation

@Chetank99
Copy link
Contributor

@Chetank99 Chetank99 commented Mar 15, 2025

following up from: #1005
i have added a new function network_to_markdown(), that exports a network object's config to md format. It is using the current JSON-based network export format.

Added network_to_markdown() to hnn_io.py

I used this code to test it:

from hnn_core import jones_2009_model
from hnn_core.hnn_io import network_to_markdown

net = jones_2009_model(mesh_shape=(3, 3))

#if we dont want to save, we can remove file param and just print
md_text = network_to_markdown(net,'file.md') 
print(md_text)

Attaching a sample md file:
file.md

This is my first PR, so very open to feedback! If this is fine, I can work on making a table with differences of 2 network params

from .cell_response import CellResponse
from .externals.mne import fill_doc

def network_to_markdown(net, fname=None):
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is a write_xxx function, it should follow the API in the remaining codebase

Copy link
Collaborator

Choose a reason for hiding this comment

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

parameters should be documented in the docstring


def network_to_markdown(net, fname=None):
"""converts network parameters to a markdown table."""
from datetime import datetime
Copy link
Collaborator

Choose a reason for hiding this comment

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

top-level import

"""converts network parameters to a markdown table."""
from datetime import datetime

md = []
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
md = []
md = list()

hard to distinguish between [] and {} otherwise

@jasmainak
Copy link
Collaborator

can you add a test?

@Chetank99
Copy link
Contributor Author

Hi @jasmainak ,
thank you for the review and comments, addressed them, except the test.

since it is a write_xxx function, used the syntax to have the overwrite param

documented via docstring

used list() for md

I am not sure right now how to add a test, going through hnn_core/tests to learn how the code base does it

@Chetank99
Copy link
Contributor Author

@jasmainak I added a test into hnn_core/tests in the existing file, hnn_core/tests/test_io.py, called test_write_network_markdown

It is heavily inspired from test_write_configuration func in the same file. Do let me know if I should focus on any other aspect.

Thank you!

@jasmainak
Copy link
Collaborator

I will let @asoplata and @ntolley review the PR and merge if happy :)


from datetime import datetime

def write_network_markdown(net, fname, overwrite=True):
Copy link
Collaborator

Choose a reason for hiding this comment

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

you need to document this in api.rst

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I have added it to the file!

updated write_network_markdown to api.rst
@asoplata asoplata changed the title pretty-print-network with md format [WIP] pretty-print-network with md format Sep 15, 2025
@asoplata
Copy link
Collaborator

Hey @Chetank99 just to let you know, it may be a while before we have time to continue work on this. We've got "many irons in the fire".

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.

3 participants