コード例 #1
0
 def test_tsread_failure(self):
     tp_name = "testTuple"
     string_buff_size = 100
     tslib.libso.tsread = MagicMock()
     MagicMock.return_value = -108
     return_value = tslib.tsread(tp_name, string_buff_size)
     self.assertEqual(return_value, 1)
コード例 #2
0
 def test_tsread_success(self):
     tp_name = "testTuple"
     string_buff_size = 100
     tslib.libso.tsread = MagicMock()
     MagicMock.return_value = 100
     return_value = tslib.tsread(tp_name, string_buff_size)
     self.assertEqual(return_value, (b'', b'testTuple'))
コード例 #3
0
def main():
    now = datetime.datetime.now()

    print("Current date and time: ")
    print(str(now))
    print("writing date to tuple")

    tuple_size = 200
    tuple_name = "date"

    return_value = tslib.tsput(tuple_name, str(now), tuple_size)
    if return_value == 1:
        print(
            "ERROR, tsput returned 1, failure detected, integration test failed"
        )
        sys.exit(1)
    else:
        print("return value from tsput : " + str(return_value))

    partial_tuple = "da"
    string_from_tuple_space, matched_tuple_name = tslib.tsread(
        partial_tuple, tuple_size)
    if matched_tuple_name.decode('utf-8') != tuple_name:
        print("ERROR, tsread regex matching from: " + partial_tuple + " | " +
              matched_tuple_name.decode('utf-8') +
              " failed, integration test failed")
        sys.exit(1)
    else:
        print("matched tuple name : " + matched_tuple_name.decode('utf-8'))
        if string_from_tuple_space.decode('utf-8') != str(now):
            print("ERROR, value retrived from tuple space does not match: " +
                  string_from_tuple_space.decode('utf-8') + " | " + str(now) +
                  " integration test failed")
            sys.exit(1)
        print("value retrieved from tuple space : " +
              string_from_tuple_space.decode('utf-8'))

    string_from_tuple_space = None

    string_from_tuple_space, matched_tuple_name = tslib.tsget(
        "date", tuple_size)
    if matched_tuple_name.decode('utf-8') != tuple_name:
        print(
            "ERROR, tsget regex matching from 'da' to 'date' failed, integration test failed"
        )
        sys.exit(1)
    else:
        print("matched tuple name : " + matched_tuple_name.decode('utf-8'))
        if string_from_tuple_space.decode('utf-8') != str(now):
            print("ERROR, value retrived from tuple space does not match: " +
                  string_from_tuple_space.decode('utf-8') + " | " + str(now) +
                  " integration test failed")
            sys.exit(1)
        print("value retrieved from tuple space : " +
              string_from_tuple_space.decode('utf-8'))
    print(
        "INTEGRATION TEST PASSED, TUPLE PUT INTO SPACE AND RETRIVED ON BOTH PARTIAL AND FULL TUPLE MATCH WITH CORRECT VALUES"
    )
    sys.exit(0)
コード例 #4
0
ファイル: tsplib.py プロジェクト: tuc48831/MSProject
def read_tour(tour_identifier):
    # of note, this does not currently support regex getting of nodes, only direct naming
    tour_size = TspTour.get_max_tour_size()
    retrieved_tour_as_json, retrieved_tour_identifier = tslib.tsread(
        tour_identifier, tour_size)
    print("retrieved node as json is: {}".format(retrieved_tour_as_json))
    node = TspTour.from_json_string(retrieved_tour_as_json)
    return node
コード例 #5
0
ファイル: tsplib.py プロジェクト: tuc48831/MSProject
def read_effective_calcs():
    effective_calcs = -1
    retrieved_effective_calcs, retrieved_tuple_name = tslib.tsread(
        effective_calcs_name, sys.getsizeof(str(effective_calcs)))
    return int(retrieved_effective_calcs)
コード例 #6
0
ファイル: tsplib.py プロジェクト: tuc48831/MSProject
def read_best_tour(num_vertices):
    best_tour_size = sys.getsizeof(int()) * num_vertices
    retrieved_best_tour, retrieved_tuple_name = tslib.tsread(
        best_tour_name, best_tour_size)
    # this slice and split is to convert "[1, 2, 3]" to a list of strings e.g. ["1", "2", "3"]
    return [int(i) for i in retrieved_best_tour[1:-1].split(", ")]
コード例 #7
0
ファイル: tsplib.py プロジェクト: tuc48831/MSProject
def read_global_minimum():
    global_min = sys.maxsize
    retrieved_global_min, retrieved_tuple_name = tslib.tsread(
        global_minimum_name, sys.getsizeof(str(global_min)))
    return int(retrieved_global_min)
コード例 #8
0
ファイル: tsplib.py プロジェクト: tuc48831/MSProject
def read_start():
    num_dimensions = -1
    retrieved_num_dimensions, retrieved_tuple_name = tslib.tsread(
        start_tuple_name, sys.getsizeof(num_dimensions))
    return int(retrieved_num_dimensions)
コード例 #9
0
ファイル: tsplib.py プロジェクト: tuc48831/MSProject
def read_cost_matrix_from_tuple_space(matrix_name, num_vertices):
    dataframe_for_size = pandas.DataFrame(
        numpy.zeros([num_vertices, num_vertices]) * numpy.nan)
    size = len(dataframe_for_size.to_json())
    retrieved_matrix, retrieved_tuple_name = tslib.tsread(matrix_name, size)
    return pandas.read_json(retrieved_matrix)