8000 Grant access to createNetwork function · Issue #59 · bayesjs/bayesjs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Grant access to createNetwork function #59

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

Open
Nonudian opened this issue May 26, 2021 · 1 comment
Open

Grant access to createNetwork function #59

Nonudian opened this issue May 26, 2021 · 1 comment

Comments

@Nonudian
Copy link
Nonudian commented May 26, 2021

Hello,

I'm actually confronted to a small but annoying problem : I can't access the createNetwork function, used in some of your test files and present in the /src/utils/network.ts file of your project.

I made a config file that contains all nodes, and I want to export the whole network at the end of file.

I done that in a little bit ugly way:

import { addNode, INetwork } from "bayesjs";
...
const allNodes = [...] //INode[]

let net: INetwork = {};
allNodes.forEach(node => net = addNode(net, node));
export const network: INetwork = net;

And I would like to do something like this:

import { createNetwork } from "bayesjs";
...
const allNodes = [...] //INode[]

export const network = createNetwork(...allNodes);

I already tried hacky thing like import { createNetwork } from "bayesjs/dist/utils/network" but that crashes at compilation.
If you have any idea to perform that, I will be glad to hear it.

Thanks!

EDIT:

Ok, finally I found a cleaner way to do it with a reduce
That's not as shorter as I want, but that's ok

export const network = allNodes.reduce<INetwork>((network, node) => addNode(network, node), {});
@nolleto
Copy link
Collaborator
nolleto commented Sep 15, 2021

I will take a look at this code and see if I can improve it, ASAP 😄

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

2 participants
0