Ejemplo n.º 1
0
def test_write_string(dict_obj):
    s_in = ju.write_string({ "string": dict_obj["string"] })
    s_out = """{
  "string": "test string"
}"""

    assert s_in == s_out
Ejemplo n.º 2
0
def test_write_string(dict_obj):
    s_in = ju.write_string({"string": dict_obj["string"]})
    s_out = """{
  "string": "test string"
}"""

    assert s_in == s_out
Ejemplo n.º 3
0
    def to_json(self, file_name=None):
        """JSON serialize object parameters to file or string.

        Parameters
        ----------
        file_name : string, optional (default None)
            Path to .json file containing VoxelModelCache parameters. If None,
            a string will be returned.

        Returns
        -------
        string
            If file_name == None, a string of the JSON serialization is returned.
        """
        params = dict(resolution=self.resolution,
                      cache=self.cache,
                      manifest_file=self.manifest_file,
                      ccf_version=self.ccf_version,
                      base_uri=self.base_uri,
                      version=self.version)

        if file_name is None:
            return json_utilities.write_string(params)

        json_utilities.write(file_name, params)
Ejemplo n.º 4
0
def test_write_list(dict_obj):
    s_in = ju.write_string({"list": dict_obj["list"]})
    s_out = """{
  "list": [
    "this",
    "is",
    1,
    "list"
  ]
}"""
    assert s_in == s_out
Ejemplo n.º 5
0
def test_write_list(dict_obj):
    s_in = ju.write_string({ "list": dict_obj["list"] })
    s_out = """{
  "list": [
    "this",
    "is",
    1,
    "list"
  ]
}"""
    assert s_in == s_out
Ejemplo n.º 6
0
def test_write_bool_array(dict_obj):
    s_in = ju.write_string({"bool_array": dict_obj["bool_array"]})
    s_out = """{
  "bool_array": [
    [
      false,
      true
    ],
    [
      false,
      true
    ]
  ]
}"""
    assert s_in == s_out
Ejemplo n.º 7
0
def test_write_bool_array(dict_obj):
    s_in = ju.write_string({ "bool_array": dict_obj["bool_array"] })
    s_out = """{
  "bool_array": [
    [
      false,
      true
    ],
    [
      false,
      true
    ]
  ]
}"""
    assert s_in == s_out
Ejemplo n.º 8
0
def test_write_float_array(dict_obj):
    s_in = ju.write_string({"float_array": dict_obj["float_array"]})
    s_out = """{
  "float_array": [
    [
      0.0,
      0.0
    ],
    [
      0.23809523809523808,
      0.23809523809523808
    ]
  ]
}"""

    assert s_in == s_out
Ejemplo n.º 9
0
def test_write_integer_array(dict_obj):
    s_in = ju.write_string({"int_array": dict_obj["int_array"]})
    s_out = """{
  "int_array": [
    [
      0,
      1
    ],
    [
      0,
      1
    ]
  ]
}"""

    assert s_in == s_out
Ejemplo n.º 10
0
def test_write_float_array(dict_obj):
    s_in = ju.write_string({ "float_array": dict_obj["float_array"] })
    s_out ="""{
  "float_array": [
    [
      0.0,
      0.0
    ],
    [
      0.23809523809523808,
      0.23809523809523808
    ]
  ]
}"""

    assert s_in == s_out
Ejemplo n.º 11
0
def test_write_integer_array(dict_obj):
    s_in = ju.write_string({ "int_array": dict_obj["int_array"] })
    s_out = """{
  "int_array": [
    [
      0,
      1
    ],
    [
      0,
      1
    ]
  ]
}"""

    assert s_in == s_out
Ejemplo n.º 12
0
 def write_json_string(self):
     config = self.get_config()
     return ju.write_string(config)
Ejemplo n.º 13
0
 def write_json_string(self):
     config = self.get_config()
     return ju.write_string(config)