Skip to content

Commit

Permalink
Merge pull request #33 from radionets-project/tqdm_support
Browse files Browse the repository at this point in the history
Changes in vis_loop
  • Loading branch information
Kevin2 authored Jul 18, 2024
2 parents ed7ad00 + 21ce8ff commit a038bd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/changes/33.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Changes to `vis_loop` function in `visibility.py`:
- add a an optional tqdm progress bar to get a visual confirmation the calculation is still running
- add optional `batch_size` parameter to control memory consumption
11 changes: 9 additions & 2 deletions pyvisgen/simulation/visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import pyvisgen.simulation.scan as scan

from tqdm import tqdm


@dataclass
class Visibilities:
Expand Down Expand Up @@ -37,7 +39,7 @@ def add(self, visibilities):
]


def vis_loop(obs, SI, num_threads=10, noisy=True, mode="full"):
def vis_loop(obs, SI, num_threads=10, noisy=True, mode="full", batch_size=100, show_progress=False):
torch.set_num_threads(num_threads)
torch._dynamo.config.suppress_errors = True

Expand Down Expand Up @@ -93,7 +95,12 @@ def vis_loop(obs, SI, num_threads=10, noisy=True, mode="full"):
else:
raise ValueError("Unsupported mode!")

for p in torch.arange(bas[:].shape[1]).split(1000):
batches = torch.arange(bas[:].shape[1]).split(batch_size)

if show_progress:
batches = tqdm(batches)

for p in batches:
bas_p = bas[:][:, p]

int_values = torch.cat(
Expand Down

0 comments on commit a038bd8

Please sign in to comment.