Skip to content

Commit

Permalink
added encoding to open operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Askill committed Jul 8, 2024
1 parent edfa973 commit ccaca9e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions calculateAverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_file_chunks(
chunk_size = file_size // cpu_count

start_end = list()
with open(file_name, "r+b") as f:
with open(file_name, encoding="utf-8", mode="r+b") as f:

def is_new_line(position):
if position == 0:
Expand Down Expand Up @@ -62,7 +62,7 @@ def _process_file_chunk(
) -> dict:
"""Process each file chunk in a different process"""
result = dict()
with open(file_name, "rb") as f:
with open(file_name, encoding="utf-8", mode="rb") as f:
f.seek(chunk_start)
gc_disable()
for line in f:
Expand All @@ -86,7 +86,7 @@ def _process_file_chunk(
measurement,
1,
] # min, max, sum, count

gc_enable()
return result

Expand Down
6 changes: 3 additions & 3 deletions calculateAveragePypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_file_chunks(
chunk_size = file_size // cpu_count

start_end = list()
with open(file_name, "r+b") as f:
with open(file_name, encoding="utf-8", mode="r+b") as f:

def is_new_line(position):
if position == 0:
Expand Down Expand Up @@ -64,7 +64,7 @@ def _process_file_chunk(
"""Process each file chunk in a different process"""
result = dict()

with open(file_name, "r+b") as fh:
with open(file_name, encoding="utf-8", mode="r+b") as fh:
fh.seek(chunk_start)
gc_disable()

Expand Down Expand Up @@ -115,7 +115,7 @@ def _process_file_chunk(
] # min, max, sum, count

location = None

gc_enable()
return result

Expand Down
2 changes: 1 addition & 1 deletion createMeasurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def generate_measurement_file(
batches = max(records // 10_000_000, 1)
batch_ends = np.linspace(0, records, batches + 1).astype(int)

with open(file_name, "w") as f:
with open(file_name, encoding="utf-8", mode="w") as f:
for i in tqdm(range(batches)):
from_, to = batch_ends[i], batch_ends[i + 1]
data = self.generate_batch(std_dev, to - from_)
Expand Down

0 comments on commit ccaca9e

Please sign in to comment.