Skip to content

Commit

Permalink
Formatting tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Nov 1, 2024
1 parent 9104f54 commit a452a95
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/somd2/io/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,17 @@ def parquet_append(filepath: _Path or str, df: _pd.DataFrame) -> None:
Pandas dataframe to append. Must be same schema as original.
"""
try:
# Use memory map for speed.
table_original_file = _pq.read_table(
source=str(filepath), pre_buffer=False, use_threads=True, memory_map=True
) # Use memory map for speed.
)
table_to_append = _pa.Table.from_pandas(df)
table_to_append = table_to_append.cast(
table_original_file.schema
) # Attempt to cast new schema to existing, e.g. datetime64[ns] to datetime64[us] (may throw otherwise).
# Attempt to cast new schema to existing, e.g. datetime64[ns] to
# datetime64[us] (may throw otherwise).
table_to_append = table_to_append.cast(table_original_file.schema)

temp_file = str(filepath) + "_temp" # Temporary file to write to
# Temporary file to write to.
temp_file = str(filepath) + "_temp"

# Writing to a temporary file
with _pq.ParquetWriter(temp_file, table_original_file.schema) as temp_writer:
Expand Down
4 changes: 3 additions & 1 deletion src/somd2/runner/_repex.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,9 @@ def run(self):
end = time()

# Log the run time in minutes.
_logger.success(f"Simulation finished. Run time: {(end - start) / 60:.2f} minutes")
_logger.success(
f"Simulation finished. Run time: {(end - start) / 60:.2f} minutes"
)

def _run_block(
self, index, lambdas, is_checkpoint, is_final_block, block, num_blocks
Expand Down
5 changes: 3 additions & 2 deletions src/somd2/runner/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def run(self):
result = job.result()
except Exception as e:
result = False

_logger.error(
f"Exception raised for {_lam_sym} = {lambda_value}: {e}"
)
Expand All @@ -192,7 +191,9 @@ def run(self):
end = time()

# Log the run time in minutes.
_logger.success(f"Simulation finished. Run time: {(end - start) / 60:.2f} minutes")
_logger.success(
f"Simulation finished. Run time: {(end - start) / 60:.2f} minutes"
)

def run_window(self, index):
"""
Expand Down

0 comments on commit a452a95

Please sign in to comment.