def _describe_response_for_remediation(self, request: "_RequestSpec", actual_response: Json) -> str: method = request.method params = request.params result = actual_response.get("result") powered_by = actual_response.get("powered_by") request_snippet = f"""\ .request(""" if request.comment is not None: request_snippet += f""" comment={request.comment!r},""" request_snippet += f""" method={method!r}, params={params!r}, result={result!r},""" if not request.wait: request_snippet += f""" wait=False,""" if request.powered_by is not None: request_snippet += f""" powered_by={powered_by!r},""" request_snippet += f""" )""" remediation = f"""\ 1) If this was unexpected, then the language server is buggy and should be fixed. 2) If this was expected, you can update your request with the following code to make it match: {request_snippet} """ return remediation
def _describe_response_for_remediation( self, variables: VariableMap, request: "_RequestSpec", # pyre-fixme[11]: Annotation `Json` is not defined as a type. actual_response: Json, ) -> str: method = request.method params = request.params result = uninterpolate_variables(payload=actual_response.get("result"), variables=variables) powered_by = actual_response.get("powered_by") request_snippet = f"""\ .request( line=line(),""" if request.comment is not None: request_snippet += f""" comment={request.comment!r},""" request_snippet += f""" method={method!r}, params={params!r}, result={result!r},""" if request.wait_id is not None: request_snippet += f""" wait_id={request.wait_id!r},""" if powered_by is not None: request_snippet += f""" powered_by={powered_by!r},""" request_snippet += f""" )""" remediation = f"""\ 1) If this was unexpected, then the language server is buggy and should be fixed. 2) If this was expected, you can update your request with the following code to make it match: {request_snippet} """ return remediation
def generate_json(self, name, out_name, sample=82): if name not in ['train.csv', 'test.csv']: print('Invalid filename!!!') return data = pd.read_csv(os.path.join(self.file_path, name)) trajs = data['POLYLINE'] cnt = 0 trip = {} for i, x in enumerate(trajs): if i % sample != 0: continue tmp = self.str2traj(x) tr = self.judge(tmp) if len(tr) > 0: trip[str(cnt)] = [[float(tr[j][0]), float(tr[j][1]), int(data.TIMESTAMP.iloc[i] + 15 * j)] for j in range(len(tr))] cnt += 1 print (i, cnt) Json.output(trip, os.path.join(self.file_path, out_name)) return
def generate_json_all(self, name='all.json'): ret = {} users = os.listdir(self.file_path) cnt = 0 for i in range(len(users)): # 000 print(i, len(ret)) username = users[i] traj_path = os.path.join(self.file_path, username, 'Trajectory') trajs = os.listdir(traj_path) for j in range(len(trajs)): ret_traj = self.generate_json_single( os.path.join(traj_path, trajs[j])) for k in ret_traj: if len(k) < 10: continue ret[str(cnt)] = k cnt += 1 # print(ret[str(cnt)]) Json.output(ret, os.path.join(self.file_path, name)) return len(ret)
def read_data(self, name = 'train.json'): self.data = Json.load(os.path.join(self.file_path, name))
print(i, len(ret)) username = users[i] traj_path = os.path.join(self.file_path, username, 'Trajectory') trajs = os.listdir(traj_path) for j in range(len(trajs)): ret_traj = self.generate_json_single( os.path.join(traj_path, trajs[j])) for k in ret_traj: if len(k) < 10: continue ret[str(cnt)] = k cnt += 1 # print(ret[str(cnt)]) Json.output(ret, os.path.join(self.file_path, name)) return len(ret) if __name__ == '__main__': file_path = '/home/yiwei/data/Geolife1.3/Data' # f = geolife(file_path) # f.generate_json_all('all.json') dic = {} cnt = 0 js = Json.load('/home/yiwei/data/Geolife1.3/Data/small.json') for k, v in js.items(): if (int(k) % 10 != 0): print(k) dic[str(cnt)] = [[float(x[0]), float(x[1]), x[2]] for x in v] cnt += 1 Json.output(dic, '/home/yiwei/data/Geolife1.3/Data/small.json')