Skip to content
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

Maxima outputs warnings which prevent saving a STACK question #349

Closed
alcarola opened this issue Feb 14, 2018 · 9 comments
Closed

Maxima outputs warnings which prevent saving a STACK question #349

alcarola opened this issue Feb 14, 2018 · 9 comments

Comments

@alcarola
Copy link
Contributor

Hi,

In a question, I need to compute a certain p value using the command
pValue : 1-cdf_f(Ftest, nu1, nu2);
Then my Maxima 5.41.0 with SBCL 1.4.4 spits out the warnings
WARNING: redefining MAXIMA::SIMP-UNIT-STEP in DEFUN
WARNING: redefining MAXIMA::SIMP-POCHHAMMER in DEFUN
but it nevertheless computes the asked-for p value. Now STACK interprets these warnings as a reason not to let me save the question -- instead it prints out an error message above my question variables textbox.

I ask: Can STACK be changed so that Maxima warnings are ignored, but Maxima errors are not? Or is there a simple way for me to suppress Maxima warnings for an individual quesition?

Thanks!
Mikael

@sangwinc
Copy link
Member

I'll look into t his.

We already have code in place to ignore some warnings, but I don't like doing this as a blanket approach, since I think that is very poor practice as frustrating as it is.

I agree that not letting users save questions with errors can be annoying, and I've been annoyed by this myself in the past.

I've already started working on a mechanism to separate out the "validation" of questions form the Moodle form element, and as part of this implemented a separate "warning" mechanism. This might be a good reason to use the warnings, and to bring all this forward.

@sangwinc
Copy link
Member

Tim,
I've been working on issue #339, and this problem is related. Ideally, we'd like to use the new "warnings" system for this. However, at present the warnings just end up in a code black hole here:
https://github.com/maths/moodle-qtype_stack/blob/iss339/edit_stack_form.php#L737
I've got no idea how to display these through Moodle! Any idea here of how to display warnings which don't prevent the question being saved?

@sangwinc
Copy link
Member

Give the reply below, should we squash all such "WARNING" messages?

I can't actually generate one in anger, but I'll try the "compile" trick on SBCL to see if this works....

Chris


From: Robert Dodier [robert.dodier@gmail.com]
Sent: 19 February 2018 01:23
To: SANGWIN Chris
Cc: maxima-discuss@lists.sourceforge.net
Subject: Re: [Maxima-discuss] Trying to write some unit tests: how to I reliably generate a WARNING:: XXX in DEFUN?

On Sun, Feb 18, 2018 at 4:13 AM, SANGWIN Chris C.J.Sangwin@ed.ac.uk wrote:

I'm trying to write some unit tests to catch warnings etc.

Is there a way I can reliably generate something like
WARNING: redefining MAXIMA::SIMP-UNIT-STEP in DEFUN
in all versions of Maxima/LISP?

If there is a simple command which triggers such a warning I can include a unit test, but I'm struggling to recreate the problem! Any suggestions?

Well, you can generate such warnings by defining a Lisp function and
then defining it again. Some Lisp implementations generate a warning
when that happens, and some don't. It's possible that the behavior
depends on some implementation-dependent severity flag.

I'm toying with trying to trigger the warning and it appears Clisp
only complains if the function was defined in a compiled Lisp file. So
here's a way to trigger the warning in Maxima compiled with Clisp:

compile_file ("/tmp/foo.mac");
load (last (%)); /* loads the .fas */
:lisp (defun $foo (x) x)

where /tmp/foo.mac contains foo(x) := anything.

But the presence of these warnings in the test suite is a bug, really
... I've been meaning, for years, to figure out where they are coming
from and squash them. Maybe now is the time to do it for real.

best,

Robert Dodier

@sangwinc
Copy link
Member

Mikael,

If you have access to the server files, you could put in a dummy command, e.g.

pValue : 1-cdf_f(Ftest, nu1, nu2);

for specific values around here:
https://github.com/maths/moodle-qtype_stack/blob/master/stack/maxima/stackmaxima.mac#L2778

This should throw the warnings at image compile time, and so not when you are trying to use a question. This will, I think, be a work-around until we can figure out a permanent fix.

@aharjula
Copy link
Member

Chris,

As a more complete/complex solution we could build an Maxima image generator that would call through all the functions we ever support before saving the image thus ensuring that everything the functions do to the state of the Maxima process, i.e. loading of optional deeper libraries and defining of additional functions, gets done and warnings given, before we actually start to give it stuff to process.

This would have the benefit of eating up the setup time of those functions that do additional loads and definitions only at the time of first call.

We would "just" need to have a list of functions and test inputs triggering all possible branches... Maxima probably has those in unit tests somewhere... (might tie in nicely with that keyval.-editor I have worked on, as it too has a need for function signatures)

Taking that further the image generator could check which functions are present and if they work as expected and even patch (redefine) bad versions so that our Maxima support could cover some less than optimal releases. However, we would then just be building an unit testing system for Maxima on STACKs side with our assumptions on what Maxima should do.

Naturally, such an image generator would take much longer to generate images but once generated they would probably have much better worst case performance and give no warnings about re-definitions from inside system functions. Might however increase the image size a bit and best case performance in non Pool situations might suffer.

@alcarola
Copy link
Contributor Author

Thanks for the workaround, Chris! I started looking into disabling all warnings in the pre-optimized Maxima image rather than doing it for only one command at a time, but found that it seems to depend on which flavour of LISP is being used. Matti's approach is much better.

Here is what I found for CLISP:
http://def.fe.up.pt/pipermail/maxima-discuss/2009/031467.html (the discussion continues; click the link at the bottom)
and this is what I found for SBCL:
https://stackoverflow.com/questions/2535478/how-do-i-disable-warnings-in-lisp-sbcl

I ended up not using the affected question in this year's incarnation of the course, so I didn't try any of the suggestions in the threads myself. I just include them here in case they help someone while a better solution is being worked out.

@sangwinc
Copy link
Member

Thanks, that is really helpful.
Do we really want to suppress all warnings though. If I'd had a warning, we wouldn't be in this mess!!
#333

@aharjula
Copy link
Member

Well, I guess the problem is with those functions that do definitions within themselves and thus redefine things like those stats functions tend to do on first calls. And we would need to know that those functions have this "behaviour" and ignore just those warnings. Problem is that such context awareness is difficult. Ideally, we should have white-lists of warnings but as we cannot know all the warnings that could exist in the future that would matter we would need to go for black-lists and as that leads to the context awareness issue we may need to go for something else. And that something else is to trigger the warnings before we care about warnings like in your workaround.

As to addrow. That image generator (Maxima tester/patcher) could even be built so that it would check that STACK does not itself redefine any functions we do not want to redefine.

In any case such an image generator would be an handy tool for MaximaPool admins and might act as and testing tool for others and I think I'll look at it at some point as I have other interests in that direction.

jgoldfar pushed a commit to jgoldfar/maxima-clone that referenced this issue Mar 9, 2018
Partial resolution of bug reported to mailing list 2018-02-18: "Trying to write some unit tests: how to I reliably generate a WARNING:: XXX in DEFUN?"
See also: maths/moodle-qtype_stack#349
(2) Remove redundant, identical definition of FLOAT-OR-RATIONAL-P.
rtoy pushed a commit to rtoy/maxima that referenced this issue Aug 5, 2018
Partial resolution of bug reported to mailing list 2018-02-18: "Trying to write some unit tests: how to I reliably generate a WARNING:: XXX in DEFUN?"
See also: maths/moodle-qtype_stack#349
(2) Remove redundant, identical definition of FLOAT-OR-RATIONAL-P.
@sangwinc
Copy link
Member

I've just tested this on the latest dev code, and we no longer have this problem in STACK 4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants