Skip to content

Commit 5ebc11d

Browse files
nstarmaneerovaher
andcommitted
documentation
Signed-off-by: nstarman <nstarman@users.noreply.github.com> Co-authored-by: Eero Vaher <eero.vaher@fysik.lu.se> Signed-off-by: nstarman <nstarman@users.noreply.github.com>
1 parent b43d1ba commit 5ebc11d

8 files changed

Lines changed: 40 additions & 16 deletions

File tree

astropy/cosmology/connect.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ def __getattr__(name):
3333

3434
# Raise deprecation warning
3535
warnings.warn(
36-
f"{name} is deprecated (since v6.0) and will be removed in a future version. "
36+
f"astropy.cosmology.connect.{name} is deprecated (since v6.0)"
37+
" and will be removed in a future version. "
3738
f"Use astropy.cosmology.io.{name} instead.",
3839
AstropyDeprecationWarning,
39-
stacklevel=2,
40+
stacklevel=1,
4041
)
4142

4243
return obj

astropy/cosmology/io/_connect.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# Read / Write
1818

1919
readwrite_registry = io_registry.UnifiedIORegistry()
20+
"""Registry for reading and writing cosmology objects."""
2021

2122

2223
class CosmologyRead(io_registry.UnifiedReadWrite):
@@ -139,6 +140,7 @@ def __call__(self, *args, **kwargs):
139140
# for transforming instances, e.g. Cosmology <-> dict
140141

141142
convert_registry = io_registry.UnifiedIORegistry()
143+
"""Registry for converting cosmology objects to and from other formats."""
142144

143145

144146
class CosmologyFromFormat(io_registry.UnifiedReadWrite):
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
A new module -- ``astropy.cosmology.io`` -- has been added for all cosmology I/O
2-
functionality. ``astropy.cosmology.connect`` has been deprecated and will be removed in
3-
a future version; it's contents are now in ``astropy.cosmology.io``.
1+
``astropy.cosmology.connect`` has been renamed to ``astropy.cosmology.io``.
2+
The module is still available under its old name, but that has been deprecated
3+
and will be removed in a future version.

docs/cosmology/io/builtin.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Row
6969
.. automodule:: astropy.cosmology.io._builtin.row
7070

7171

72+
.. _cosmology_io_builtin_readwrite:
7273

7374
*************************************
7475
Built-in Cosmology Read/Write Formats

docs/cosmology/io/details.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ object is using the :mod:`pickle` module. This is good for e.g. passing a
2828

2929
However this method has all the attendant drawbacks of :mod:`pickle` — security
3030
vulnerabilities and non-human-readable files. Pickle files just generally don't
31-
make for good persistent storage.
32-
33-
Solving both these issues, ``astropy`` provides a unified interface for reading
34-
and writing data in different formats.
31+
make for good persistent storage. See :ref:`cosmology_io_builtin_readwrite` for
32+
better options.
3533

3634

3735
.. _cosmology_io_renaming_fields:

docs/cosmology/io/index.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Cosmology I/O & Convert
99
Introduction
1010
============
1111

12-
The ``astropy.cosmology.io`` package provides a unified interface for reading, writing,
13-
and converting |Cosmology| objects. Most of the features of this package are accessible
14-
through the |Cosmology| class, which provides the methods |Cosmology.read|,
12+
The :mod:`astropy.cosmology.io` package provides a unified interface for reading,
13+
writing, and converting |Cosmology| objects. Most of the features of this package are
14+
accessible through the |Cosmology| class, which provides the methods |Cosmology.read|,
1515
|Cosmology.write|, |Cosmology.to_format|, and |Cosmology.from_format| for reading,
1616
writing, and converting |Cosmology| objects, respectively.
1717

@@ -89,8 +89,8 @@ instances between packages!
8989

9090
.. EXAMPLE START: Planck18 to QTable and back
9191
92-
Another pre-registered format is "table", for converting a |Cosmology| to and
93-
from a |QTable|.
92+
One of the pre-registered conversion formats is "astropy.table", for converting a
93+
|Cosmology| to and from a |QTable|.
9494

9595
.. code-block::
9696
@@ -154,3 +154,5 @@ Reference/API
154154
=============
155155

156156
.. automodapi:: astropy.cosmology.io
157+
:no-heading:
158+
:include-all-objects:

docs/cosmology/units.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ for unit conversions and equivalencies, use
2323
About the Units
2424
===============
2525

26-
.. doctest::
27-
:hide:
26+
.. testsetup::
2827

2928
>>> import astropy.units as u
3029

docs/whatsnew/6.0.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,27 @@ method, allowing users to export a cosmology object to a LaTeX table.::
155155
This will write the cosmology object to a file in LaTeX format,
156156
with appropriate formatting of units and table alignment.
157157

158+
I/O Module
159+
----------
160+
161+
The new :mod:`~astropy.cosmology.io` module contains the classes and functions that are
162+
used to read and write, cosmology instances to different file formats, and to convert
163+
cosmologies between different object representations. In particular, the
164+
:mod:`~astropy.cosmology.io` module provides the classes
165+
:class:`~astropy.cosmology.io.CosmologyRead`,
166+
:class:`~astropy.cosmology.io.CosmologyWrite`,
167+
:class:`~astropy.cosmology.io.CosmologyFromFormat`,
168+
:class:`~astropy.cosmology.io.CosmologyToFormat` and registries
169+
:obj:`~astropy.cosmology.io.readwrite_registry`,
170+
:obj:`~astropy.cosmology.io.convert_registry`, which enable
171+
:class:`~astropy.cosmology.Cosmology` class for |Cosmology.read|, |Cosmology.write|,
172+
|Cosmology.from_format|, and |Cosmology.to_format|.
173+
174+
The public :mod:`~astropy.cosmology.io` module replaces the old semi-private
175+
:mod:`~astropy.cosmology.connect` module. It is intended that more public I/O
176+
functionality will be added to the :mod:`~astropy.cosmology.io` module in the future.
177+
178+
158179
Renaming fields in I/O
159180
----------------------
160181

0 commit comments

Comments
 (0)