Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not clear how to write a file #49

Open
Svito-zar opened this issue Oct 21, 2022 · 2 comments
Open

Not clear how to write a file #49

Svito-zar opened this issue Oct 21, 2022 · 2 comments

Comments

@Svito-zar
Copy link

The documentation shows the following usage example for the write functionality:

import c3d
import numpy as np


writer = c3d.Writer()
for _ in range(100):
    writer.add_frame(np.random.randn(30, 5))
with open('random-points.c3d', 'wb') as h:
    writer.write(h)

This has two issues. First, it should be add_frames but not add_frame. That's easy to fix. But the second issue is hard to fix, since write.write expects a second argument, labels, and it is not clear what it should be

TypeError: write() missing 1 required positional argument: 'labels'

@mrrezaie
Copy link

mrrezaie commented Oct 9, 2024

Hi, I have a similar problem with c3d.Writer. Any idea how to fix it?

for i, point, analog in reader.read_frames():
    writer.add_frames((point,analog))
Traceback (most recent call last):
  File F:\Python310\lib\site-packages\numpy\core\fromnumeric.py:2022 in shape
    result = a.shape
AttributeError: 'list' object has no attribute 'shape'

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  Cell In[122], line 2
    writer.add_frames((point,analog))
  File F:\Python310\lib\site-packages\c3d\c3d.py:2213 in add_frames
    sh = np.shape(frames)
  File F:\Python310\lib\site-packages\numpy\core\fromnumeric.py:2024 in shape
    result = asarray(a).shape
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (1, 2) + inhomogeneous part.

Any help is greatly appreciated.
Python 3.10, Numpy 1.25

@zhuyuhang4
Copy link

@mrrezaie Try to 'pip install numpy==1.21.1'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants