Skip to content

Commit

Permalink
Remove make_from_counts
Browse files Browse the repository at this point in the history
  • Loading branch information
delucchi-cmu committed Jan 6, 2025
1 parent 6622a51 commit 7a26c0f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/hats_import/catalog/map_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ def map_to_pixels(
):
mapped_pixel, count_at_pixel = np.unique(mapped_pixels, return_counts=True)

partial = SparseHistogram.make_from_counts(
mapped_pixel, count_at_pixel, healpix_order=highest_order
)
histo.add(partial)
histo.add(SparseHistogram(mapped_pixel, count_at_pixel, highest_order))

histo.to_sparse().to_file(
ResumePlan.partial_histogram_file(tmp_path=resume_path, mapping_key=mapping_key)
Expand Down
4 changes: 2 additions & 2 deletions tests/hats_import/catalog/test_resume_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_read_write_histogram(tmp_path):
remaining_keys = plan.get_remaining_map_keys()
assert remaining_keys == [("map_0", "foo1")]

histogram = SparseHistogram.make_from_counts([11], [131], 0)
histogram = SparseHistogram([11], [131], 0)
histogram.to_file(ResumePlan.partial_histogram_file(tmp_path=tmp_path, mapping_key="map_0"))

remaining_keys = plan.get_remaining_map_keys()
Expand Down Expand Up @@ -118,7 +118,7 @@ def test_some_map_task_failures(tmp_path, dask_client):
with pytest.raises(RuntimeError, match="map stages"):
plan.wait_for_mapping(futures)

histogram = SparseHistogram.make_from_counts([11], [131], 0)
histogram = SparseHistogram([11], [131], 0)
histogram.to_file(ResumePlan.partial_histogram_file(tmp_path=tmp_path, mapping_key="map_0"))

## Method succeeds, *and* partial histogram is present.
Expand Down
10 changes: 5 additions & 5 deletions tests/hats_import/catalog/test_run_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def test_resume_dask_runner(
## Now set up our resume files to match previous work.
resume_tmp = tmp_path / "tmp" / "resume_catalog"
ResumePlan(tmp_path=resume_tmp, progress_bar=False)
histogram = SparseHistogram.make_from_counts([11], [131], 0)
empty = SparseHistogram.make_empty(0)
histogram = SparseHistogram([11], [131], 0)
empty = SparseHistogram([], [], 0)
for file_index in range(0, 5):
ResumePlan.touch_key_done_file(resume_tmp, ResumePlan.SPLITTING_STAGE, f"split_{file_index}")
histogram_file = ResumePlan.partial_histogram_file(
Expand Down Expand Up @@ -139,7 +139,7 @@ def test_resume_dask_runner_diff_pixel_order(
## Now set up our resume files to match previous work.
resume_tmp = tmp_path / "tmp" / "resume_catalog"
ResumePlan(tmp_path=resume_tmp, progress_bar=False)
SparseHistogram.make_from_counts([11], [131], 0).to_dense_file(resume_tmp / "mapping_histogram.npz")
SparseHistogram([11], [131], 0).to_dense_file(resume_tmp / "mapping_histogram.npz")
for file_index in range(0, 5):
ResumePlan.touch_key_done_file(resume_tmp, ResumePlan.SPLITTING_STAGE, f"split_{file_index}")

Expand Down Expand Up @@ -203,8 +203,8 @@ def test_resume_dask_runner_histograms_diff_size(
ResumePlan(tmp_path=resume_tmp, progress_bar=False)

# We'll create mock partial histograms of size 0 and 2
histogram = SparseHistogram.make_empty(0)
wrong_histogram = SparseHistogram.make_empty(2)
histogram = SparseHistogram([], [], 0)
wrong_histogram = SparseHistogram([], [], 2)

for file_index in range(0, 5):
ResumePlan.touch_key_done_file(resume_tmp, ResumePlan.SPLITTING_STAGE, f"split_{file_index}")
Expand Down

0 comments on commit 7a26c0f

Please sign in to comment.