Exemplo n.º 1
0
 def test_redirect_settings_file(self):
     data = _load_redirect(os.path.join(test_dir, "test_settings.yaml"))
     self.assertEqual(
         data, {
             'old_module': {
                 'old_class': {
                     '@class': 'new_class',
                     '@module': 'new_module'
                 }
             }
         })
Exemplo n.º 2
0
 def test_redirect_settings_file(self):
     data = _load_redirect(os.path.join(test_dir, "test_settings.yaml"))
     self.assertEqual(
         data,
         {
             "old_module": {
                 "old_class": {
                     "@class": "new_class",
                     "@module": "new_module"
                 }
             }
         },
     )
Exemplo n.º 3
0
# Usage code

>>> vor = get_marked_class("VoronoiNN", NNDict)

The new class are marked with "_D"
"""

import json
import os
from inspect import getfullargspec
from typing import List, Dict

from monty.json import MontyDecoder, _load_redirect

REDIRECT = _load_redirect(os.path.join(os.path.expanduser("~"), ".monty.yaml"))


def as_dict(self) -> dict:
    """
    A JSON serializable dict representation of an object.
    """
    d = {
        "@module": self.__class__.__module__,
        "@class": self.__class__.__name__,
        "@version": None
    }

    dk = {}
    spec = getfullargspec(self.__init__)
    args = spec.args