-
Notifications
You must be signed in to change notification settings - Fork 12
gh-136: Implementation of variable depth #535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
mwiet
wants to merge
69
commits into
main
Choose a base branch
from
mwiet/variable-depth
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
073e272
Added angular_variable_depth_mask and angular_los_variable_depth_mask…
mwiet 3f87848
Added new classes to the file's index
mwiet aa36f81
pre-commit.ci: style fixes
pre-commit-ci[bot] c7393fd
Updated class to follow CapWords convention
mwiet 31a5335
Updated class to follow CapWords convention
mwiet cfdaa58
Updated classes in index to follow CapWords convention
mwiet 51b0c1b
Fixed typing of variables throughout
mwiet d5e5863
Fixed docstrings throughout
mwiet 2a7ea91
Changed np.trapz to np.trapezoid
mwiet d3eed2f
Fixed ValueError to TypeError
mwiet 07ccec4
Added new citations for glass.observations.AngularLosVariableDepthMask
mwiet 7ce0c2d
Removed references from AngularLosVariableDepthMask docstring and mov…
mwiet 375d148
Fixed outstanding typing issues
mwiet 85a337e
Merge branch 'main' into mwiet/variable-depth
paddyroddy 5a79a47
Fixed np.trapezoid typo
mwiet 37f2183
Fixed np.trapezoid typo
mwiet c5649b2
Loaded Callable type object
mwiet 0467b0d
Added excemption to PLR0913/too many arguments
mwiet 78d7757
Fixed typo
mwiet 5b1268d
Removd whitespace
mwiet d5a0491
Added excemption to PLR0913/too many arguments
mwiet 1a1ff3f
Fixed pre-commit issues
mwiet 68d5089
Added excemption to PLR0913/too many arguments
mwiet 7b637f8
Tidy up docstrings
paddyroddy 585ea65
Run pre-commit
paddyroddy 1847e05
Add comma
paddyroddy b298f4e
Suppress no any return
paddyroddy 368b086
Adjusted typing of vardepth_tomo_functions
mwiet 746e4d8
Ensured consitency in the typing on zbins
mwiet fb9f83f
Tidied up line length
mwiet b094792
pre-commit.ci: style fixes
pre-commit-ci[bot] 36d6f0d
Merge branch 'main' into mwiet/variable-depth
paddyroddy 59b17e0
Add notebook from @mwiet and clear output
paddyroddy 6be4bfd
Fix surname
paddyroddy 9c44912
Tidy up imports
paddyroddy 65eecc4
Fix line length
paddyroddy 7e0f2c4
Fix
paddyroddy 56136cd
Fix [NPY002](https://docs.astral.sh/ruff/rules/numpy-legacy-random/)
paddyroddy 2267bee
Remove `plt.show`
paddyroddy cab715e
Better formatting
paddyroddy df4e5fc
Import direct from namespace
paddyroddy 3fbd7d0
Suppress plot output
paddyroddy dd60d4f
Reduce down to one `mollview` plot
paddyroddy 4134346
Add rng keyword arg where possible
paddyroddy 3228dfe
Remove duplicate rng generation
paddyroddy e518883
Turn off warning
paddyroddy 059ac59
Move notebook
paddyroddy 6f81ecb
Add title
paddyroddy d61e5f2
Clear output
paddyroddy b56028b
gh-578: mutable argument should be empty list rather than `None`
paddyroddy 5bc2588
Merge branch 'paddy/issue-578' into mwiet/variable-depth
paddyroddy a9f32e4
Merge branch 'main' into mwiet/variable-depth
paddyroddy 9bb8f8f
Fix import
paddyroddy 67e028f
Remove `nbstripout` temporarily
paddyroddy e564a8e
Merge branch 'main' into mwiet/variable-depth
paddyroddy cd71581
Fix notebook
paddyroddy 996e7e2
Restore
paddyroddy c8d1f5a
Add RNG
paddyroddy ab38ee3
Speed up sampling
paddyroddy d551fc3
Run notebook
paddyroddy d53e03c
Merge branch 'main' into mwiet/variable-depth
paddyroddy 683b458
Re-use maps
paddyroddy a5e4c0d
Fix notebook running
paddyroddy eb412f7
Increase timeout
paddyroddy 21f8cce
Change lmax
paddyroddy a4efa52
Revert "Increase timeout"
paddyroddy 8746064
Test AngularVariableDepthMask
paddyroddy 3e31f06
Rename notebook
paddyroddy 002785e
2 digit years
paddyroddy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| import healpix | ||
| import numpy as np | ||
| import pytest | ||
| from numpy.typing import NDArray | ||
|
|
||
| import glass | ||
| import glass.observations | ||
|
|
||
|
|
||
| def test_vmap_galactic_ecliptic() -> None: | ||
|
|
@@ -136,3 +138,86 @@ def test_tomo_nz_gausserr() -> None: | |
| # check the shape of the output | ||
|
|
||
| np.testing.assert_array_equal(binned_nz.shape, (len(zbins), len(z))) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I started to add tests yesterday before @ntessore's review. It feels pointless continuing these given the proposed changes. |
||
| ("vardepth_map", "n_bins", "zbins", "index", "expected_mask"), | ||
| [ | ||
| ( | ||
| np.array([[1.0, 2.0], [3.0, 4.0]]), | ||
| 2, | ||
| [(0.0, 0.5), (0.5, 1.0)], | ||
| (0, 0), | ||
| np.array([1.0, 2.0]), | ||
| ), | ||
| ( | ||
| np.array([[1.0, 2.0], [3.0, 4.0]]), | ||
| 2, | ||
| [(0.0, 0.5), (0.5, 1.0)], | ||
| (1, 1), | ||
| np.array([3.0, 4.0]), | ||
| ), | ||
| ], | ||
| ids=["test_valid_index_1", "test_valid_index_2"], | ||
| ) | ||
| def test_getitem_happy_path( | ||
| vardepth_map: NDArray[np.float64], | ||
| n_bins: int, | ||
| zbins: list[tuple[float, float]], | ||
| index: tuple[int, int], | ||
| expected_mask: NDArray[np.float64], | ||
| ) -> None: | ||
| # Arrange | ||
| mask = glass.observations.AngularVariableDepthMask(vardepth_map, n_bins, zbins) | ||
|
|
||
| # Act | ||
| result = mask[index] | ||
|
|
||
| # Assert | ||
| np.testing.assert_array_equal(result, expected_mask) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("vardepth_map", "n_bins", "zbins", "index", "expected_error"), | ||
| [ | ||
| ( | ||
| np.array([[1.0, 2.0], [3.0, 4.0]]), | ||
| 2, | ||
| [(0.0, 0.5), (0.5, 1.0)], | ||
| (2, 0), | ||
| ValueError, | ||
| ), | ||
| ( | ||
| np.array([[1.0, 2.0], [3.0, 4.0]]), | ||
| 2, | ||
| [(0.0, 0.5), (0.5, 1.0)], | ||
| (0, 2), | ||
| ValueError, | ||
| ), | ||
| ( | ||
| np.array([[1.0, 2.0], [3.0, 4.0]]), | ||
| 2, | ||
| [(0.0, 0.5), (0.5, 1.0)], | ||
| 0, | ||
| TypeError, | ||
| ), | ||
| ], | ||
| ids=[ | ||
| "test_invalid_index_1", | ||
| "test_invalid_index_2", | ||
| "test_invalid_index_type", | ||
| ], | ||
| ) | ||
| def test_getitem_error_cases( | ||
| vardepth_map: NDArray[np.float64], | ||
| n_bins: int, | ||
| zbins: list[tuple[float, float]], | ||
| index: tuple[int, int], | ||
| expected_error: type[BaseException], | ||
| ) -> None: | ||
| # Arrange | ||
| mask = glass.observations.AngularVariableDepthMask(vardepth_map, n_bins, zbins) | ||
|
|
||
| # Act & Assert | ||
| with pytest.raises(expected_error): | ||
| mask[index] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.