def extract_traj(fname: str, config: dict) -> Trajectory: """Extract trajector from filename and create Trajectory instance. Args: fname: Filename from which to load trajectory. config: Dictionary containing parameters of javascript simulation. Returns: Trajectory with mapped states and actions. """ states, actions = [], [] data = load_json(fname) for step in data: states.append(step['data']['state']) actions.append(step['data']['action']) traj = Trajectory(states, actions, config, fname) traj.remap_states() traj.as_numpy() return traj