How to avoid the error thrown by the maxima function polynomialp? - constants

Look at the following two sequences of two commands. They are the same up to the choice of variable a or z, but the version with a produces an error whereas the function with z does not.
First run (after a restart of maxima):
declare(a,constant); polynomialp(x^2+x+1/a,[x]);
Now replace a by z and there is no error when run (after a restart of maxima):
declare(z,constant); polynomialp(x^2+x+1/z,[x]);
The error reported in the case with variable a is:
define: in definition of dotproduct, found bad argument a
-- an error. To debug this try: debugmode(true);
Strangely enough, after running the second command of the first sequence again, the error does not recur.
Above code was run on Maxima versions 5.30 and 5.39.

Related

Matlab test runner skips test functions that try to import non-existing file

Let's define a simple test class
classdef test_file < matlab.unittest.TestCase
methods(Test)
function test_function(testCase)
import some_package.some_function
testCase.verifyEqual(true,some_function(0));
end
end
end
It is irrelevant what some_function does. Function some_package.some_function does not exist in my path (for example I forgot to add it when pushing a commit). Whenever I try to run the test file above the test test_function is skipped with warning:
Warning: "test_file.m" was excluded.
Caused by:
Error: File: test_file.m Line: 4 Column: 20
The import statement 'import sc_force_models.apparent_accel' cannot be found or cannot be imported. Imported names must
end with '.*' or be fully qualified.
Since the test is skipped the problem is undetected and test runner returns 0 errors. In case someone forgets to commit a file I'd still like to detect this problem during testing, so expected behavior is to fail the test case.
As a workaround I've tried using the 'Strict',True argument to testrunner but it neither detects the issue. I've also tried putting the import statement between try, catch statements but it seems any code in the file is not executed.
Any ideas how to detect incorrect import statements in test cases?

Error on matlab get_param

I'm generating tlc files from a model. In a specific point I'm getting this error when calling get_param:
>> get_param('FGCS_Sim', 'TargetFcnLibHandle')
??? Error using ==> getTfl at 30 TFL: "None" cannot be found in the
registry.
Error in ==>
C:\MATLAB\R2008b\toolbox\rtw\rtw\#RTW\#TargetRegistry\getTflTableList.p>getTflTableList
at 18
??? Target Function Library 'None' is missing or does not contain a valid TFL Table.
This error is occurring in .p file, so I can't see what's happening. But when I try with a different parameter name (one that does not exist), I get a "normal" error:
>> get_param('FGCS_Sim', 'foo_boo_bar')
??? block_diagram does not have a parameter named 'foo_boo_bar'.
What could be happening?
propose to first check property
'TargetFcnLib'
If that equals 'None' - you will run into the reported error...

Scala Process Builder

I'm trying to execute a command on Scala, but i'm getting an error
s"git --git-dir ${repository.localLocation.get.path}/.git log --format='%h %at %s' --no-decorate" !!
I'm getting an error exit status:
java.lang.RuntimeException: Nonzero exit value: 128
at scala.sys.package$.error(package.scala:27)
at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:134)
But when i'm running this via terminal it works perfectly:
git --git-dir='/var/folders/mk/dc2mnd7x3db1hnqm0vfg6b800000gn/T/XXHMjm7178261334218603127.tmp/.git' log --format='%h %at %s'
If i leave only one % part, it works properly.
Can anyone help me ?
You should probably use the Seq[String] variant, because you have space characters in your args that might be used to wrongly separate the arguments. Try
Seq("git", "--git-dir", s"${repository.localLocation.get.path}/.git",
"log", "--format='%h %at %s'", "--no-decorate").!!
Also note that you will see the single ticks ' in the output. You probably want "--format=%h %at %s".

opp_runall -q runnumbers returned nonzero exit status omnet++

I try to run the simulation from command line with the following command,
$ opp_runall -j2 ./inetmanet-3.x-mactest2 -u Cmdenv -c General -r 1 -n ../..:../../../src:../../../tutorials --image-path=../../../images -l ../../../src/INET omnetpp.ini
I get a weird error, which does not make sense to me, any one can help as follows.
what(): ASSERT: Condition '(int)signalListenerCount.size() == lastSignalID+1' does not hold in function registerSignal, ccomponent.cc line 414 opp_runall: ./inetmanet-3.x-mactest2 [...] -q runnumbers returned nonzero exit status
I using omnetpp RC2 latest release, 1992-2017.
any help?
I stumbled upon the same problem. It is actually a bug/feature in newer versions of OMNeT++, where the signal handling was improved. I just discussed this problem with Attila Török on the mailing list.
This occurs if a signal is registered in an external library during static initialization. Three possible solutions:
Citing Attila:
Insert EXECUTE_ON_STARTUP(cComponent::clearSignalState()); into ccomponent.cc, right after the definition of cComponent::signalListenerCount, then rebuilding OMNeT++.
Move your signal registration out of the static initialization phase. This might or might not be possible in your scenario, but avoids modifications of OMNeT++ itself.
Downgrade OMNeT++ and wait until this is fixed upstream. At least 5.0 works.

Matlab Distributed Server parfor can't find mex opencv files

everyone!
I'm trying to parallelize an algorithm that uses mex files from mexopencv (KNearest.m, KNearest_.mexw32).
The program is based vlfeat (vlsift.mex32) + mexopencv (KNearest.m and KNearest_.mexw32).I classify descriptors obtained from images.
All the code is located on the fileshare
\\ LAB-07 \ untitled \ DISTRIB \ (this is the program code)
\\ LAB-07 \ untitled \ + cv (mexopencv)
When I run the program with matlabpool close everything works well.
Then I make matlabpool open (2 computers on 2 cores each. ultimately 4 worker, but now I use for testing only 2 workers on the computer and run the program which)
PathDependencises from fileshare -> \LAB-07\untitled\DISTRIB\ , \LAB-07\untitled+cv
Before parfor loop I train classifier on the local machine
classifiers = cv.KNearest
classifiers.train(Descriptors',Labels','MaxK',1)
Then run parfor
descr=vlsift(img);
PredictClasses = classifiers.predict(descr');
Error
Error in ==> KNearest>KNearest.find_nearest at 173
Invalid MEX-file '\\LAB-07\untitled\+cv\private\KNearest_.mexw32':
The specified module could not be found.
That is KNearest.m finds, but no KNearest_.mexw32. Because KNearest_.mexw32 located in private folder, I changed the code KNearest.m (everywhere where it appeal KNearest_ () changed to cv.KNearest_ (). Example: this.id = сv.KNearest_ ()) and placed in a folder with KNearest_.mexw32 KNearest.m. As a result, get the same error
Immediately after matlabpool open file search on workers
pctRunOnAll which ('KNearest.m')
'KNearest.m' not found.
'KNearest.m' not found.
'KNearest.m' not found.
pctRunOnAll which ('KNearest_.mexw32')
'KNearest_.mexw32' not found.
'KNearest_.mexw32' not found.
'KNearest_.mexw32' not found.
after cd \LAB-07\untitled+cv
pctRunOnAll which ('KNearest.m')
\\LAB-07\untitled\+cv\KNearest.m
\\LAB-07\untitled\+cv\KNearest.m % cv.KNearest constructor
\\LAB-07\untitled\+cv\KNearest.m
>> pctRunOnAll which ('KNearest_.mexw32')
\\LAB-07\untitled\+cv\KNearest_.mexw32
\\LAB-07\untitled\+cv\KNearest_.mexw32
\\LAB-07\untitled\+cv\KNearest_.mexw32
I ran and FileDependecies, but the same result.
I do not know this is related or not, I display during the execution of the program classifiers
after training and before parfor
classifiers =
cv.KNearest handle
Package: cv
Properties:
id: 5
MaxK: 1
VarCount: 128
SampleCount: 9162
IsRegression: 0
Methods, Events, Superclasses
Within parfor before classifiers.predict
classifiers =
cv.KNearest handle
Package: cv
Properties:
id: 5
I tested the file cvtColor.mexw32. I left in a folder only 2 files cvtColor.mexw32 and vl_sift
parfor i=1:2
im1=imread('Copy_of_start40.png');
im_vl = im2single(rgb2gray(im1));
desc=vl_sift(im_vl);
im1 = cvtColor(im1,'RGB2GRAY');
end
The same error, and vl_sift work, cvtColor no...
If the worker machines can see the code in your shared filesystem, you should not need FileDependencies or PathDependencies at all. It looks like you're using Windows. It seems to me that the most likely problem is file permissions. MDCS workers running under a jobmanager on Windows by default run not using your own account (they run using the "LocalSystem" account I think), and so may well simply not have access to files on a shared filesystem. You could try making sure your code is world-readable.
Otherwise, you can add the files to the pool by using something like
matlabpool('addfiledependencies', {'\\LAB-07\untitled\+cv'})
Note that MATLAB interprets directories with a + in as defining "packages", not sure if this is intentional in your case.
EDIT
Ah, re-reading your original post, and your comments below - I suspect the problem is that the workers cannot see the libraries on which your MEX file depends. (That's what the "Invalid MEX-file" message is indicating). You could use http://www.dependencywalker.com/ to work out what are the dependencies of your MEX file, and make sure they're available on the workers (I think they need to be on %PATH%, or in the current directory).
Edric thanks. There was a problem in the PATH for parfor. With http://www.dependencywalker.com/ looked missing files and put them in a folder +cv. Only this method works in parfor.
But predict in parfor gives an error
PredictClasses = classifiers.predict(descr');
??? Error using ==> parallel_function at 598
Error in ==> KNearest>KNearest.find_nearest at 173
Unexpected Standard exception from MEX file.
What() is:..\..\..\src\opencv\modules\ml\src\knearest.cpp:365: error: (-2) The search
tree must be constructed first using train method
I solved this problem by calling each time within parfor train
classifiers = cv.KNearest
classifiers.train(Descriptors',Labels','MaxK',1)
But it's an ugly solution :)