Skip to content

Commit

Permalink
Fixed a bug that occurred when code_timer in ex_input.py was set to N…
Browse files Browse the repository at this point in the history
…one.
  • Loading branch information
YCC-ProjBackups committed Jun 3, 2023
1 parent 9abf25a commit e6f9887
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions anisoap/representations/ellipsoidal_density_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def pairwise_ellip_expansion(
if timer is not None:
internal_timer2.mark("5-8-2-7. compute gaussian params")
internal_timer3 = SimpleTimer()
else:
internal_timer3 = None

if moment_fn_lang == "rust":
# NOTE: This line was replaced with Rust implementation.
Expand Down
12 changes: 7 additions & 5 deletions tests/ex_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
# ------------------------------ Configurations ------------------------------ #
# See above for explanations for each variables.
_file_name = "res_cmp"
_write_mode = "time"
_write_mode = "result"
SimpleTimer.default_coll_mode = "avg"
_coll_mode_name = None
_moment_fn_lang = "rust"
_test_files = { # file name: repeat number
"ellipsoid_frames": 16,
"ellipsoid_frames": 4,
# "both_rotating_in_z": 1, # Results in key error in frames.arrays['c_q']
# "face_to_face": 1,
# "random_rotations": 1,
Expand Down Expand Up @@ -153,11 +153,13 @@ def single_pass(file_path: str, *, timer: SimpleTimer = None):
timer.mark("7. standardize keys")
internal_timer.clear_time()

my_cg = ClebschGordanReal(l_max, timer=internal_timer, cache_list=_cache_list)
if timer is not None:
my_cg = ClebschGordanReal(l_max, timer=internal_timer, cache_list=_cache_list)
timer.mark("8. constructing CGR")
timer.collect_and_append(internal_timer)
timer.mark_start()
else:
my_cg = ClebschGordanReal(l_max, cache_list=_cache_list)

anisoap_nu2 = cg_combine(
anisoap_nu1,
Expand Down Expand Up @@ -212,14 +214,14 @@ def single_pass(file_path: str, *, timer: SimpleTimer = None):
flatten_name.append(name + ": iter" + str(iter_num + 1))
out_file.write("stage," + ",".join(flatten_name) + "\n")

code_timer = SimpleTimer()
code_timer = SimpleTimer() if _write_mode == "time" else None
for test_file, rep_num in _test_files.items():
file_path = str(pathlib.Path(__file__).parent.parent.absolute()) + "/benchmarks/two_particle_gb/" + test_file + ".xyz"
for rep_index in range(rep_num):
print(f"Computation for {test_file}, iteration {rep_index + 1} has started")

if _write_mode == "result":
out_file.write(f"{test_file}, iter {rep_index + 1}\n")
out_file.write(f"{test_file}: iter {rep_index + 1}\n")

comp_result = single_pass(file_path, timer=code_timer)

Expand Down
Loading

0 comments on commit e6f9887

Please sign in to comment.