Repository: graspologic-org/graspologic

Issue:
[BUG] mug2vec assumes undirected graphs but doesn't check for this
## Expected Behavior
Should run on a set of directed graphs

## Actual Behavior
Breaks on this line 
https://github.com/microsoft/graspologic/blob/2125f27bc3f2739f4f2c784d5b700417df63c5d7/graspologic/embed/mug2vec.py#L141
since `omni_embedding` is a tuple 



Discussion:
Hey @bdpedigo , The `omni.fit_transform` returns a tuple of two ndarrays. In that case, what should be taken as self.omnibus_n_components_ ?

I think it would make sense to check if `omnibus_embedding` is an instance of `ndarray` or `tuple` and then assign proper components. What do you think?
hi @vmdhhh - I like your idea but I think it may actually be simpler to pass `concat=True` to `OmnibusEmbed` - this will ensure that the output is always an ndarray. I think it would also make sense to make  `self.omnibus_n_components_ = len(omni.singular_values_)`

I haven't tested this fix but I think it would work. If you are interested in trying it I can assign you this issue and would be happy to review your PR if you make one. 
Hey @bdpedigo, I will be happy to try it out. But I am not sure how to test it, and I also don't see any tests written for mug2vec.
Please let me know If you know any easy way to test this.
the tests are here https://github.com/microsoft/graspologic/blob/dev/tests/test_mug2vec.py

there's also some info about contributing code and testing here https://github.com/microsoft/graspologic/blob/dev/CONTRIBUTING.md

please let me know if that helps or if you have further questions
Is this issue still open? Can I work on this ?
> Is this issue still open? Can I work on this ?

Sure! some info on how to solve it is provided in the comments above
Ok thanks

On Fri, Aug 20, 2021, 8:30 PM Benjamin Pedigo ***@***.***>
wrote:

> Is this issue still open? Can I work on this ?
>
> Sure! some info on how to solve it is provided in the comments above
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/microsoft/graspologic/issues/793#issuecomment-902755925>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AMPIV6VUV5FZ5LJSJGJKQYLT5ZUYVANCNFSM45NSCQTQ>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
> .
>


Resolving patch:
diff --git a/graspologic/embed/mug2vec.py b/graspologic/embed/mug2vec.py
--- a/graspologic/embed/mug2vec.py
+++ b/graspologic/embed/mug2vec.py
@@ -153,10 +153,11 @@ def fit(
             n_components=self.omnibus_components,
             n_elbows=self.omnibus_n_elbows,
             svd_seed=self.svd_seed,
+            concat=True,
         )
         omnibus_embedding = omni.fit_transform(graphs)
 
-        self.omnibus_n_components_ = omnibus_embedding.shape[-1]
+        self.omnibus_n_components_ = len(omni.singular_values_)
 
         cmds = ClassicalMDS(
             n_components=self.cmds_components,


Test patch: