New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test @sym/function_handle failed #431
Comments
@genuinelucifer any idea what's going on here? of those three tests, one or two of them seem to fail. @finalsnd would you be willing to step through those tests manually, look at the |
It seems like a file reading problem.
|
Weird. Should we be checking the return value of |
Weird. Should we be checking the
return value of fclose?
Probably... But, seeing the return value, still would require to do a check
on the file. Or, is there an overload which flushes writing the file if
there's a return value?
|
Maybe Octave doesn't refresh the files in the path until a few seconds. There's a function, ignore_function_time_stamp() but i'm changing it and doesn't work anyway.
|
What is the fclose return value? Should have 'assert ( ret == 0)' or similar Does it help if we write the file then add the path? |
It is zero only.
Indeed! It works... |
@cbm755 If we add the path in |
There's no need for that. The user already knows the path of the file, doesnt? Maybe it's good idea to remove the path after finish the function, or leave it alone if the path existed before invoking the function. |
Fair enough
I'll have to try that. But, if we remove the path then the function handle |
I think that if the user didn't set the path before invoking the function, then it will be an error (octave can't find, for example, temp_file). So, not need to remove the path anyway. Or am i missing something? Is there any way to invoke a function that isn't in the path? (something like 'run' but for functions) |
IMHO the test as written is correct, and works on GNU/Linux and probably any POSIX, it may be something we don't quite understand about the Windows filesystem or I/O layer that is not behaving the way Octave expects. @finalsnd Not now, but in a future version of Octave the |
@genuinelucifer Umm, no that's not fine. I just meant:
|
No actually, that wouldn't work. We call `str2func` in function_handle and
hence the path should be modified before that call....
I guess we will have to look into how octave loads the files and probably
add a new method to reload the cache manually.
|
I see. What about writing the test to |
Then the call to
|
The directory or the path doesn't seem to be the issue, I think the core of this issue is that the something ilke following may fail on Windows (but one of you please verify for me).
This is expected to work in Octave, at the command line, in one long command, as a script, in any context. If it doesn't, I think we should address this underlying bug instead of (or before) trying to invent workarounds. |
It actually works!!!
then it has the same problem. I have to use a delay before str2func can be Seems like octave loads the current directory asap but it doesn't load the |
The problem is that Octave in Windows doesn't refresh instantly the new functions in the files of the path. If you wait a while, you can run the new function and works fine. @genuinelucifer tried to put the addpath after creating the file and it worked. Maybe because when you add a path, octave refreshes all the functions. That's why i said maybe changing ignore_function_time_stamp() would fix it, but i tried and didn't fix anything. @mtmiller the function 'run' doesn't accept input parameters... so we can't use it for this. That code didn't fail for me!!! |
I tried a few more times and can now confirm that addpath then fopen fails.
But fclose then addpath works! (for files in different directory than
current)
Seems like addpatb refreshes the cache. We might just need to define a new
function that would refresh the cache for us. Or maybe when functions like
str2func query for functions and variables in path, a refresh should occur
automatically?!
|
That's what rehash supposed to do... and the ignore_function_time_stamp... doesn't? I opened a bug report in Octave (I forgot to fill the title... :( ): |
The function Octave still fundamentally depends on the timestamp of the directory containing an m-file to be updated when a new file is created or else it will never look in the contents of the directory for any functions that it hasn't already seen. |
Anyway, we should continue this at the appropriate bug report. |
@mtmiller Could you please point me to some file where I could find the implementation of |
@genuinelucifer Sure, let's discuss in the appropriate venue, either bug #31080 or the maintainers list, your choice. |
I sent the mail on maintainers list. That would be more suitable for me....
|
Well, I have been looking at the octave source. The only solution that comes to my mind is have a |
And even if we do that, it will probably take a long time before it actually gets officially into octave release (i guess so as is the case with most of the large open source softwares)... |
I haven't been following this enough to know if that is the correct solution upstream or not. But probably should discuss at the upstream bug report. Re: tests: I'm not too worried about the failing tests on Windows. I guess in real-life, people will use function_handle interactively where its less of a problem... We could just mark them |
Certainly seems like the most favourable option at this point. I have posted on the bug report and will see what the response of other people is. |
I agree that even if this important issue is fixed upstream, it will be worth commenting or addressing in some way in octsympy, because the fix likely won't help a lot of users for a while. The 3 |
Alright, I'd be ok with #432 wrapped with |
@mtmiller Sorry, at this point I do not wish to dive into windows file systems and researching into the filestamps (as you suggested on the bug report). Maybe sometime down the line or after GSoC, I could try this. |
could you please explain
|if(exist('OCTAVE_VERSION')...)| ? why to check existence of octave_version?
Because Octsympy supports Matlab too. This is the same reason we don't
use Octave-only extensions like `endfunction` and double-quoted strings.
|
The text was updated successfully, but these errors were encountered: