[Invalid argument: assertion failed: [width must be >= target + offset.]] - computer-vision

I encountered this error when testing the model(Image text detection and recognition)
''[Invalid argument: assertion failed: [width must be >= target + offset.]]''
Does anyone know why?

Related

OS.FileSys.mkDir that does not raise exception when the directory already exists

I am trying to write a function that creates a directory but does not raise an error when the directory already exists. This is the function:
fun ensureDir s =
(OS.FileSys.mkDir s)
handle OS.SysErr (_, SOME Posix.Error.exist) => ()
I based the pattern OS.SysErr (_, SOME Posix.Error.exist) on the fact that OS.FileSys.mkDir fails with the following error message when the directory already exists:
Poly/ML:
Exception- SysErr ("File exists", SOME EEXIST) raised
SML/NJ:
uncaught exception SysErr [SysErr: File exists [exist]]
raised at: <mkdir.c>
However, I get this error when I try to define the function in the Poly/ML shell:
poly: : error: qualified name Posix.Error.exist illegal here
Static Errors
This is the error in SML/NJ:
Error: variable found where constructor is required: Posix.Error.exist
What mistake did I make in the function definition?
(Poly/ML 5.7.1; SML/NJ 110.79; Ubuntu 20.04)
Posix.Error.exist is a val and not a constructor (like SOME) so
you cannot use it as a pattern in a pattern matching construct. Here
is an equivalent code for what you intended to do.
fun ensureDir s =
(OS.FileSys.mkDir s)
handle e as (OS.SysErr (_, SOME err)) =>
if err = Posix.Error.exist
then ()
else raise e
;

Boost data-driven test output: "Assertion occurred in a following context"

I have a question regarding the output of the following minimal example that uses Boost test.
#define BOOST_TEST_MODULE ExampleTestSuite
#include <boost/test/included/unit_test.hpp>
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
using boost::unit_test::framework::master_test_suite;
#include <boost/test/data/test_case.hpp>
namespace bdata = boost::unit_test::data;
BOOST_DATA_TEST_CASE(ExampleTest, bdata::xrange(2), testDatum) {
int exp = testDatum == 0 ? 0 : 1;
BOOST_CHECK_EQUAL(testDatum, exp);
}
If I run this test with ./boost_testing --log_level=all, I get the following output:
Running 2 test cases...
Entering test module "ExampleTestSuite"
boost_testing.cpp(11): Entering test suite "ExampleTest"
boost_testing.cpp(11): Entering test case "_0"
boost_testing.cpp(15): info: check testDatum == exp has passed
Assertion occurred in a following context:
testDatum = 0;
boost_testing.cpp(11): Leaving test case "_0"
boost_testing.cpp(11): Entering test case "_1"
boost_testing.cpp(15): info: check testDatum == exp has passed
Assertion occurred in a following context:
testDatum = 1;
boost_testing.cpp(11): Leaving test case "_1"
boost_testing.cpp(11): Leaving test suite "ExampleTest"
Leaving test module "ExampleTestSuite"
*** No errors detected
What is the meaning of the output line Assertion occurred in a following context: testDatum = 0;? Does it indicate an issue with the way that I have set up the data-driven test case or can I safely ignore it?
I agree the message is confusing: this is in fact the description of the assertion context for the test BOOST_CHECK_EQUAL(testDatum, exp), and in fact this is not describing an error, but the context attached to the check. If you change --log_level=all to something else, or user another output format, this should go away.
Feel free to raise an issue on Boost.Test project

Why does ERT say my test is aborted?

I'm trying out writing some elisp for the first time. I'd like to be able to run unit tests on it.
I have a buffer with the following in it:
(ert-deftest addition-test ()
(should (= (+ 1 2) 4)))
And I ran M-x eval-buffer to install the ert-deftest definition into my emacs. When I run M-x ert RET t RET, I see:
Selector: t
Passed: 0
Failed: 0
Total: 0/1
Started at: 2015-11-16 00:27:46-0800
Aborted.
Aborted at: 2015-11-16 00:27:46-0800
A
A addition-test
aborted
And I see the message "Test failed: ...." in the minibuffer at the bottom of the screen. Why is the failure reported there rather in the ERT buffer?
EDIT:
It appears that the "aborted" message occurs after a failing test is hit, then any remaining tests aren't run. Example:
(ert-deftest test1 ()
(should 1))
(ert-deftest test2 ()
(should nil))
(ert-deftest test3 ()
(should 1))
M-x eval-buffer RET M-x ert RET opens up a buffer named *ert* that says:
Selector: t
Passed: 1
Failed: 0
Total: 1/3
Started at: 2015-11-16 02:06:57-0800
Aborted.
Aborted at: 2015-11-16 02:06:57-0800
.A-
A test2
aborted
And in *Messages* I see:
Aborted: Ran 3 tests, 1 results were as expected
ert-fail: Test failed: ((should nil) :form nil :value nil)
If I go in the *ert* and press d over test2, I get the following in *Messages*:
Running test test2...ABORTED
ert-fail: Test failed: ((should nil) :form nil :value nil)
I can convince it to run test3 if I hit enter on the - in .A-, expand test3, then hit d on it. That looks like:
Selector: t
Passed: 2
Failed: 0
Total: 2/3
Started at: 2015-11-16 02:08:40-0800
Aborted.
Aborted at: 2015-11-16 02:08:40-0800
.A.
A test2
aborted
. test3
passed
In terms of getting a backtrace, hitting b over test2 gives me:
ert-results-pop-to-backtrace-for-test-at-point: cl-etypecase failed: [cl-struct-ert-test-aborted-with-non-local-exit (((should nil) :form nil :value nil))], (ert-test-passed ert-test-result-with-condition)
I don't understand the output of the backtrace at all. This behavior doesn't seem to match what the ERT documentation says so I'm really puzzled. What's going on here?
The code you have posted works in a clean Emacs started with emacs -Q. Most likely, it is caused by some library that has been loaded somehow.

SML uncaught exception "Use failed: Io: openIn failed on..."

I am new with SML/programming/emacs/all the stuff and when I do the first homework from coursera class I have the old story regarding this error:
[opening is_older.sml]
[use failed: Io: openIn failed on "is_older.sml", Win32TextPrimIO:openRd: failed]
uncaught exception Error
raised at: ../compiler/TopLevel/interact/interact.sml:24.14-24.28
I tried all the possible things found on the forums, topics, like: path,checking any misspelled name of sml file, coding-I put several codes, savings, etc. The only thing I did not made was to custom Emacs and I didn't verify if the SML-mode is working properly since 2 days ago Emacs and SML/NJ were installed.
The last code I wrote - but anyway is not important because it doesn't matter which code is, I have the same error - is this:
fun is_older ((x1,y1,z1), (x2,y2,z2)) =
if z1 < z2
then true
else
if x1 = x1 andalso y1 = y2 andalso z1 < z2
then true
else false;
[use failed: Io: openIn failed on "is_older.sml", Win32TextPrimIO:openRd: failed]
This sounds like like it simply didn't find the file. Maybe you misspelled the name, or it's in a different directory?

Function in if statement: error expected expression

I want to compile following file:
https://gist.github.com/bodokaiser/5382281
which does not succeed because I get following error:
CXX(target) Release/obj.target/parser/src/parser/parser.o
In file included from ../src/parser/parser.cc:2:
../src/parser/calc_head_size.cc:67:16: error: expected expression
if (mask || isMasking(masking)) {
^
1 error generated.
make: *** [Release/obj.target/parser/src/parser/parser.o] Error 1
This does not make sense to me. Can it be that there is something else wrong?
Bodo
You seem to have a strange character in your source code that looks like a space but isn't. In this line:
if (mask || isMasking(masking)) {
// ^ here
try to delete the "space" and add a real space.