Skip to content

Commit

Permalink
Merge pull request #377 from adrn/make-getter
Browse files Browse the repository at this point in the history
Add implementation of make_getter (removed from astropy)
  • Loading branch information
adrn authored May 24, 2024
2 parents e0d599a + ebaf5bb commit 7750fee
Show file tree
Hide file tree
Showing 13 changed files with 196 additions and 163 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jobs:

# For animation tests
- uses: FedericoCarboni/setup-ffmpeg@v3
if: ${{ !startsWith(matrix.os, 'mac') }}
with:
# Not strictly necessary, but it may prevent rate limit
# errors especially on GitHub-hosted macos machines.
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ gala/cconfig.c
gala/dynamics/nbody/nbody.c

# Other generated files
*/version.py
*/cython_version.py
*/_version.py
htmlcov
.coverage
MANIFEST
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Bug fixes
- Fixed a bug in which passing a ``DirectNBody`` instance to the ``MockStreamGenerator.
run()`` would fail if ``save_all=False`` in the nbody instance.

- Fixed an incompatibility with Astropy v6.1 and above where ``_make_getter`` was
removed.


API changes
-----------
Expand Down
8 changes: 3 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-

import datetime
import os
import pathlib
import re
import sys
import datetime
from importlib import import_module
import warnings
from importlib import import_module

# Load all of the global Astropy configuration
try:
Expand Down Expand Up @@ -92,13 +92,11 @@
import_module(package_name)
package = sys.modules[package_name]

from cmastro import cmaps

plot_formats = [("png", 200), ("pdf", 200)]
plot_apply_rcparams = True
# NOTE: if you update these, also update docs/tutorials/nb_setup
plot_rcparams = {
"image.cmap": "cma:hesperia",
"image.cmap": "magma",
# Fonts:
"font.size": 16,
"figure.titlesize": "x-large",
Expand Down
40 changes: 17 additions & 23 deletions docs/tutorials/nb_setup
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@

get_ipython().magic('config InlineBackend.figure_format = "retina"') # noqa

import matplotlib.pyplot as plt
from cmastro import cmaps # noqa

plt.style.use("default")

# NOTE: if you update these, also update docs/conf.py
plot_rcparams = {
'image.cmap': 'cma:hesperia',

"image.cmap": "magma",
# Fonts:
'font.size': 16,
'figure.titlesize': 'x-large',
'axes.titlesize': 'large',
'axes.labelsize': 'large',
'xtick.labelsize': 'medium',
'ytick.labelsize': 'medium',

"font.size": 16,
"figure.titlesize": "x-large",
"axes.titlesize": "large",
"axes.labelsize": "large",
"xtick.labelsize": "medium",
"ytick.labelsize": "medium",
# Axes:
'axes.labelcolor': 'k',
'axes.axisbelow': True,

"axes.labelcolor": "k",
"axes.axisbelow": True,
# Ticks
'xtick.color': '#333333',
'xtick.direction': 'in',
'ytick.color': '#333333',
'ytick.direction': 'in',
'xtick.top': True,
'ytick.right': True,

'figure.dpi': 300,
'savefig.dpi': 300,
"xtick.color": "#333333",
"xtick.direction": "in",
"ytick.color": "#333333",
"ytick.direction": "in",
"xtick.top": True,
"ytick.right": True,
"figure.dpi": 300,
"savefig.dpi": 300,
}

plt.rcParams.update(plot_rcparams)
18 changes: 2 additions & 16 deletions gala/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@

import sys

__author__ = 'adrn <[email protected]>'
__author__ = "adrn <[email protected]>"

from ._astropy_init import *

# Enforce Python version check during package import.
# This is the same check as the one at the top of setup.py
__minimum_python_version__ = "3.7"


class UnsupportedPythonError(Exception):
pass


if sys.version_info < tuple((int(val)
for val in __minimum_python_version__.split('.'))):
raise UnsupportedPythonError(
f"packagename does not support Python < {__minimum_python_version__}")
from ._version import version as __version__
26 changes: 0 additions & 26 deletions gala/_astropy_init.py

This file was deleted.

20 changes: 10 additions & 10 deletions gala/coordinates/greatcircle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
from textwrap import dedent
from warnings import warn

import astropy.coordinates as coord

# Third-party
import astropy.units as u
import astropy.coordinates as coord
import numpy as np
from astropy.coordinates.attributes import CoordinateAttribute
from astropy.coordinates.baseframe import base_doc
from astropy.coordinates.transformations import (
DynamicMatrixTransform,
FunctionTransform,
)
from astropy.coordinates.attributes import CoordinateAttribute
from astropy.coordinates.baseframe import base_doc
from astropy.utils.decorators import format_doc
import numpy as np

from .helpers import StringValidatedAttribute

Expand All @@ -34,10 +35,7 @@ def get_xhat(zhat, ra0, tol=1e-10):
)

denom = (
z2**2
+ z3**2
+ 2 * z1 * z2 * np.tan(ra0)
+ (z1**2 + z3**2) * np.tan(ra0) ** 2
z2**2 + z3**2 + 2 * z1 * z2 * np.tan(ra0) + (z1**2 + z3**2) * np.tan(ra0) ** 2
)
x1 = -np.tan(ra0) * np.sqrt(z3**2 / denom)
x2 = x1 / np.tan(ra0)
Expand Down Expand Up @@ -506,8 +504,10 @@ def make_greatcircle_cls(cls_name, docstring_header=None, **kwargs):
@format_doc(base_doc, components=_components, footer=_footer)
@greatcircle_transforms(self_transform=False)
class GCFrame(GreatCircleICRSFrame):
pole = kwargs.get("pole", None)
origin = kwargs.get("origin", None)
pole = CoordinateAttribute(default=kwargs.get("pole", None), frame=coord.ICRS)
origin = CoordinateAttribute(
default=kwargs.get("origin", None), frame=coord.ICRS
)

GCFrame.__name__ = cls_name
if docstring_header:
Expand Down
2 changes: 2 additions & 0 deletions gala/coordinates/pm_cov_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def get_transform_matrix(from_frame, to_frame):
p = to_frame

if isinstance(trans, coord.DynamicMatrixTransform):
if not isinstance(p, coord.BaseCoordinateFrame):
p = p()
M = trans.matrix_func(currsys, p)
elif isinstance(trans, coord.StaticMatrixTransform):
M = trans.matrix
Expand Down
4 changes: 2 additions & 2 deletions gala/coordinates/tests/test_greatcircle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
coord.SkyCoord(ra=0 * u.deg, dec=90 * u.deg),
coord.SkyCoord(ra=0 * u.deg, dec=-90 * u.deg),
coord.SkyCoord(ra=12.3 * u.deg, dec=45.6 * u.deg, distance=1 * u.kpc),
coord.SkyCoord(ra=[12.3] * u.deg, dec=[45.6] * u.deg),
] + [coord.SkyCoord(lon, lat) for lon, lat in zip(rand_lon, rand_lat)]


Expand Down Expand Up @@ -188,7 +187,8 @@ def test_sph_midpoint():


def test_init_from_R():
from ..gd1 import R as gd1_R, GD1Koposov10
from ..gd1 import GD1Koposov10
from ..gd1 import R as gd1_R

N = 128
rnd = np.random.RandomState(42)
Expand Down
Loading

0 comments on commit 7750fee

Please sign in to comment.