Skip to content

np.load fails on a single element ndarray numpy file #524

Closed as duplicate

Description

@doticworks

save in python. and elenpy1 has single element.

elenpy1=np.array(13000,np.float32)
np.save('temp_elenpy1.npy',elenpy1)
elenpy2=np.array([13000,13],np.float32)
np.save('temp_elenpy2.npy',elenpy2)

load in c#

np.load(@"temp_elenpy1.npy")//failed System.ArgumentOutOfRangeException
np.load(@"temp_elenpy2.npy")

length ('-52') must be a non-negative value. (Parameter 'length')
Actual value was -52.

at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName)
at System.ArgumentOutOfRangeException.ThrowIfNegative[T](T value, String paramName)
at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
at System.String.Substring(Int32 startIndex, Int32 length)
// /src/NumSharp.Core/APIs/np.load.cs line361
at NumSharp.np.parseReader(BinaryReader reader, Int32& bytes, Type& t, Int32[]& shape)
at NumSharp.np.load(Stream stream)
at NumSharp.np.load(String path)

apologize in advance for my poor english.

Activity

  1. doticworks commented on Nov 18, 2025

    @doticworks
    Author

    here is a temporary fix issue#517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions