octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hgsave weirdness


From: Dmitri A. Sergatskov
Subject: Re: hgsave weirdness
Date: Mon, 23 Sep 2019 12:45:18 -0500



On Mon, Sep 23, 2019 at 12:31 PM Rik <address@hidden> wrote:
On 09/23/2019 09:00 AM, address@hidden wrote:
Subject:
hgsave weirdness
From:
"Dmitri A. Sergatskov" <address@hidden>
Date:
09/22/2019 09:27 PM
To:
Octave Help <address@hidden>, octave-maintainers <address@hidden>
List-Post:
<mailto:address@hidden>
Precedence:
list
MIME-Version:
1.0
Message-ID:
<address@hidden>
Content-Type:
text/plain; charset="UTF-8"
Message:
2

$ cat t2.m
h1=figure();
plot(randn(10));
fname = "t2.ofig"
hgsave(h1, fname)
h2=hgload(fname)
h1_l = get(h1);
h2_l = get(h2);
assert(h1, h2)


$ ls -l t2.ofig
ls: cannot access 't2.ofig': No such file or directory

octave:1> t2
fname = t2.ofig
error: hgload: unable to locate file t2.ofig
error: called from
    hgload at line 60 column 7
    t2 at line 5 column 3
octave:2> t2
fname = t2.ofig
h2 =  3
error: ASSERT errors for:  assert (h1,h2)

  Location  |  Observed  |  Expected  |  Reason
     ()           2            3         Abs err 1 exceeds tol 0 by 1
octave:3>

Adding pause(10) after hgsave() does not seem to change anything, so
it is not a timing issue.

What is going on here?

I'm not seeing the first problem with hgload.  Here is my session

~/wip/Projects_Mine/octave-dev: run-octave --no-gui-libs -f -q
octave:1> t2
fname = t2.ofig
h2 =  2
error: ASSERT errors for:  assert (h1,h2)

  Location  |  Observed  |  Expected  |  Reason
     ()           1            2         Abs err 1 exceeds tol 0 by 1

I started Octave with -f to make sure there was no user configuration issues that might be a problem.

The reason why h1 != h2 is that the original figure was not closed after hgsave.  When you do hgload, it would like to use the next available figure handle which can't be '1' in this case so Octave uses '2'.  If I add "close (h1)" after hgsave then the script runs with no errors.


assert() here is irrelevant (it is leftover from other tests, and it should have been assert (h1_l, h2_l).
I am puzzled why hgload does not see the file. I wonder if hgsave forgets to fclose it or something like that.

Dmitri.
--


reply via email to

[Prev in Thread] Current Thread [Next in Thread]