https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/merge_requests/7724__;!!G_uCfscf7eWS!c2pUfXzQgwy7S-LHON8g6ZH69NclYWSFtbeLLrMTZC_ubB8ziO9UykEAHS_ZMauViQm7pXW9lC06zLXAFT_v52Q$
> On Jul 27, 2024, at 12:49 PM, Nick OBrien via petsc-users > <petsc-users@mcs.anl.gov> wrote: > > This Message Is From an External Sender > This message came from outside your organization. > PetscBinaryIO errors when reading a Vec with zero elements. The > following python script demonstrates the issue: > > --8<---------------cut here---------------start------------->8--- > import PetscBinaryIO > import numpy as np > > io = PetscBinaryIO.PetscBinaryIO() > v = np.array([], np.float32).view(PetscBinaryIO.Vec) > io.writeBinaryFile("test.bin", (v,)) > io.readBinaryFile("test.bin") > --8<---------------cut here---------------end--------------->8--- > > --8<---------------cut here---------------start------------->8--- > [...] > File "/[...]/lib/petsc/bin/PetscBinaryIO.py", line 258, in readVec > raise IOError('Inconsistent or invalid Vec data in file') > OSError: Inconsistent or invalid Vec data in file > --8<---------------cut here---------------end--------------->8--- > > Tested on 3.20.5. readVec errors if `len(vals) == 0`, but maybe the > check should be `len(vals) != nz`? > > -- > Nick OBrien > >