TrackedArray vs numpy array
See original GitHub issueHi,
I did some processing for a Trimesh object and then got the new vertices viamyverts = mesh.vertices
. I then did some subsequent computations on myverts
which went fine. However at some point I happened to notice that myverts
is actually of type TrackedArray
. Converting it to a simple numpy array I got a speedup by a factor of 4.
This is not really a big issue, but I was wondering if there should be a method to return the vertices as a simple numpy array, or maybe at least the docs should mention that using the property will yield a TrackedArray
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
trimesh.caching — trimesh 3.17.1 documentation
Properly subclass a numpy ndarray to track changes. Avoids some pitfalls of subclassing by forcing contiguous arrays and does a view into a...
Read more >Tracking signs in numpy array - python - Stack Overflow
Use sign function: np.sign(x) != np.sign(y). If you want the coordinates, you can wrap that around np.where or np.nonzero
Read more >numpy.asarray — NumPy v1.24 Manual
Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples...
Read more >trimesh/caching.py - ynic-debian
Properly subclass a numpy ndarray to track changes. ... arrays, and does a view into a TrackedArray. 37. 38. Parameters. 39. ------------.
Read more >batch must contain tensors, numpy arrays, numbers, dicts or lists
I just use the native example of PyTorch to load Cifar10 and Cifar100 datasets, but it returns this. default_collate: batch must contain tensors ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh interesting. The
TrackedArray
is the thing that enables caching, which provides huge speedups in applications accessing properties multiple times so it’s kind of necessary for vertices and faces. If this turns into an ongoing issue, I wonder if we could make it so copies of aTrackedArray
revert tondarray
type.That being said, in some quick and dirty profiling I couldn’t see any speed difference:
Ok. It’s not really a problem for me - just wanted to make sure there wasn’t a bug or something. I think my use case is kind of uncommon anyway, since I’m looping through a subset of vertices and modifying it in iterative fashion.
Thanks for the package BTW - it already saved me a lot of time.