Ad
  • Custom User Avatar

    You are right,I guess it was my own mistake.

  • Custom User Avatar

    Seems fine to me. Try saving your code and use the 'reset' button which should reset the tests.

  • Custom User Avatar

    Tests are messed up.

    Traceback (most recent call last):
    File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper
    func()
    File "/workspace/default/tests.py", line 11, in test_case
    2: (s, "fat"),
    ^
    NameError: name 's' is not defined

  • Custom User Avatar

    Maybe 6 kyu. It took me some time to solve it.

  • Custom User Avatar

    That which you mention is not a Java bug.

    Comparisons between primitive types do not produce the errors you mentioned, and the "equals" method

    of Integer class compares whether they are the same object by comparing if are of the same class and their values.

    Integer equals:

    public boolean equals(Object obj) {
        if (obj instanceof Integer) {
            return value == ((Integer)obj).intValue();
        }
        return false;
    }
    

    I've solved that problem. There was a precision issue in test case.

  • Custom User Avatar

    This might be a bug on java. Some times, when using equal on the numeric objects, instead comparing the value, they compare the instances memory addresses.

  • Custom User Avatar

    Java

    Why sometimes (.2% de 100 of running test) fails?
    I have compensated for an error of 1E-10.

    sumHeight: 39.399476090834455 sumWidth: 39.399476090834455: perfect

    org.opentest4j.AssertionFailedError:
    Expected :fat
    Actual :perfect

  • Custom User Avatar

    It's fixed now, if you encountered an issue, reopen this

  • Custom User Avatar
  • Custom User Avatar

    For what language this issue addressed? If Python, i can fix this.

  • Custom User Avatar

    A solution: don't generate (near) perfect matrices.

    For example:

    num_tests = 0
    while num_tests < 100:
        matrix = random_matrix()
        width, height = ...
        if isclose(width, height):
            continue # drop this matrix
        num_tests += 1
        ... # do test
    
  • Custom User Avatar

    we have infinite decimal places

    ???

  • Custom User Avatar

    approved by

  • Default User Avatar

    Thanks for the advice, hope it is clearer now.

  • Default User Avatar

    I think that the precision errors will be infinite since we have infinite decimal places and the rounding error will always be present, I thought that with an error of 1E-10 I would catch a large part of those results that caused the error.

    In addition, infinite random numbers are not generated, they are generated in a small range between -5 and 20 to force the matrices whose result is null, so the calculation with the error is enough to save those precision errors.

  • Loading more items...