Skip to content

Numpy-style indexing gets "mushed" (i.e. loses a space) #33

Description

@dhermes

For the repro file its_science.py

def first_column1d(values):
    """First column, as a 1D array."""
    return values[:, 0]


def first_column2d(values):
    """First column, but still a 2D array."""
    return values[:, 0:1]

Running black (installed from HEAD as in #30)

$ venv-HEAD/bin/black its_science.py
reformatted its_science.py

changes the "exotic" slice argument:

diff --git a/its_science.py b/its_science.py
index f3c4a8b..3a5dba0 100644
--- a/its_science.py
+++ b/its_science.py
@@ -5,4 +5,4 @@ def first_column1d(values):
 
 def first_column2d(values):
     """First column, but still a 2D array."""
-    return values[:, 0:1]
+    return values[:,0:1]

PS @ambv This is my fourth and last issue (for now) and it's just "wrong" things I encountered when running this on a large codebase of mine. I am SOOOOO happy you have created black and look forward to evangelizing it in the community.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions