Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#35)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.4 → v0.1.6](astral-sh/ruff-pre-commit@v0.1.4...v0.1.6)
- [github.com/psf/black: 23.10.1 → 23.11.0](psf/black@23.10.1...23.11.0)
- [github.com/nbQA-dev/nbQA: 1.7.0 → 1.7.1](nbQA-dev/nbQA@1.7.0...1.7.1)

* fixes
* Add property uninterpolated
* update rtd

Signed-off-by: nstarman <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Dec 6, 2023
1 parent a8c12ea commit 530b3f3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.4
rev: v0.1.6
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/psf/black
rev: 23.10.1
rev: 23.11.0
hooks:
- id: black
additional_dependencies: ["toml"]

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
rev: 1.7.1
hooks:
- id: nbqa-black
- id: nbqa-flake8
Expand Down
9 changes: 3 additions & 6 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
version: 2

build:
os: ubuntu-20.04
apt_packages:
- graphviz
os: "ubuntu-20.04"
tools:
python: "3.9"
python: "3.11"

sphinx:
builder: html
Expand All @@ -15,13 +13,12 @@ sphinx:
# Install regular dependencies.
# Then, install special pinning for RTD.
python:
system_packages: false
install:
- method: pip
path: .
extra_requirements:
- docs
- test
- all

# Don't build any extra formats
formats: []
4 changes: 2 additions & 2 deletions src/interpolated_coordinates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
derivatives can also be constructed, but they do not have a corresponding class
in Astropy, so a "Generic" class is constructed.
>>> irep.derivative(n=2)[:4]
<InterpolatedGenericCartesian2ndDifferential (affine| d_x, d_y, d_z) in ...
>>> irep.derivative(n=2)[:4] # doctest: +FLOAT_CMP
<InterpolatedGenericCartesian2ndDifferential (affine| d_x, d_y, d_z) in Myr| kpc / Myr2
[(0. , -5.41233725e-16, 3.35564909e-15, -9.45535317e-14),
(0.25641026, 1.80411242e-17, -2.88657986e-16, -1.91326122e-14),
(0.51282051, 5.77315973e-16, -3.93296506e-15, 5.62883073e-14),
Expand Down
14 changes: 11 additions & 3 deletions src/interpolated_coordinates/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ def realize_frame(
frame = self.frame.realize_frame(data, **kwargs)
return self._class_(frame, affine=affine, **kwargs)

@property
def uninterpolated(self) -> BaseCoordinateFrame:
"""Return uninterpolated CoordinateFrame."""
return self.frame.realize_frame(self.frame.data.uninterpolated)

#################################################################
# Interpolation Methods
# Mapped to underlying Representation
Expand Down Expand Up @@ -562,6 +567,11 @@ def __call__(self, affine: Quantity | None = None) -> SkyCoord:
"""
return SkyCoord(self.frame(affine))

@property
def uninterpolated(self) -> SkyCoord:
"""Return uninterpolated SkyCoord."""
return SkyCoord(self.frame.uninterpolated)

def transform_to(
self,
frame: FrameLikeType,
Expand Down Expand Up @@ -604,9 +614,7 @@ def transform_to(
ValueError
If there is no possible transformation route.
"""
sc = SkyCoord(self, copy=False) # TODO, less jank
nsc = sc.transform_to(frame, merge_attributes=merge_attributes)

nsc = self.uninterpolated.transform_to(frame, merge_attributes=merge_attributes)
return self.__class__(nsc, affine=self.affine, copy=False)

# -----------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions src/interpolated_coordinates/representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,11 @@ def derivative(self, n: int = 1) -> InterpolatedDifferential:
#################################################################
# Mapping to Underlying Representation

@property
def uninterpolated(self) -> BaseRepresentationOrDifferential:
"""Return the underlying Representation."""
return self.data

# ---------------------------------------------------------------
# Hidden methods

Expand Down Expand Up @@ -710,6 +715,13 @@ def __call__(self, affine: u.Quantity | None = None) -> BaseRepresentation:

return self.data.__class__(**params, differentials=differentials)

@property
def uninterpolated(self) -> BaseRepresentation:
"""Return the underlying Representation."""
data = copy.deepcopy(self.data)
data.diffentials = {k: dif.uninterpolated for k, dif in data.differentials.items()}
return data

# ---------------------------------------------------------------

# TODO just wrap self.data method with a wrapper?
Expand Down
2 changes: 1 addition & 1 deletion src/interpolated_coordinates/utils/spline.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def derivatives(self, x: Quantity) -> ndarray:
>>> x = np.linspace(0, 3, 11)
>>> y = x**2
>>> spl = UnivariateSpline(x, y)
>>> spl.derivatives(1.5) # doctest: +FLOAT_CMP
>>> np.round(spl.derivatives(1.5), 2) # doctest: +FLOAT_CMP
array([2.25, 3. , 2. , 0. ])
"""
x_val: float = x.to_value(self._xunit)
Expand Down

0 comments on commit 530b3f3

Please sign in to comment.