Skip to content

Commit 784dde1

Browse files
authored
Merge pull request #962 from Christopher-Bradshaw/docs-readthrough
Docs readthrough [WIP]
2 parents b8198cf + f8c7372 commit 784dde1

35 files changed

+255
-232
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Getting Started
2626
quickstart_and_tutorials/index
2727
function_usage/index
2828
source_notes/index
29+
quickstart_and_tutorials/development/index
2930

3031
***********
3132
What's New?
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.. _getting_started_developers:
2+
3+
*************************
4+
Contributing to Halotools
5+
*************************
6+
7+
All halotools development happens in the github repository. To contribute, first clone the repo.
8+
Then install the dependencies listed on the :ref:`step_by_step_install` page.
9+
10+
11+
Code
12+
====
13+
14+
Halotools contains a compiled component. To compile all cython (``.pyx``) files inplace run, ::
15+
16+
python3 setup.py build_ext --inplace
17+
18+
If you modify a ``.pyx`` file use the same command to recompile it. Subsequent runs will only compile files whose source has changed and so will be much quicker.
19+
20+
Halotools also has comprehensive unit tests and uses pytest. To run all tests, assuming you are in the base of the repository, first change directory into ``halotools`` and then run ``pytest``. ::
21+
22+
cd halotools
23+
pytest
24+
25+
If you have made a change and only want to run a subset of tests run, ::
26+
27+
pytest -k tests_matching_this_string_will_run
28+
29+
Run ``pytest --help`` for a full list of options.
30+
31+
32+
Docs
33+
====
34+
35+
First ensure that the halotools package and sphinx are installed. From the base of the repository run, ::
36+
37+
pip3 install -e .
38+
pip3 install sphinx==1.3.1 # see docs/conf.py for the sphinx version
39+
40+
Then build documentation with, ::
41+
42+
cd docs
43+
make html
44+
45+
You can see the built documentation in ``docs/_build/html/``. The easiest way to view it in your browser is to spin up a local server. One way to do this is to run, from the built directory, ::
46+
47+
python3 -m http.server
48+
49+
The docs should then be viewable at ``localhost:8000`` (the port will be logged when you start the server).

docs/quickstart_and_tutorials/development/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ contribute to the Halotools code base.
1414

1515
staying_up_to_date
1616
bug_reports
17+
getting_started
1718
contributors
1819
../../changelog

halotools/empirical_models/abunmatch/bin_free_cam.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ def conditional_abunmatch(x, y, x2, y2, nwin, add_subgrid_noise=True,
1111
assume_x_is_sorted=False, assume_x2_is_sorted=False, return_indexes=False):
1212
r"""
1313
Given a set of input points with primary property `x` and secondary property `y`,
14-
use conditional abundance matching to map new values `ynew` onto the input points
15-
such that :math:`P(<y_{\rm new} | x) = P(<y_2 | x)`, and also that
16-
`y` and `ynew` are in monotonic correspondence at fixed `x`.
14+
and a mapping between that primary property and another secondary property
15+
(`y2 | x2`), assign values of the `y2` property to the input points.
16+
17+
The `y2` that is assigned (`ynew`) is in monotonic correspondence with `y` at
18+
fixed `x`. Therefore, :math:`P(<y_{\rm new} | x) = P(<y | x)`.
19+
20+
See :ref:`cam_tutorial` demonstrating how to use this function in galaxy-halo
21+
modeling with several worked examples.
1722
1823
Parameters
1924
----------
@@ -24,10 +29,10 @@ def conditional_abunmatch(x, y, x2, y2, nwin, add_subgrid_noise=True,
2429
Numpy array of shape (n1, ) storing the secondary property of the input points.
2530
2631
x2 : ndarray
27-
Numpy array of shape (n2, ) storing the primary property of the desired distribution.
32+
Numpy array of shape (n2, ) storing the primary property of the desired distribution. This should be the same physical property (e.g. halo mass) as x.
2833
2934
y2 : ndarray
30-
Numpy array of shape (n2, ) storing the secondary property of the desired distribution.
35+
Numpy array of shape (n2, ) storing the secondary property of the desired distribution. This is a different physical property to y.
3136
3237
nwin : int
3338
Odd integer specifying the size of the window
@@ -75,9 +80,6 @@ def conditional_abunmatch(x, y, x2, y2, nwin, add_subgrid_noise=True,
7580
values of ``window_length`` must exceed 100. Values more tha a few hundred are
7681
likely overkill when using the (recommended) sub-grid noise option.
7782
78-
See :ref:`cam_tutorial` demonstrating how to use this
79-
function in galaxy-halo modeling with several worked examples.
80-
8183
With the release of Halotools v0.7, this function replaced a previous function
8284
of the same name. The old function is now called
8385
`~halotools.empirical_models.conditional_abunmatch_bin_based`.

halotools/empirical_models/abunmatch/noisy_percentile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def noisy_percentile(percentile, correlation_coeff, seed=None, random_percentile
6969
Returns
7070
-------
7171
noisy_percentile : ndarray
72-
Numpy array of shape (ngals, ) storing an array such that
72+
Numpy array of shape (npts, ) storing an array such that
7373
the Spearman rank-order correlation coefficient between
7474
``percentile`` and ``noisy_percentile`` is equal to the input
7575
``correlation_coeff``.

halotools/mock_observables/catalog_analysis_helpers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def return_xyz_formatted_array(x, y, z, period=np.inf,
131131
galaxy positions under the distant-observer approximation.
132132
Default is no distortions.
133133
134-
cosmology : object, optional
134+
cosmology : astropy.cosmology.Cosmology, optional
135135
Cosmology to assume when applying redshift-space distortions,
136136
e.g., the cosmology of the simulation.
137137
Default is set in `sim_manager.sim_defaults`.
@@ -264,7 +264,7 @@ def apply_zspace_distortion(true_pos, peculiar_velocity, redshift, cosmology, Lb
264264
redshift of the snapshot. If using a lightcone, this argument is the
265265
redshift of each point.
266266
267-
cosmology : object
267+
cosmology : astropy.cosmology.Cosmology
268268
Cosmology to assume when applying redshift-space distortions,
269269
e.g., the cosmology of the simulation.
270270
@@ -308,9 +308,9 @@ def cuboid_subvolume_labels(sample, Nsub, Lbox):
308308
309309
Nsub : array_like
310310
Length-3 numpy array of integers indicating how many times to split the volume
311-
along each dimension. If single integer, N, is supplied, ``Nsub`` is set to
311+
along each dimension. If a single integer, N, is supplied, ``Nsub`` is set to
312312
[N,N,N], and the volume is split along each dimension N times. The total number
313-
of subvolumes is then given by numpy.prod(Nsub).
313+
of subvolumes is given by numpy.prod(Nsub).
314314
315315
Lbox : array_like
316316
Length-3 numpy array definging the lengths of the sides of the cubical volume
@@ -320,7 +320,7 @@ def cuboid_subvolume_labels(sample, Nsub, Lbox):
320320
Returns
321321
-------
322322
labels : numpy.array
323-
numpy array with integer labels in the range [1,numpy.prod(Nsub)] indicating
323+
(Npts, ) numpy array with integer labels in the range [1,numpy.prod(Nsub)] indicating
324324
the subvolume each point in ``sample`` occupies.
325325
326326
N_sub_vol : int

halotools/mock_observables/isolation_functions/conditional_cylindrical_isolation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def conditional_cylindrical_isolation(sample1, sample2, rp_max, pi_max,
6060
If a single float is given, ``rp_max`` is assumed to be the same for each galaxy in
6161
``sample1``. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.
6262
63-
pi_max : float
63+
pi_max : array_like
6464
half the length of cylinders to search for neighbors around galaxies in ``sample1``.
6565
If a single float is given, ``pi_max`` is assumed to be the same for each galaxy in
6666
``sample1``. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.
@@ -117,7 +117,7 @@ def conditional_cylindrical_isolation(sample1, sample2, rp_max, pi_max,
117117
Returns
118118
-------
119119
is_isolated : numpy.array
120-
array of booleans indicating if each point in `sample1` is isolated.
120+
(Npts1, ) array of booleans indicating if each point in `sample1` is isolated.
121121
122122
Notes
123123
-----

halotools/mock_observables/isolation_functions/spherical_isolation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def spherical_isolation(sample1, sample2, r_max, period=None,
8888
Returns
8989
-------
9090
is_isolated : numpy.array
91-
array of booleans indicating if each point in `sample1` is isolated.
91+
(Npts1, ) array of booleans indicating if each point in `sample1` is isolated.
9292
9393
Examples
9494
--------

halotools/mock_observables/large_scale_density/large_scale_density_spherical_annulus.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def large_scale_density_spherical_annulus(sample, tracers, inner_radius, outer_r
8888
Returns
8989
--------
9090
number_density : array_like
91-
Length-Npts array of number densities
91+
Length-Npts1 array of number densities
9292
9393
Examples
9494
---------
@@ -105,9 +105,9 @@ def large_scale_density_spherical_annulus(sample, tracers, inner_radius, outer_r
105105
period, sample_volume, num_threads, approx_cell1_size)
106106
)
107107

108-
_ = npairs_per_object_3d(sample, tracers, rbins, period=period,
108+
result = npairs_per_object_3d(sample, tracers, rbins, period=period,
109109
num_threads=num_threads, approx_cell1_size=approx_cell1_size)
110-
result = np.diff(_, axis=1)
110+
result = np.diff(result, axis=1)
111111

112112
environment_volume = (4/3.)*np.pi*(outer_radius**3 - inner_radius**3)
113113
number_density = result/environment_volume

halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def large_scale_density_spherical_volume(sample, tracers, radius,
8787
Returns
8888
--------
8989
number_density : array_like
90-
Length-Npts array of number densities
90+
Length-Npts1 array of number densities
9191
9292
Examples
9393
---------
@@ -103,9 +103,8 @@ def large_scale_density_spherical_volume(sample, tracers, radius,
103103
sample, tracers, radius, period, sample_volume, num_threads, approx_cell1_size)
104104
)
105105

106-
_ = npairs_per_object_3d(sample, tracers, rbins, period=period,
107-
num_threads=num_threads, approx_cell1_size=approx_cell1_size)
108-
result = _[:, 0]
106+
result = npairs_per_object_3d(sample, tracers, rbins, period=period,
107+
num_threads=num_threads, approx_cell1_size=approx_cell1_size)[:, 0]
109108

110109
environment_volume = (4/3.)*np.pi*radius**3
111110
number_density = result/environment_volume
@@ -123,8 +122,8 @@ def _large_scale_density_spherical_volume_process_args(
123122
"""
124123
sample = np.atleast_1d(sample)
125124
tracers = np.atleast_1d(tracers)
126-
_ = np.atleast_1d(radius).astype(float)
127-
rbins = np.append(_, _[0]+0.0001)
125+
rbins = np.atleast_1d(radius).astype(float)
126+
rbins = np.append(rbins, rbins[0]+0.0001)
128127

129128
if period is None:
130129
if sample_volume is None:

0 commit comments

Comments
 (0)