Skip to content

TensorForceField serialization - #178

Merged
mattwthompson merged 5 commits into
mainfrom
tensor-force-field-serialization
Oct 1, 2026
Merged

mattwthompson merged 5 commits into
mainfrom
tensor-force-field-serialization

Conversation

@mattwthompson

Copy link
Copy Markdown
Member

Closes #168

@codecov-commenter

codecov-commenter commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.47%. Comparing base (4db3654) to head (93909c6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
tyff/_serialization.py 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #178      +/-   ##
==========================================
+ Coverage   81.40%   81.47%   +0.07%     
==========================================
  Files          56       57       +1     
  Lines        5070     5097      +27     
==========================================
+ Hits         4127     4153      +26     
- Misses        943      944       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mattwthompson
mattwthompson marked this pull request as ready for review October 1, 2026 15:13
@mattwthompson
mattwthompson requested a balanced review from Copilot October 1, 2026 15:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The new module contains non-functional dead code (_Tensor and the sparse helpers) and the exceptions serialization path is entirely untested.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

This PR adds JSON serialization support for TensorForceField (closing #168). It introduces a new tyff/_serialization.py module providing dump_*/load_* functions that convert a TensorForceField (and its nested TensorPotential and TensorVSites) to and from plain Python dicts suitable for json.dump/json.load, handling tensors, units, OpenFF PotentialKeys, and exceptions. A new test module exercises round-trip serialization for a basic water force field and a virtual-site force field.

Changes:

  • New tyff/_serialization.py with helpers to encode/decode tensors, units, potential keys, and exceptions, plus top-level dump_tensor_force_field/load_tensor_force_field.
  • New tyff/_tests/test_serialization.py with a field-by-field comparison helper and two round-trip tests (basic and virtual sites).
File Description
tyff/​_serialization.py Adds dump/load functions for TensorForceField, TensorPotential, and TensorVSites, plus tensor/exception encoding helpers (includes some unused _Tensor/sparse helpers).
tyff/​_tests/​test_serialization.py Adds round-trip serialization tests and a compare_tensor_force_fields helper (does not compare exceptions).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tyff/_serialization.py
Comment thread tyff/_serialization.py Outdated
@mattwthompson
mattwthompson merged commit 3e0adea into main Oct 1, 2026
5 checks passed
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.

Serialize TensorForceField

3 participants