Skip to content

Commit

Permalink
fixed paths in tests.yaml; added dtype in .to_array() method; lbsim g…
Browse files Browse the repository at this point in the history
…ls routine now takes pointing flags from lbsim observations
  • Loading branch information
anand-avinash committed Oct 28, 2024
1 parent 5ee6c5a commit 9d59729
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
run: |
brew install libomp
echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV
echo "CPPFLAGS=-I$(brew --prefix llvm@15)/include -I$(brew --prefix libomp)/include" >> $GITHUB_ENV
echo "LDFLAGS=-L$(brew --prefix libomp)/lib -lomp" >> $GITHUB_ENV
echo "CPPFLAGS=\"-I$(brew --prefix llvm@15)/include -I$(brew --prefix libomp)/include\"" >> $GITHUB_ENV
echo "LDFLAGS=\"-L$(brew --prefix libomp)/lib -lomp\"" >> $GITHUB_ENV
- name: Install MPI ${{ matrix.mpi }}
uses: mpi4py/setup-mpi@v1
Expand All @@ -59,4 +59,4 @@ jobs:
fi
- name: Test BrahMap with pytest
run: bash ${GITHUB_WORKSPACE}/tests/mpiexec_test_loop.sh
run: bash ${GITHUB_WORKSPACE}/tests/tools/mpiexec_test_loop.sh
8 changes: 6 additions & 2 deletions brahmap/interfaces/linearoperators.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,13 @@ def mult(self, v):

return y

def __init__(self, a, size):
def __init__(self, a, size, dtype=None):
if dtype is None:
dtype = np.float64
else:
dtype = dtype
super(ToeplitzLO, self).__init__(
nargin=size, nargout=size, matvec=self.mult, symmetric=True
nargin=size, nargout=size, matvec=self.mult, symmetric=True, dtype=dtype
)
self.array = a

Expand Down
2 changes: 0 additions & 2 deletions brahmap/mapmakers/GLS.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ def compute_GLS_maps(
update_pointings_inplace=update_pointings_inplace,
)

inv_noise_cov_operator.pointings_flag = processed_samples.pointings_flag

pointing_operator = PointingLO(processed_samples=processed_samples)

blockdiagprecond_operator = BlockDiagonalPreconditionerLO(
Expand Down
11 changes: 8 additions & 3 deletions brahmap/mapmakers/lbsim_mapmakers.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def __init__(
def LBSim_compute_GLS_maps_from_obs(
nside: int,
obs: Union[lbs.Observation, List[lbs.Observation]],
pointings_flag: Union[np.ndarray, List[np.ndarray], None] = None,
inv_noise_cov_diagonal: Union[
LBSim_InvNoiseCovLO_UnCorr, InvNoiseCovLO_Uncorrelated, None
] = None,
Expand All @@ -104,11 +103,17 @@ def LBSim_compute_GLS_maps_from_obs(
else:
obs_list = obs

pointings = np.concatenate([ob.pointings for ob in obs_list]).reshape((-1, 2))
pointings = np.concatenate([obs.pointings for obs in obs_list]).reshape((-1, 2))
pol_angles = np.concatenate(
[ob.psi for ob in obs_list], axis=None
[obs.psi for obs in obs_list], axis=None
) # `axis=None` returns flattened arrays
tod = np.concatenate([getattr(obs, component) for obs in obs_list], axis=None)
if hasattr(obs_list[0], "pointings_flag"):
pointings_flag = np.concatenate(
[getattr(obs, "pointings_flag") for obs in obs_list], axis=None
)
else:
pointings_flag = None

lbsim_gls_result = LBSim_compute_GLS_maps(
nside=nside,
Expand Down
13 changes: 11 additions & 2 deletions tests/tools/mpiexec_test_loop.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/bin/bash

# Primary purpose of this script is to run the test using pytest on the BrahMap
# pakage. It runs the test for multiple number of MPI processes in a bash loop.
# In a simple case, the loop will terminate with an error if the test fails for
# an iteration. In this test instead, the loop will simply continue despite
# catching an error while recording the passing status of each iteration.
# Once the loop is over, the script will throw an error if any of the loop iteration
# fail. Otherwise, the script will terminate normally.


# Color formats
bbred='\033[1;91m' # bold bright red
bbgreen='\033[1;92m' # bold bright green
Expand Down Expand Up @@ -39,14 +48,14 @@ for nprocs in 1 2 5 6; do
done

if [ ${#error_nprocs[@]} -ne 0 ]; then
# exit 0, when some tests fail
# exit 1, when some tests fail
formatted_print \
"$(printf "${bbred}Test failed for nproc(s): ${error_nprocs[*]}${nc}")"\
"$error_nprocs"

exit 1
else
# when all tests are passing
# exit 0, when all tests are passing
formatted_print "$(printf "${bbgreen}Test passed for all nprocs${nc}")"

exit 0
Expand Down

0 comments on commit 9d59729

Please sign in to comment.