Skip to content

[BUG] loadtxt is sensitive to blank lines #709

Closed
@Bzero

Description

@Bzero

Describe the bug
loadtxt infers a wrong shape and omits values if the datafile contains blank lines.

ulab version: 6.7.2-2D

To Reproduce
Create a data file with either of the following content (note the white space):

0 1

2 3

or

0 1
2 3


And try to load either of the files with loadtxt:

from ulab import numpy
print(numpy.loadtxt('data.dat'))

Both result in an array with too few columns and an omitted value:

array([[0.0],
       [1.0],
       [2.0]], dtype=float32)

Expected behavior

Blank lines should not make a difference.

Additional context

If the file contains more blank lines 0.0 is inserted, e.g. the file

0 1
2 3






results in the array

array([[0.0],
       [1.0],
       [2.0],
       [3.0],
       [0.0],
       [0.0],
       [0.0]], dtype=float32)

This issue may be related to #706.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions