question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[3.5.23] test failures: TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'

See original GitHub issue

While updating the Fedora package, I see quite a few tests failing with this error:

TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'

The failed “scratch build” is here: https://koji.fedoraproject.org/koji/taskinfo?taskID=40470914 Since the build will be trashed in a few days, I’ve attached the complete build logs here:

trimesh-3.5.14-build-fail.txt trimesh-3.5.14-build-fail-state.txt trimesh-3.5.14-build-fail-hw.txt

It seems to be arch specific. If I force the build to run on an x86_64 builder, I only get two failed tests:

=================================== FAILURES ===================================
____________________________ ExportTest.test_layer _____________________________
self = <tests.test_svg.ExportTest testMethod=test_layer>
    def test_layer(self):
        from shapely.geometry import Point
    
        # create two disjoint circles and apply layers
        a = g.trimesh.load_path(Point([0, 0]).buffer(1))
        a.apply_layer('ACIRCLE')
    
        b = g.trimesh.load_path(Point([2, 0]).buffer(1))
        b.apply_layer('BCIRCLE')
    
        # combine two circles
        c = a + b
    
        # should be combined
        assert g.np.isclose(c.area, a.area + b.area)
    
        # export C with just layer of A
        aX = g.trimesh.load(g.io_wrap(
            c.export(file_type='svg',
                     layers=['ACIRCLE'])),
            file_type='svg')
    
        # export C with all layers
        cX = g.trimesh.load(g.io_wrap(
            c.export(file_type='svg',
                     layers=None)),
            file_type='svg')
    
>       assert len(cX.entities) == len(c.entities)
E       AssertionError: assert 1 == 2
E         -1
E         +2
../tests/test_svg.py:59: AssertionError
_____________________________ ExportTest.test_svg ______________________________
self = <tests.test_svg.ExportTest testMethod=test_svg>
    def test_svg(self):
        for d in g.get_2D():
            # export as svg string
            exported = d.export(file_type='svg')
            # load the exported SVG
            stream = g.trimesh.util.wrap_as_stream(exported)
    
            if g.np.isclose(d.area, 0.0):
                continue
    
            loaded = g.trimesh.load(stream, file_type='svg')
    
            # we only have line and arc primitives as SVG
            # export and import
            if all(i.__class__.__name__ in ['Line', 'Arc']
                   for i in d.entities):
                # perimeter should stay the same-ish
                # on export/import
>               assert g.np.isclose(d.length,
                                    loaded.length,
                                    rtol=.01)
E               AssertionError: assert False
E                +  where False = <function isclose at 0x7f5cb37e0f70>(15.16883270309641, 10.88659282532712, rtol=0.01)
E                +    where <function isclose at 0x7f5cb37e0f70> = <module 'numpy' from '/usr/lib64/python3.8/site-packages/numpy/__init__.py'>.isclose
E                +      where <module 'numpy' from '/usr/lib64/python3.8/site-packages/numpy/__init__.py'> = g.np
E                +    and   15.16883270309641 = <trimesh.Path2D(vertices.shape=(4, 2), len(entities)=4)>.length
E                +    and   10.88659282532712 = <trimesh.Path2D(vertices.shape=(4, 2), len(entities)=1)>.length
../tests/test_svg.py:27: AssertionError
=============================== warnings summary ===============================
/usr/lib/python3.8/site-packages/svg/path/path.py:3
  /usr/lib/python3.8/site-packages/svg/path/path.py:3: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    from collections import MutableSequence
tests/test_normals.py::NormalsTest::test_weighted_vertex_normals
  /builddir/build/BUILD/trimesh-3.5.14/trimesh/triangles.py:109: RuntimeWarning: invalid value encountered in true_divide
    u /= util.row_norm(u).reshape((-1, 1))
tests/test_triangles.py::TrianglesTest::test_zero_angle
  /builddir/build/BUILD/trimesh-3.5.14/trimesh/triangles.py:111: RuntimeWarning: invalid value encountered in true_divide
    w /= util.row_norm(w).reshape((-1, 1))
-- Docs: https://docs.pytest.org/en/latest/warnings.html
====== 2 failed, 324 passed, 12 deselected, 3 warnings in 219.35 seconds =======

The logs from this build are here: https://koji.fedoraproject.org/koji/taskinfo?taskID=40471476

trimesh-3.5.14-build-fail-2.txt trimesh-3.5.14-build-fail-hw-2.txt trimesh-3.5.14-build-fail-state-2.txt

Cheers,

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
musicinmybraincommented, Sep 23, 2021

All of the failures are still due to:

TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'

The list of failing tests is:

BinvoxTest.test_load_save_invariance
BoundsTest.test_bounding_egg
EncodingTest.test_composite
EncodingTest.test_dense
EncodingTest.test_flat
EncodingTest.test_flipped
EncodingTest.test_reshape
EncodingTest.test_transpose
PrimitiveTest.test_cyl_buffer
NearestTest.test_coplanar_signed_distance
RleTest.test_brle_encode_decode
RleTest.test_brle_length
RleTest.test_brle_logical_not
RleTest.test_brle_to_dense
RleTest.test_brle_to_rle
RleTest.test_brle_encode_decode
ContainsTest.test_inside
VoxelGridTest.test_local
0reactions
musicinmybraincommented, Dec 1, 2022

A new failure has appeared in 3.17.0, similar to the existing 32-bit failures:


_______________________ SubDivideTest.test_loop_correct ________________________
self = <tests.test_remesh.SubDivideTest testMethod=test_loop_correct>
    def test_loop_correct(self):
        box = g.trimesh.creation.box()
        big_sphere = g.trimesh.creation.icosphere(radius=0.5)
        small_sphere = g.trimesh.creation.icosphere(radius=0.4)
        sub = box.subdivide_loop(iterations=2)
        # smaller than 0.5 sphere
>       assert big_sphere.contains(sub.vertices).all()
/builddir/build/BUILD/trimesh-3.17.0/tests/test_remesh.py:160: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builddir/build/BUILD/trimesh-3.17.0/trimesh/base.py:2887: in contains
    return self.ray.contains_points(points)
/builddir/build/BUILD/trimesh-3.17.0/trimesh/ray/ray_triangle.py:191: in contains_points
    return contains_points(self, points)
/builddir/build/BUILD/trimesh-3.17.0/trimesh/constants.py:146: in timed
    result = method(*args, **kwargs)
/builddir/build/BUILD/trimesh-3.17.0/trimesh/ray/ray_util.py:76: in contains_points
    bi_hits = np.bincount(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
args = (array([ 41,  94, 106,  56,  80, 188,  81,  57,  33, 118, 150,  74, 157,
        89, 171,  77, 137,  79, 110,  54, 121... 45,  25, 131, 101,
       117, 103,   2,  46,  43,  95,  10, 168, 194,  60, 141, 167,  23,
       175], dtype=int64),)
kwargs = {'minlength': 196}
relevant_args = (array([ 41,  94, 106,  56,  80, 188,  81,  57,  33, 118, 150,  74, 157,
        89, 171,  77, 137,  79, 110,  54, 121... 25, 131, 101,
       117, 103,   2,  46,  43,  95,  10, 168, 194,  60, 141, 167,  23,
       175], dtype=int64), None)
>   ???
E   TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'
<__array_function__ internals>:180: TypeError
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot cast array data from dtype('float64') to dtype('int32 ...
Your original result array contains elements of type 'numpy.int64', but the result/4 operation returns an array of elements of type 'numpy.
Read more >
Change data type of given numpy array - GeeksforGeeks
Problem #1 : Given a numpy array whose underlying data is of 'int32' type. Change the dtype of the given object to 'float64'...
Read more >
cannot convert 0.0 to eagertensor of dtype int64 - You.com
Describe the expected behavior Variable should be converted to EagerTensor, operation should return constrained variable. Code to reproduce the issue Provide a ...
Read more >
numpy.can_cast — NumPy v1.24 Manual
Data type, scalar, or array to cast from. todtype or dtype specifier. Data type to cast to. casting{'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional....
Read more >
NumPy User Guide
differences between NumPy arrays and the standard Python sequences: ... TypeError: Cannot cast ufunc add output from dtype('float64') to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found