Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/blackPublic

Math expressions and readability #148

Closed
Labels
@paugier

Description

@paugier

It is not a bug, just a feedback. I start to use black for a project with math formula and I think black sometimes makes the code less readable.

Two simple examples:

Equations not fitting on one line

if True:    if True:        PK1_fft = np.real(            + vx_fft.conj() * fx_fft            + vy_fft.conj() * fy_fft            + vz_fft.conj() * fz_fft        )

is transformed byblack -l 82 into

if True:    if True:        PK1_fft = np.real(            +vx_fft.conj()            * fx_fft            + vy_fft.conj()            * fy_fft            + vz_fft.conj()            * fz_fft        )

The result is clearly less readable. It would be nice that black keeps the code as it is in such cases.

Spaces around pow operator

result = 2 * x**2 + 3 * x**(2/3)

is transformed byblack into

result = 2 * x ** 2 + 3 * x ** (2 / 3)

which is less readable.

It seems to me it would make sense to allow "no space around**" because of the high precedence of the exponentiation (https://docs.python.org/3/reference/expressions.html#operator-precedence).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp