Skip to content

Bug: Database.__str__ prints the number of columns instead of rows for snapshot count #295

@kshitij-maths

Description

@kshitij-maths

Describe the bug
When printing a Database object, the __str__ method incorrectly reports the number of degrees of freedom (columns) as the number of snapshots. This occurs because the string formatting calls self.snapshots_matrix.shape[1] instead of shape[0] or len(self).

To Reproduce

import numpy as np
from ezyrb import Database

# Create a database with 3 snapshots and 100 degrees of freedom
params = np.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
snapshots = np.random.rand(3, 100)
db = Database(params, snapshots)

print(db)

Expected behavior

len(db): 3
db.parameters_matrix.shape: (3, 2)
db.snapshots_matrix.shape: (3, 100)
Output of print(db):
Database with 3 snapshots and 2 parameters

Output

len(db): 3
db.parameters_matrix.shape: (3, 2)
db.snapshots_matrix.shape: (3, 100)
Output of print(db):
Database with 100 snapshots and 2 parameters

Fix
In ezyrb/database.py, update line 134 in the __str__ method:

Change

self.snapshots_matrix.shape[1]

to

self.snapshots_matrix.shape[0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions