Skip to content

Suggestion: refactor __repr__ methods to output shape tuples instead of MATLAB-like size strings #183

@dmdunla

Description

@dmdunla

Suggestion: Change class instance output (via __repr__) to output shapes as tuples

Background: When making changes for #145 , I added a test of __repr__ for empty ktensor instances and saw an inconsistency of how the shape attribute is output in this case.

In MATLAB, here is the output string (for a ktensor for example):

B is a ktensor of size 3 x 4 x 5

Here is the proposed corresponding output string in pyttb:

ktensor of shape (3, 4, 5)

Several motivators for this suggestion:

  1. Output reflects that the shape attribute is a tuple.
  2. Consistency with numpy-like shape attributes:
    • Empty: ktensor of shape () (rather that ktensor of shape 0, which may confuse users)
    • 1-way: ktensor of shape (2,) (rather than ktensor of shape 2, which may confuse users)
    • d-way: ktensor of shape (3, 4, 5)

I made the changes in a current PR (#182), but would like input before merging the changes.

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions