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

Add simple values() method in Tensorics to retrieve all the values of a Tensor #42

Open
delph74 opened this issue Oct 16, 2020 · 16 comments

Comments

@delph74
Copy link
Contributor

delph74 commented Oct 16, 2020

No description provided.

@kaifox
Copy link
Member

kaifox commented Oct 16, 2020

Hi @delph74

What would you expect as a return type of such a method?

@delph74
Copy link
Contributor Author

delph74 commented Oct 16, 2020

Hello @kaifox ,
We could return a Set, and in this case maybe call the method uniqueValues().
What do you think?

@agorzawski
Copy link
Member

Hi @delph74 and @kaifox

As far I remember, a tensor has no 'values' like method. But (if implements Mappable, and this is the case for the ImmutableTensor) it has .asMap()... which you follow with values().

The practical use of such values collection (only values) may be very limited, as this may vary with their position in the Tensor (coordinate).

@kaifox
Copy link
Member

kaifox commented Oct 16, 2020

yes, then its clear!

Potentially uniqueValuesOf(...) as the other methods in Tensorics?

public static final <T> Set<T> Tensorics.uniqueValuesOf(Tensor<T> tensor);

In general, I clients should void using also the asMap() method directly ... In general, Tensorics.mapFrom(Tensor t) should be used. This calls asMap() if available, which makes it more efficient....

@kaifox
Copy link
Member

kaifox commented Oct 16, 2020

Hey @agorzawski !!! Cool to see you here!

@agorzawski
Copy link
Member

@kaifox I just want to recall, that I have never left this project ;-)

@delph74
Copy link
Contributor Author

delph74 commented Oct 16, 2020

Yes @kaifox , something like that would be perfect.
I often use values for Map and I think for a Tensor we may have many usecase where such method would be needed!

@michi42
Copy link
Member

michi42 commented Oct 16, 2020

Maybe one more thing - there is Tensorics.stream(Tensor) that allows processing Position-Value pairs via the Java 8 streaming API, and TensorStreamFilters and TensorStreamMappers to help with filtering/mapping. Also there are some collectors to build tensors or tensorbackeds with streams in TensorStreams.

@delph74
Copy link
Contributor Author

delph74 commented Oct 16, 2020

yes of course it it possible and not to difficult to get all the values of a Tensor, like that for example
Tensorics.stream(betaStarParameters).map(Map.Entry::getValue).collect(toSet());

So nothing urgent or really missing, just for convenience and make it easier.

@kaifox
Copy link
Member

kaifox commented Oct 16, 2020

Good point @michi42 ! ... Still, convenience methods can still be justified... I think there is nothing against adding it.

@kaifox
Copy link
Member

kaifox commented Oct 16, 2020

@agorzawski , good to hear!

@michi42
Copy link
Member

michi42 commented Oct 16, 2020

Yes sure, I did not mean to object that :-)

@kaifox
Copy link
Member

kaifox commented Oct 16, 2020

I know ;-)

@kaifox
Copy link
Member

kaifox commented Oct 16, 2020

Just wanted to encourage @delph74 to add it if she feels like ;-)

@delph74
Copy link
Contributor Author

delph74 commented Oct 16, 2020

Yes why not, I would then add my first contribution to tensoric project ✌️ 😃

@kaifox
Copy link
Member

kaifox commented Oct 16, 2020

Cooool!!!!!

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

4 participants