Closed VikingScientist closed 7 years ago
i've had much fun with this one ;) the problem is wrong open mode in the G2 class from here https://github.com/sintefmath/Splipy/blob/master/splipy/IO/g2.py#L18
I guess this makes sense. The reason for writing it the way it currently is, is to allow for read/write operations to take on a similar structure
with G2('test.g2') as f:
my_spline_objects = f.read()
should return the objects in the file. This causes some problem on creation of the file-object, since you don't know a priori if you are going to read and/or write to it (actually the read AND write was discontinued in bf60f1a7c2e7f37b09806326b3625bf969a0e960).
Writing to a file that already exist will cause it to starting from the top to swap out previous lines with the new ones. At the end of writing, any trailing lines present in the previous file, but so far down that they were not overwritten, will be kept unchanged. This renders the result file unusable