Skip to content

Add test coverage for to_pickle export#106

Open
GiGiKoneti wants to merge 1 commit intomllam:mainfrom
GiGiKoneti:test/add-to-pickle-coverage
Open

Add test coverage for to_pickle export#106
GiGiKoneti wants to merge 1 commit intomllam:mainfrom
GiGiKoneti:test/add-to-pickle-coverage

Conversation

@GiGiKoneti
Copy link
Copy Markdown

Describe your changes

to_pickle is a public export function in save.py but had zero test
coverage — unlike to_pyg which is already covered by test_save_to_pyg.

Adds test_save_to_pickle to tests/test_save.py mirroring the same
structure. The test does a full round-trip check:

  • output .pkl file is created on disk at the expected path
  • file loads back cleanly with pickle.load()
  • loaded object is a networkx graph instance
  • node and edge counts match the original after deserialisation

No production code touched. No new dependancies introduced.

Issue Link

Related to #88

Type of change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📖 Documentation (Addition or improvements to documentation)

Checklist before requesting a review

  • My branch is up-to-date with the target branch - if not update your fork with the changes from the target branch (use pull with --rebase option if possible).
  • I have performed a self-review of my code
  • For any new/modified functions/classes I have added docstrings that clearly describe its purpose, expected inputs and returned values
  • I have placed in-line comments to clarify the intent of any hard-to-understand passages of my code
  • I have updated the documentation to cover introduced code changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have given the PR a name that clearly describes the change, written in imperative form (context).
  • I have requested a reviewer and an assignee (assignee is responsible for merging)

Checklist for reviewers

Each PR comes with its own improvements and flaws. The reviewer should check the following:

  • the code is readable
  • the code is well tested
  • the code is documented (including return types and parameters)
  • the code is easy to maintain

Author checklist after completed review

  • I have added a line to the CHANGELOG describing this change, in a section
    reflecting type of change (add section where missing):
    • added: when you have added new functionality
    • changed: when default behaviour of the code has been changed
    • fixes: when your contribution fixes a bug

Checklist for assignee

  • PR is up to date with the base branch
  • the tests pass
  • author has added an entry to the changelog (and designated the change as added, changed or fixed)
  • Once the PR is ready to be merged, squash commits and merge the PR.

Adds test_save_to_pickle to tests/test_save.py, mirroring the existing
test_save_to_pyg structure.

The test verifies:
- the output .pkl file is created on disk
- the file can be loaded back with pickle.load
- the loaded object is a networkx graph
- node and edge counts are preserved after the round-trip

to_pickle had zero test coverage prior to this commit.
Related to the test coverage improvements noted in issue mllam#88.
@GiGiKoneti GiGiKoneti force-pushed the test/add-to-pickle-coverage branch from 5631a74 to 82f204d Compare March 18, 2026 10:52
@leifdenby
Copy link
Copy Markdown
Member

Thank you for adding this, but aren't you just checking that pickle works with this test? I don't quite understand what this adds

@GiGiKoneti
Copy link
Copy Markdown
Author

Hey @leifdenby

I know it looks like it's just testing the standard library pickle, but the main reson is to guarantee that our specific, complex graph objects (like the ones from create_oskarsson_hierarchical_graph) are completely serializable. Sometimes custom networkx attributes can act wierd when pickled, so this ensures a safe round-trip.It also explicitly tests the public I/O contract in save.py. If we ever decide to refactor to_pickle later (like adding gzip compression or stripping unnessecary nodes to save disk space before export), we'll have a regression test already backing it up. Mostly just wanted to bring the coverage on par with to_pyg since thats tested too. Let me know if you want me to add checks for any deeper graph properties!

@bhawna346
Copy link
Copy Markdown

Hi, I’d like to work on this issue. Could you please assign it to me?

@GiGiKoneti
Copy link
Copy Markdown
Author

This is a PR.

@bhawna346
Copy link
Copy Markdown

Thanks for the clarification! I'll look for open issues instead.

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