-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Request: minimal support for reasonable formatting of mathematical expressions
Readability of mathematical expressions is critical for numerical code, and this is vitally dependent on reasonable code formatting. Black appears to have no sense of this issue, and produces code formatting that makes mathematical expressions not just obscure, but unreadable. I (developer of scqubits) love the idea of uniform code formatting. I also love the idea of enforcing uniformity by not providing options for formatting variations. The latter, however, can only work if the choices black makes fulfill minimal requirements of readability. If there is any interest within the black development team to address this issue, I would be happy to contribute and advise on reasonable formatting of mathematical expressions.
Evidence of the above
def spectral_density(omega):
therm_ratio = calc_therm_ratio(omega, T)
s = (
2
* self.EL
/ q_ind_fun(omega)
* (1 / np.tanh(0.5 * np.abs(therm_ratio)))
/ (1 + np.exp(-therm_ratio))
)Reasonable style
def spectral_density(omega):
therm_ratio = calc_therm_ratio(omega, T)
s = (
2 * self. EC / q_cap_fun(omega)
* (1 / np.tanh(0.5 * np.abs(therm_ratio))) / (1 + np.exp(-therm_ratio))
)The latter fits into the default 88 character line width just fine.