Macaulay2 » Documentation
Packages » MRDI :: MRDI
next | previous | forward | backward | up | index | toc

MRDI -- serialization using the mrdi file format

Description

The MRDI package provides tools for serializing and deserializing mathematical objects in Macaulay2 using the MRDI file format, a JSON-based format for storing and sharing results in computer algebra without losing accuracy. The format was developed as part of the Mathematics Research Data Initiative (MaRDI) and is described in the paper:

Antony Della Vecchia, Michael Joswig, and Benjamin Lorenz, A FAIR file format for mathematical software, Mathematical software—ICMS 2024, 234–244, Lecture Notes in Comput. Sci., 14749, Springer, Cham.

Each serialized object carries a namespace (_ns) identifying the originating software system and version, a type descriptor (_type) that may include recursive parameters, the actual data, and optionally a set of references (_refs) keyed by UUIDs.

The package can serialize and deserialize integers, rings (ZZ, QQ, finite prime fields, Galois fields), polynomial rings, ring elements, ideals, and matrices. It can also load and save objects using the OSCAR namespace, enabling interoperability with the OSCAR computer algebra system.

The namespace mechanism also makes it possible to define custom serialization formats for exchanging data with other software systems.

i1 : R = QQ[x,y,z,w]

o1 = R

o1 : PolynomialRing
i2 : I = monomialCurveIdeal(R, {1,2,3})

             2                    2
o2 = ideal (z  - y*w, y*z - x*w, y  - x*z)

o2 : Ideal of R
i3 : s = saveMRDI I

o3 = {"_type": {"params": "6caf806b-9118-4741-bec7-217a71096848", "name":
     "Ideal"}, "data": [[[["0", "0", "2", "0"], ["1", "1"]], [["0", "1", "0",
     "1"], ["-1", "1"]]], [[["0", "1", "1", "0"], ["1", "1"]], [["1", "0",
     "0", "1"], ["-1", "1"]]], [[["0", "2", "0", "0"], ["1", "1"]], [["1",
     "0", "1", "0"], ["-1", "1"]]]], "_ns": {"Macaulay2":
     ["https://macaulay2.com", "1.26.05"]}, "_refs":
     {"6caf806b-9118-4741-bec7-217a71096848": {"_type": {"params": {"_type":
     "Ring", "data": "QQ"}, "name": "PolynomialRing"}, "data": {"variables":
     ["x", "y", "z", "w"]}}}}
i4 : loadMRDI s

             2                    2
o4 = ideal (z  - y*w, y*z - x*w, y  - x*z)

o4 : Ideal of R

Menu

Author

Version

This documentation describes version 0.1 of MRDI, released April 25, 2026.

Citation

If you have used this package in your research, please cite it as follows:

@misc{MRDISource,
  title = {{MRDI: serializing algebraic data with .mrdi files. Version~0.1}},
  author = {Doug Torrance},
  howpublished = {A \emph{Macaulay2} package available at
    \url{https://github.com/Macaulay2/M2/tree/stable/M2/Macaulay2/packages}}
}

Exports

  • Functions and commands
    • addLoadMethod -- register a method for deserializing a type from MRDI format
    • addNamespace -- register a namespace for MRDI serialization
    • addSaveMethod -- register a method for serializing a type to MRDI format
    • loadMRDI -- deserialize a Macaulay2 object from MRDI format
    • saveMRDI -- serialize a Macaulay2 object to MRDI JSON format
    • validateMRDI -- validate an MRDI JSON object against the format specification
  • Methods
    • addLoadMethod(List,Function) -- see addLoadMethod -- register a method for deserializing a type from MRDI format
    • addLoadMethod(String,Function) -- see addLoadMethod -- register a method for deserializing a type from MRDI format
    • addNamespace(String,String,String) -- see addNamespace -- register a namespace for MRDI serialization
    • addSaveMethod(Type) -- see addSaveMethod -- register a method for serializing a type to MRDI format
    • addSaveMethod(Type,Function) -- see addSaveMethod -- register a method for serializing a type to MRDI format
    • addSaveMethod(Type,Function,Function) -- see addSaveMethod -- register a method for serializing a type to MRDI format
    • loadMRDI(HashTable) -- see loadMRDI -- deserialize a Macaulay2 object from MRDI format
    • loadMRDI(String) -- see loadMRDI -- deserialize a Macaulay2 object from MRDI format
    • saveMRDI(Thing) -- see saveMRDI -- serialize a Macaulay2 object to MRDI JSON format
    • validateMRDI(HashTable) -- see validateMRDI -- validate an MRDI JSON object against the format specification
    • validateMRDI(String) -- see validateMRDI -- validate an MRDI JSON object against the format specification
    • validateMRDI(Thing) -- see validateMRDI -- validate an MRDI JSON object against the format specification
  • Symbols
    • UseID -- see addSaveMethod -- register a method for serializing a type to MRDI format
    • Namespace -- option specifying the namespace for MRDI serialization
    • ToString -- see saveMRDI -- serialize a Macaulay2 object to MRDI JSON format

For the programmer

The object MRDI is a package, defined in MRDI.m2.


The source of this document is in /build/reproducible-path/macaulay2-1.26.05+ds/M2/Macaulay2/packages/MRDI.m2:487:0.