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

TypeScript error: op.sum is restricted to string parameters only #269

Open
leibatt opened this issue Feb 25, 2022 · 0 comments
Open

TypeScript error: op.sum is restricted to string parameters only #269

leibatt opened this issue Feb 25, 2022 · 0 comments

Comments

@leibatt
Copy link

leibatt commented Feb 25, 2022

Arquero is awesome! I've been using it a lot in one of my ongoing research projects. But today I ran into an issue using op.sum. In the code comments, I see that Arquero's sum operator is restricted to strings only:

/**                                                                                                  
* Aggregate function to sum values.                                                                 
* @param {string} field The data field.                                                             
* @return {number} The sum of the values.                                                           
*/                                                                                                  
sum: (field) => op('sum', field),  

For me, this leads to errors in TypeScript when trying to pass functions instead of the field name. For example, when trying to adapt the percentage calculation from the Arquero cookbook, I get an error because d.c is not a string:

p: (d: Record<string, number>) => d.c / op.sum(d.c)

I see that the other operators do not have this restriction, but I wasn't sure where in the code this could be fixed since I think some of it is generated automatically.

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

1 participant