diff trafficintelligence/storage.py @ 1141:3e0f43edb4d6

Issue loading from different location
author Etienne Beauchamp <etienne-2.beauchamp@polymtl.ca>
date Thu, 16 Apr 2020 11:24:35 -0400
parents c4d9c270f999
children 8ac52ebff5f7
line wrap: on
line diff
--- a/trafficintelligence/storage.py	Wed Apr 15 00:18:35 2020 -0400
+++ b/trafficintelligence/storage.py	Thu Apr 16 11:24:35 2020 -0400
@@ -6,6 +6,7 @@
 import shutil
 from copy import copy
 import sqlite3, logging
+from os import chdir
 
 from numpy import log, min as npmin, max as npmax, round as npround, array, sum as npsum, loadtxt, floor as npfloor, ceil as npceil, linalg, int32, int64
 from pandas import read_csv, merge
@@ -661,6 +662,9 @@
     'Loads prototype ids and matchings (if stored)'
     prototypes = []
     if Path(filename).is_file():
+        filename = str(Path(filename).resolve())
+        pwd = Path.cwd()
+        chdir(Path(filename).parent)
         with sqlite3.connect(filename) as connection:
             cursor = connection.cursor()
             objects = []
@@ -685,6 +689,7 @@
                 printDBError(error)
         if len(set([p.getTrajectoryType() for p in prototypes])) > 1:
             print('Different types of prototypes in database ({}).'.format(set([p.getTrajectoryType() for p in prototypes])))
+        chdir(pwd)
     return prototypes
 
 def savePOIsToSqlite(filename, gmm, gmmType, gmmId):