Skip to content
This repository was archived by the owner on Aug 8, 2024. It is now read-only.

Commit 819a2f2

Browse files
committed
run commit black and isort
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
1 parent 27832e5 commit 819a2f2

File tree

7 files changed

+54
-17
lines changed

7 files changed

+54
-17
lines changed

docs/conf.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@
146146

147147
# Grouping the document tree into LaTeX files. List of tuples
148148
# (source start file, target name, title, author, documentclass [howto/manual]).
149-
latex_documents = [("index", project + ".tex", project + u" Documentation", author, "manual")]
149+
latex_documents = [
150+
("index", project + ".tex", project + u" Documentation", author, "manual"),
151+
]
150152

151153

152154
# -- Options for manual page output -------------------------------------------

pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ force_grid_wrap = 0
1515
use_parentheses = "True"
1616
ensure_newline_before_comments = "True"
1717
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
18-
19-
known_third_party = ["astropy", "extension_helpers", "setuptools"]
18+
known_third_party = ["astropy", "extension_helpers", "galpy", "numpy", "scipy", "setuptools"]
2019
known_localfolder = "sample_scf"
2120

2221
import_heading_stdlib = "BUILT-IN"

sample_scf/_typing.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
# Licensed under a 3-clause BSD style license - see LICENSE.rst
23
# BUILT-IN
34
import typing as T

sample_scf/base.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ def phisampler(self) -> rv_continuous_modrvs:
109109

110110
# /def
111111

112-
def cdf(self, r: npt.ArrayLike, theta: npt.ArrayLike, phi: npt.ArrayLike) -> NDArray64:
112+
def cdf(
113+
self,
114+
r: npt.ArrayLike,
115+
theta: npt.ArrayLike,
116+
phi: npt.ArrayLike,
117+
) -> NDArray64:
113118
"""
114119
Cumulative Distribution Functions in r, theta(r), phi(r, theta)
115120
@@ -156,7 +161,9 @@ def rvs(
156161
phis = self.phisampler.rvs(rs, thetas, size=size, random_state=random_state)
157162

158163
crd = PhysicsSphericalRepresentation(
159-
r=rs, theta=(np.pi / 2 - thetas) * u.rad, phi=phis * u.rad
164+
r=rs,
165+
theta=(np.pi / 2 - thetas) * u.rad,
166+
phi=phis * u.rad,
160167
)
161168
return crd
162169

sample_scf/sample_exact.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
# LOCAL
2525
from ._typing import NDArray64, RandomLike
26-
27-
# PROJECT-SPECIFIC
2826
from .base import SCFSamplerBase, rv_continuous_modrvs
2927
from .utils import _x_of_theta, difPls, phiRSms, thetaQls, x_of_theta
3028

@@ -332,7 +330,7 @@ def _cdf(self, phi: NDArray64, *args: T.Any, **kw: T.Any) -> NDArray64:
332330
factor = 1 / Rm[0] # R0
333331
ms = np.arange(1, Rm.shape[1])
334332
term1p = np.sum(
335-
(Rm[1:] * np.sin(ms * phi) + Sm[1:] * (1 - np.cos(ms * phi))) / (2 * np.pi * ms)
333+
(Rm[1:] * np.sin(ms * phi) + Sm[1:] * (1 - np.cos(ms * phi))) / (2 * np.pi * ms),
336334
)
337335

338336
cdf: NDArray64 = term0 + factor * term1p

sample_scf/sample_intrp.py

+34-7
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ def __init__(
122122
) -> None:
123123
# compute the r-dependent coefficient matrix $\tilde{\rho}$
124124
nmax, lmax = pot._Acos.shape[:2]
125-
rhoTilde = np.array([pot._rhoTilde(r, N=nmax, L=lmax) for r in rgrid]) # (R, N, L)
125+
rhoTilde = np.array(
126+
[pot._rhoTilde(r, N=nmax, L=lmax) for r in rgrid],
127+
) # (R, N, L)
126128

127129
# ----------
128130
# theta Qls
@@ -134,7 +136,13 @@ def __init__(
134136
# phi Rm, Sm
135137
# radial and inclination sums
136138

137-
Rm, Sm = _phiRSms(rhoTilde, Acos=pot._Acos, Asin=pot._Asin, r=rgrid, theta=thetagrid)
139+
Rm, Sm = _phiRSms(
140+
rhoTilde,
141+
Acos=pot._Acos,
142+
Asin=pot._Asin,
143+
r=rgrid,
144+
theta=thetagrid,
145+
)
138146

139147
# ----------
140148
# make samplers
@@ -184,8 +192,18 @@ def __init__(self, pot: SCFPotential, rgrid: NDArray64, **kw: T.Any) -> None:
184192
# work in zeta, not r, since it is more numerically stable
185193
zeta = zeta_of_r(rgrid)
186194
# make splines for fast calculation
187-
self._spl_cdf = InterpolatedUnivariateSpline(zeta, mgrid, ext="raise", bbox=[-1, 1])
188-
self._spl_ppf = InterpolatedUnivariateSpline(mgrid, zeta, ext="raise", bbox=[0, 1])
195+
self._spl_cdf = InterpolatedUnivariateSpline(
196+
zeta,
197+
mgrid,
198+
ext="raise",
199+
bbox=[-1, 1],
200+
)
201+
self._spl_ppf = InterpolatedUnivariateSpline(
202+
mgrid,
203+
zeta,
204+
ext="raise",
205+
bbox=[0, 1],
206+
)
189207

190208
# TODO! make sure
191209
# # store endpoint values to ensure CDF normalized to [0, 1]
@@ -479,7 +497,9 @@ def __init__(
479497
# start by supersampling
480498
Zetas, Xs, Phis = np.meshgrid(zetas, xs, self._phi_interpolant, indexing="ij")
481499
_cdfs = self._spl_cdf((Zetas.ravel(), Xs.ravel(), Phis.ravel())).reshape(
482-
lR, lT, len(self._phi_interpolant)
500+
lR,
501+
lT,
502+
len(self._phi_interpolant),
483503
)
484504
# build reverse spline
485505
ppfs = np.empty((lR, lT, self._ninterpolant), dtype=np.float64)
@@ -488,7 +508,9 @@ def __init__(
488508
ppfs[i, j, :] = splev(qarr, spl, ext=0)
489509
# interpolate
490510
self._spl_ppf = RegularGridInterpolator(
491-
(zetas, xs, self._q_interpolant), ppfs, bounds_error=False
511+
(zetas, xs, self._q_interpolant),
512+
ppfs,
513+
bounds_error=False,
492514
)
493515

494516
# /def
@@ -505,7 +527,12 @@ def _cdf(
505527

506528
# /def
507529

508-
def cdf(self, phi: npt.ArrayLike, r: npt.ArrayLike, theta: npt.ArrayLike) -> NDArray64:
530+
def cdf(
531+
self,
532+
phi: npt.ArrayLike,
533+
r: npt.ArrayLike,
534+
theta: npt.ArrayLike,
535+
) -> NDArray64:
509536
# TODO! make sure r, theta in right domain
510537
cdf = self._cdf(
511538
phi,

sample_scf/utils.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def zeta_of_r(r: T.Union[u.Quantity, NDArray64]) -> NDArray64:
9696

9797

9898
def r_of_zeta(
99-
zeta: npt.ArrayLike, unit: T.Optional[u.UnitBase] = None
99+
zeta: npt.ArrayLike,
100+
unit: T.Optional[u.UnitBase] = None,
100101
) -> T.Union[u.Quantity, NDArray64]:
101102
r""":math:`r = \frac{1 + \zeta}{1 - \zeta}`
102103
@@ -258,7 +259,9 @@ def _phiRSms(
258259

259260

260261
def phiRSms(
261-
pot: SCFPotential, r: npt.ArrayLike, theta: npt.ArrayLike
262+
pot: SCFPotential,
263+
r: npt.ArrayLike,
264+
theta: npt.ArrayLike,
262265
) -> T.Tuple[NDArray64, NDArray64]:
263266
r"""Radial and inclination sums for azimuthal weighting factors.
264267

0 commit comments

Comments
 (0)