diff --git a/docs/pyerrors/input/json.html b/docs/pyerrors/input/json.html index 10cf078d..b310585c 100644 --- a/docs/pyerrors/input/json.html +++ b/docs/pyerrors/input/json.html @@ -77,14 +77,14 @@ View Source
import json
 import gzip
-from ..obs import Obs
+import numpy as np
 import getpass
 import socket
 import datetime
-from .. import version as pyerrorsversion
 import platform
-import numpy as np
 import warnings
+from ..obs import Obs
+from .. import version as pyerrorsversion
 
 
 def create_json_string(ol, description='', indent=1):
@@ -92,13 +92,13 @@
     to a .json(.gz) file
 
     Parameters
-    -----------------
+    ----------
     ol : list
         List of objects that will be exported. At the moments, these objects can be
-        either of: Obs, list, np.ndarray
+        either of: Obs, list, numpy.ndarray.
         All Obs inside a structure have to be defined on the same set of configurations.
     description : str
-        Optional string that describes the contents of the json file
+        Optional string that describes the contents of the json file.
     indent : int
         Specify the indentation level of the json file. None or 0 is permissible and
         saves disk space.
@@ -110,7 +110,7 @@
     _default.default = json.JSONEncoder().default
     my_encoder.default = _default
 
-    class deltalist:
+    class Deltalist:
         def __init__(self, li):
             self.cnfg = li[0]
             self.deltas = li[1:]
@@ -141,7 +141,7 @@
                     rd['deltas'].append([ol[0].idl[r_name][i]])
                     for o in ol:
                         rd['deltas'][-1].append(o.deltas[r_name][i])
-                    rd['deltas'][-1] = deltalist(rd['deltas'][-1])
+                    rd['deltas'][-1] = Deltalist(rd['deltas'][-1])
                 ed['replica'].append(rd)
             dl.append(ed)
         return dl
@@ -149,15 +149,16 @@
     def _assert_equal_properties(ol, otype=Obs):
         for o in ol:
             if not isinstance(o, otype):
-                raise Exception('Wrong data type in list!')
+                raise Exception("Wrong data type in list.")
         for o in ol[1:]:
             if not ol[0].is_merged == o.is_merged:
-                raise Exception('All Obs in list have to be defined on the same set of configs!')
+                raise Exception("All Obs in list have to be defined on the same set of configs.")
             if not ol[0].reweighted == o.reweighted:
-                raise Exception('All Obs in list have to have the same property .reweighted!')
+                raise Exception("All Obs in list have to have the same property 'reweighted'.")
             if not ol[0].e_content == o.e_content:
-                raise Exception('All Obs in list have to be defined on the same set of configs!')
-            # more stringend tests --> compare idl?
+                raise Exception("All Obs in list have to be defined on the same set of configs.")
+            if not ol[0].idl == o.idl:
+                raise Exception("All Obs in list have to be defined on the same set of configurations.")
 
     def write_Obs_to_dict(o):
         d = {}
@@ -183,7 +184,6 @@
             d['reweighted'] = ol[0].reweighted
         d['value'] = [o.value for o in ol]
         d['data'] = _gen_data_d_from_list(ol)
-
         return d
 
     def write_Array_to_dict(oa):
@@ -200,13 +200,15 @@
         d['value'] = [o.value for o in ol]
         d['data'] = _gen_data_d_from_list(ol)
         return d
+
     if not isinstance(ol, list):
         ol = [ol]
+
     d = {}
     d['program'] = 'pyerrors %s' % (pyerrorsversion.__version__)
     d['version'] = '0.1'
     d['who'] = getpass.getuser()
-    d['date'] = str(datetime.datetime.now())[:-7]
+    d['date'] = datetime.datetime.now().astimezone().strftime('%Y-%m-%d %H:%M:%S %Z')
     d['host'] = socket.gethostname() + ', ' + platform.platform()
 
     if description:
@@ -222,9 +224,10 @@
 
     jsonstring = json.dumps(d, indent=indent, cls=my_encoder, ensure_ascii=False)
 
-    # workaround for un-quoting of delta lists, adds 5% of work
-    # but is save, compared to a simple replace that could destroy the structure
     def remove_quotationmarks(s):
+        """Workaround for un-quoting of delta lists, adds 5% of work
+           but is save, compared to a simple replace that could destroy the structure
+        """
         deltas = False
         split = s.split('\n')
         for i in range(len(split)):
@@ -244,15 +247,15 @@
     """Export a list of Obs or structures containing Obs to a .json(.gz) file
 
     Parameters
-    -----------------
+    ----------
     ol : list
         List of objects that will be exported. At the moments, these objects can be
-        either of: Obs, list, np.ndarray
+        either of: Obs, list, numpy.ndarray.
         All Obs inside a structure have to be defined on the same set of configurations.
     fname : str
-        Filename of the output file
+        Filename of the output file.
     description : str
-        Optional string that describes the contents of the json file
+        Optional string that describes the contents of the json file.
     indent : int
         Specify the indentation level of the json file. None or 0 is permissible and
         saves disk space.
@@ -279,13 +282,14 @@
 
 def load_json(fname, verbose=True, gz=True, full_output=False):
     """Import a list of Obs or structures containing Obs from a .json.gz file.
-    The following structures are supported: Obs, list, np.ndarray
+
+    The following structures are supported: Obs, list, numpy.ndarray
     If the list contains only one element, it is unpacked from the list.
 
     Parameters
-    -----------------
+    ----------
     fname : str
-        Filename of the input file
+        Filename of the input file.
     verbose : bool
         Print additional information that was written to the file.
     gz : bool
@@ -428,13 +432,13 @@
     to a .json(.gz) file
 
     Parameters
-    -----------------
+    ----------
     ol : list
         List of objects that will be exported. At the moments, these objects can be
-        either of: Obs, list, np.ndarray
+        either of: Obs, list, numpy.ndarray.
         All Obs inside a structure have to be defined on the same set of configurations.
     description : str
-        Optional string that describes the contents of the json file
+        Optional string that describes the contents of the json file.
     indent : int
         Specify the indentation level of the json file. None or 0 is permissible and
         saves disk space.
@@ -446,7 +450,7 @@
     _default.default = json.JSONEncoder().default
     my_encoder.default = _default
 
-    class deltalist:
+    class Deltalist:
         def __init__(self, li):
             self.cnfg = li[0]
             self.deltas = li[1:]
@@ -477,7 +481,7 @@
                     rd['deltas'].append([ol[0].idl[r_name][i]])
                     for o in ol:
                         rd['deltas'][-1].append(o.deltas[r_name][i])
-                    rd['deltas'][-1] = deltalist(rd['deltas'][-1])
+                    rd['deltas'][-1] = Deltalist(rd['deltas'][-1])
                 ed['replica'].append(rd)
             dl.append(ed)
         return dl
@@ -485,15 +489,16 @@
     def _assert_equal_properties(ol, otype=Obs):
         for o in ol:
             if not isinstance(o, otype):
-                raise Exception('Wrong data type in list!')
+                raise Exception("Wrong data type in list.")
         for o in ol[1:]:
             if not ol[0].is_merged == o.is_merged:
-                raise Exception('All Obs in list have to be defined on the same set of configs!')
+                raise Exception("All Obs in list have to be defined on the same set of configs.")
             if not ol[0].reweighted == o.reweighted:
-                raise Exception('All Obs in list have to have the same property .reweighted!')
+                raise Exception("All Obs in list have to have the same property 'reweighted'.")
             if not ol[0].e_content == o.e_content:
-                raise Exception('All Obs in list have to be defined on the same set of configs!')
-            # more stringend tests --> compare idl?
+                raise Exception("All Obs in list have to be defined on the same set of configs.")
+            if not ol[0].idl == o.idl:
+                raise Exception("All Obs in list have to be defined on the same set of configurations.")
 
     def write_Obs_to_dict(o):
         d = {}
@@ -519,7 +524,6 @@
             d['reweighted'] = ol[0].reweighted
         d['value'] = [o.value for o in ol]
         d['data'] = _gen_data_d_from_list(ol)
-
         return d
 
     def write_Array_to_dict(oa):
@@ -536,13 +540,15 @@
         d['value'] = [o.value for o in ol]
         d['data'] = _gen_data_d_from_list(ol)
         return d
+
     if not isinstance(ol, list):
         ol = [ol]
+
     d = {}
     d['program'] = 'pyerrors %s' % (pyerrorsversion.__version__)
     d['version'] = '0.1'
     d['who'] = getpass.getuser()
-    d['date'] = str(datetime.datetime.now())[:-7]
+    d['date'] = datetime.datetime.now().astimezone().strftime('%Y-%m-%d %H:%M:%S %Z')
     d['host'] = socket.gethostname() + ', ' + platform.platform()
 
     if description:
@@ -558,9 +564,10 @@
 
     jsonstring = json.dumps(d, indent=indent, cls=my_encoder, ensure_ascii=False)
 
-    # workaround for un-quoting of delta lists, adds 5% of work
-    # but is save, compared to a simple replace that could destroy the structure
     def remove_quotationmarks(s):
+        """Workaround for un-quoting of delta lists, adds 5% of work
+           but is save, compared to a simple replace that could destroy the structure
+        """
         deltas = False
         split = s.split('\n')
         for i in range(len(split)):
@@ -586,10 +593,10 @@ to a .json(.gz) file