Skip to content

Commit

Permalink
modify pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuke-takase committed Aug 5, 2024
1 parent f0d204f commit 7c2bba4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[tool.poetry]
name = "sbm"
version = "0.1.0"
license = "GPL3"
description = "Spin-based map-making (SBM) for CMB experiments"
authors = ["yusuke-takase <[email protected]>"]
readme = "README.md"
Expand Down
Binary file not shown.
14 changes: 8 additions & 6 deletions tests/test.py → tests/test_sbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
from pathlib import Path
from sbm import ScanFields, SignalFields, Field
import healpy as hp
import os

class TestSBM(unittest.TestCase):
def setUp(self):
self.base_path = "../maps"
print(f"Current directory: {os.getcwd()}")
self.base_path = "maps"
self.scan_field = ScanFields.load_det(self.base_path, "nside128_boresight.h5")
self.input_map = hp.read_map("../maps/cmb_0000_nside_128_seed_33.fits", field=(0,1,2)) * 1e6
self.input_map = hp.read_map("maps/cmb_0000_nside_128_seed_33.fits", field=(0,1,2)) * 1e6
self.nside = hp.npix2nside(len(self.input_map[0]))

def test_diff_gain(self, save_output_map=False):
Expand All @@ -32,9 +34,9 @@ def test_diff_gain(self, save_output_map=False):
print(f"output_map.shape: {output_map.shape}")

if save_output_map==True:
hp.write_map("reference/diff_gain_output_map.fits", output_map)
hp.write_map("tests/reference/diff_gain_output_map.fits", output_map)
else:
reference = hp.read_map("reference/diff_gain_output_map.fits", field=(0,1,2))
reference = hp.read_map("tests/reference/diff_gain_output_map.fits", field=(0,1,2))
print(f"reference.shape: {reference.shape}")
self.assertTrue(np.allclose(output_map, reference))

Expand Down Expand Up @@ -75,9 +77,9 @@ def test_diff_pointing(self, save_output_map=False):
print(f"output_map.shape: {output_map.shape}")

if save_output_map==True:
hp.write_map("reference/diff_pointing_output_map.fits", output_map)
hp.write_map("tests/reference/diff_pointing_output_map.fits", output_map)
else:
reference = hp.read_map("reference/diff_pointing_output_map.fits", field=(0,1,2))
reference = hp.read_map("tests/reference/diff_pointing_output_map.fits", field=(0,1,2))
print(f"reference.shape: {reference.shape}")
self.assertTrue(np.allclose(output_map, reference))

Expand Down

0 comments on commit 7c2bba4

Please sign in to comment.