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

Conversion methods: to* versus to_*? #271

Open
dmdunla opened this issue Sep 28, 2023 · 2 comments
Open

Conversion methods: to* versus to_*? #271

dmdunla opened this issue Sep 28, 2023 · 2 comments
Labels
question Further information is requested
Milestone

Comments

@dmdunla
Copy link
Collaborator

dmdunla commented Sep 28, 2023

(I was going to make a Shakespeare pun, but I resisted...)

What should the convention be for the conversion methods?

Here are a couple in place already:

  • sptensor.spmatrix (aligns with MATLAB TTB)
  • tensor.to_sptensor
  • ktensor.tolist
  • ktensor.tovec
  • ktensor.to_tensor

Note: numpy and scipy support to* methods. Examples (using tab completion to illustrate):

>>> np.ndarray.to
np.ndarray.tobytes(   np.ndarray.tofile(    np.ndarray.tolist(    np.ndarray.tostring(  
>>> sp.coo_matrix.to
sp.coo_matrix.toarray(  sp.coo_matrix.tobsr(    sp.coo_matrix.tocoo(    sp.coo_matrix.tocsc(    sp.coo_matrix.tocsr(    sp.coo_matrix.todense(  sp.coo_matrix.todia(    sp.coo_matrix.todok(    sp.coo_matrix.tolil(

Suggestion: In pyttb, we should align with numpy and scipy conventions.

@jeremy-myers @ntjohnson1 Please weigh in.

@dmdunla dmdunla added the question Further information is requested label Sep 28, 2023
@dmdunla dmdunla added this to the v2.0 milestone Sep 28, 2023
@ntjohnson1
Copy link
Collaborator

I find to_* more readable and I think it follows the snake case convention. However I think aligning with numpy is probably the better option at this point.

@jeremy-myers
Copy link
Collaborator

I agree with @ntjohnson1 that to_* is more readable and follows snake case convention. I am less experienced and more prone to statements like "numpy and scipy got to* wrong".

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

No branches or pull requests

3 participants