Skip to content

Commit

Permalink
Fix bug where theta_feature was not constrained to the interval [-p…
Browse files Browse the repository at this point in the history
…i, pi]
  • Loading branch information
MetinSa committed Nov 6, 2023
1 parent 225a421 commit 37c7ab8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ repos:
- id: check-yaml
langauge_version: python3

- repo: https://github.com/charliermarsh/ruff-pre-commit
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.241'
rev: v0.1.4
hooks:
- id: ruff
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pytest-cov = "^4.0.0"
mkdocs-material = "^9.0.1"
mkdocstrings = "^0.19.1"
mkdocstrings-python = "^0.8.2"
ruff = "^0.0.236"
ruff = "^0.1.4"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down Expand Up @@ -93,6 +93,7 @@ ignore = [
"D105",
"D107",
"ANN101",
"PLR0913",
]
exclude = ["tests/*"]

Expand Down
19 changes: 9 additions & 10 deletions zodipy/_ipd_dens_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
RingRRM,
)

"""The density functions for the different types of components.
"""The density functions for the different types of components.
Common for all of these is that the first argument will be `X_helio` (the line
of sight from the observer towards a point on the sky) and the remaining arguments
will be parameters that are set by the `Component` subclasses. These arguments are
unpacked automatically, so for a `ComputeDensityFunc` to work, the mapped `Component`
class must have all the parameters as instance variables.
Common for all of these is that the first argument will be `X_helio` (the line
of sight from the observer towards a point on the sky) and the remaining arguments
will be parameters that are set by the `Component` subclasses. These arguments are
unpacked automatically, so for a `ComputeDensityFunc` to work, the mapped `Component`
class must have all the parameters as instance variables.
"""
ComputeDensityFunc = Callable[..., npt.NDArray[np.float64]]
Expand Down Expand Up @@ -163,8 +163,7 @@ def compute_feature_density(
)

delta_theta = theta_comp - theta_rad
delta_theta = np.where(delta_theta < -np.pi, +2 * np.pi, delta_theta)
delta_theta = np.where(delta_theta > np.pi, -2 * np.pi, delta_theta)
delta_theta = (delta_theta + np.pi) % (2 * np.pi) - np.pi

# Differs from eq 9 in K98 by a factor of 1/2 in the first and last
# term. See Planck 2013 XIV, section 4.1.3.
Expand Down Expand Up @@ -430,7 +429,7 @@ def construct_density_partials(
for comp in comps:
comp_dict = asdict(comp)
func_params = inspect.signature(DENSITY_FUNCS[type(comp)]).parameters.keys()
residual_params = [key for key in func_params if key not in comp_dict.keys()]
residual_params = [key for key in func_params if key not in comp_dict]
try:
residual_params.remove("X_helio")
except ValueError as err:
Expand Down Expand Up @@ -472,7 +471,7 @@ def construct_density_partials_comps(
for comp_label, comp in comps.items():
comp_dict = asdict(comp)
func_params = inspect.signature(DENSITY_FUNCS[type(comp)]).parameters.keys()
residual_params = [key for key in func_params if key not in comp_dict.keys()]
residual_params = [key for key in func_params if key not in comp_dict]
try:
residual_params.remove("X_helio")
except ValueError as err:
Expand Down

0 comments on commit 37c7ab8

Please sign in to comment.