Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small steps toward making RSI py3 compatible #250

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RealSpaceInterface/Calc2D/CalculationClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def getData(self, redshiftindex):
Valuenew = dict()
FValue_abs = np.abs(self.FValue)
_min, _max = FValue_abs.min(), FValue_abs.max()
dimensions = (self.endshape[0] / 2, self.endshape[1])
dimensions = (self.endshape[0] // 2, self.endshape[1])
for quantity, FT in FValuenew.items():
FT_abs = np.abs(FT)
FT_normalized = cv2.resize(FT_abs, dimensions).ravel()
Expand All @@ -98,7 +98,7 @@ def getInitialData(self):
return Value.ravel(), cv2.resize(
(np.abs(self.FValue) - np.abs(self.FValue).min()) /
(np.abs(self.FValue).max() - np.abs(self.FValue).min()),
(self.endshape[0] / 2, self.endshape[1])).ravel(), (minimum,
(self.endshape[0] // 2, self.endshape[1])).ravel(), (minimum,
maximum)

def getTransferData(self, redshiftindex):
Expand Down
12 changes: 6 additions & 6 deletions RealSpaceInterface/Calc2D/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ def __init__(self, directory, db_file="database.dat"):
self.db_path = os.path.join(directory, db_file)
if not os.path.exists(self.db_path):
logging.info("No database found; Creating one at {}.".format(self.db_path))
with open(self.db_path, "w") as f:
with open(self.db_path, "wb") as f:
pickle.dump(dict(), f)

self.db = self.__read_database()

def __read_database(self):
with open(self.db_path) as f:
with open(self.db_path, "rb") as f:
return pickle.load(f)

def __write_database(self):
with open(self.db_path, "w") as f:
with open(self.db_path, "wb") as f:
pickle.dump(self.db, f)

def __create_file(self, data):
filename = str(uuid.uuid4())
with open(os.path.join(self.directory, filename), "w") as f:
with open(os.path.join(self.directory, filename), "wb") as f:
pickle.dump(data, f)
return filename

Expand All @@ -40,7 +40,7 @@ def __getitem__(self, key):
frozen_key = self.__get_frozen_key(key)
if frozen_key in self.db:
filename = self.db[frozen_key]
with open(os.path.join(self.directory, filename)) as f:
with open(os.path.join(self.directory, filename), "rb") as f:
return pickle.load(f)
else:
raise KeyError("No data for key: {}".format(key))
Expand All @@ -55,4 +55,4 @@ def __contains__(self, key):
Return whether `self` contains a record
for the given `key`.
"""
return self.__get_frozen_key(key) in self.db
return self.__get_frozen_key(key) in self.db