Skip to content

[DISCUSSION] Create centralized axis mapping #1053

Description

@genedan

Description

The recurring pattern {0: 'index', 1: 'columns', 2: 'origin', 3: 'development'}` is used to look up and map axes values, and validate arguments.

It's not applied consistently though, there's a spot in pandas.py where we have the keys and values reversed in order to extract the integer value:

{"index": 0, "columns": 1, "origin": 2, "development": 3}

Anyhow, keeping the axes in a central location such as __init__.py will improve maintainability and make it clear which axes are supported, as well as solidify the text to integer mapping.

Is your feature request aligned with the scope of the package?

  • Yes, absolutely!
  • No, but it's still worth discussing.
  • N/A (this request is not a codebase enhancement).

Describe the solution you'd like, or your current workaround.

I propose a tuple: __axes__ = ('index', 'columns', 'origin', 'development'). This is immutable and can be used to lookup values in both directions:

print(__axes__[2])

'origin'

print(__axes__.index('origin'))

'2'

Do you have any additional supporting notes?

Labeling this as a discussion, to see if there's a better way to do this. I don't really like how a tuple has a method called index which can be confused with the Triangle's index.

Will drop the discussion label and set status to ready to be picked up once this is decided.

Would you be willing to contribute this ticket?

  • Yes, absolutely!
  • Yes, but I would like some help.
  • No.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Great First Contribution! 🌱Beginner friendly tickets with narrow scope and huge impact. Perfect to get your feet wet!

    Fields

    Priority

    Low

    Effort

    Low

    Scope

    Codebase

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions