I would like to multiply a dataset with a real number, e.g.
data = ct.catalogue.retrieve(...) desired_result = data*3
This gives me the following error message:
Is there any way to perform this operation?
Thank you!
I would like to multiply a dataset with a real number, e.g.
data = ct.catalogue.retrieve(...) desired_result = data*3
This gives me the following error message:
Is there any way to perform this operation?
Thank you!
6 Comments
Vivien MAVEL
Dear Georg,
Any additional detail on your workflow would help to understand the nature of data and why this operation fails.
You could try to use the multiplication operator:
Regards.
Vivien
Georg Helbing
Thank you Vivien, your code proposal worked perfectly!
Vivien MAVEL
Great, glad to know.
I am curious to understand why the * did not work, would you mind sharing the code that was failing?
Georg Helbing
Ok, here's some part of the code:
Vivien MAVEL
Hi Georg, if you do data * 3 instead of 3 * data the * operator actually works.
This is still a bug that need to be fixed but it still allows you to use * and make your code shorter and more readable.
Note that ct.operator has the advantage of handling the units where units are preserved while the +, -, *, / operations always drop the units.
Regards.
Vivien
Georg Helbing
Good to know, thanks!