Saravanan666/pypi-org huggingface dataset:
Package: tnode
Tree nodeClasses:TNode - Single node approach that can have any number of childrenParent - Parent/Child nodes. Parent can have children of specific types.Child - Parent/Child nodes. Child cannot have children, but can have a parent of specific types.Attributesparent - parent object or Nonetitle - String title for this node (Can be ‘’)children - List of child objectsfull_title - Parent titles and this title separeted by the set delimiterMethodsget_parents(require_title=False) - Iterate through the parent objectsadd_child(child) - Add a child objectremove_child(child) - Remove a child objectclear() - Clear all direct childrenfind_parent(full_title) - Return the parent and title from the given full title.find(full_title) - Return the child object with the given full title.iter_children() - Iterate through the direct children.__iter__() - Iterate through the direct children.iter() - Iterate though all children and children’s children.iter_nearest() - Iterate through direct children then their children’s children.__getitem__(full_title) - Return the child object with the given full title.__setitem__(full_title, child) - Add the child to the proper parent with the full title.__len__() - Return the length of the direct children.ExampleCreate the tree nodes.fromtnodeimportTNodet=TNode()parent1=TNode('parent1',parent=t)child1=TNode('child1',parent=parent1)child2=TNode('child2',parent=parent1)parent2=TNode('parent2',parent=parent1)child3=TNode('child3',parent=parent2)child4=TNode('child4',parent=parent2)assertlist(t.iter())==\[t,parent1,child1,child2,parent2,child3,child4]Parent Child ExampleCreate custom Parent and Child classes.fromtnodeimportParentNode,ChildNodeclassParent(ParentNode):passclassChild(ChildNode):def__init__(self,title='',data=None,parent=None,**kwargs):self.data=datasuper().__init__(title=title,parent=parent,**kwargs)defhas_data(self):"""Helper to return if this function has data."""returnTruedefget_data(self):"""Return the data stored."""returnself.dataParent.register_parent_type(Parent)Parent.register_child_type(Parent)Parent.register_child_type(Child)Child.register_parent_type(Parent)# Create treetop=Parent('')parent1=top.add_parent('parent1')parent2=top.add_parent('parent2')subparent1=top.add_parent('parent1 > subparent1')child1=top.add('child1',data=1)child2=top.add('parent1 > child2',data=2)child3=top.add('parent1 > subparent1 > child3',data=3)filename='test_json_parent_child.json'try:t2=top.from_json(top.to_json(filename))forv1,v2inzip(top.iter(),t2.iter()):assertv1.full_title==v2.full_titleassertv1.get_data()==v2.get_data()finally:try:os.remove(filename)except(OSError,Exception):pass
Package: tno.mpc.encryption-schemes.shamir
TNO MPC Lab - Encryption Schemes - ShamirThe TNO MPC lab consists of generic software components, procedures, and functionalities developed and maintained on a regular basis to facilitate and aid in the development of MPC solutions. The lab is a cross-project initiative allowing us to integrate and reuse previously developed MPC functionalities to boost the development of new protocols and solutions.The package tno.mpc.encryption_schemes.shamir is part of the TNO Python Toolbox.Limitations in (end-)use: the content of this software package may solely be used for applications that comply with international export control laws.This implementation of cryptographic software has not been audited. Use at your own risk.DocumentationDocumentation of the tno.mpc.encryption_schemes.shamir package can be foundhere.InstallEasily install the tno.mpc.encryption_schemes.shamir package using pip:$python-mpipinstalltno.mpc.encryption_schemes.shamirIf you wish to run the tests you can use:$python-mpipinstall'tno.mpc.encryption_schemes.shamir[tests]'Note:A significant performance improvement can be achieved by installing the GMPY2 library.$python-mpipinstall'tno.mpc.encryption_schemes.shamir[gmpy]'UsageThe shamir secret sharing module can be used as follows:fromtno.mpc.encryption_schemes.shamirimportShamirSecretSharingScheme,ShamirShares# Initialize a three-out-of-five secrect sharing scheme with prime 10657# Note: the polynomial degree is one less than the number of parties needed for reconstructionshamir_scheme=ShamirSecretSharingScheme(10657,5,2)# Share a secret integersharing=shamir_scheme.share_secret(42)# When receiving shares a reconstructor can be created as followsreconstructor=ShamirShares(shamir_scheme,{1:sharing.shares[1],2:sharing.shares[2],3:sharing.shares[3]})# Reconstruct the secret and check if it is the expected resultassert42==sharing.reconstruct_secret()==reconstructor.reconstruct_secret()
Package: tno.mpc.encryption-schemes.utils
TNO MPC Lab - Encryption Schemes - UtilsThe TNO MPC lab consists of generic software components, procedures, and
functionalities developed and maintained on a regular basis to facilitate and
aid in the development of MPC solutions. The lab is a cross-project initiative
allowing us to integrate and reuse previously developed MPC functionalities to
boost the development of new protocols and solutions.The package tno.mpc.encryption_schemes.utils is part of the TNO Python Toolbox.Limitations in (end-)use: the content of this software package may solely be
used for applications that comply with international export control laws.This implementation of cryptographic software has not been audited. Use at your
own risk.DocumentationDocumentation of the tno.mpc.encryption_schemes.utils package can be foundhere.InstallEasily install the tno.mpc.encryption_schemes.utils package using pip:$python-mpipinstalltno.mpc.encryption_schemes.utilsIf you wish to usenumpyyou can use:$python-mpipinstall'tno.mpc.encryption_schemes.utils[numpy]'If you wish to run the tests you can use:$python-mpipinstall'tno.mpc.encryption_schemes.utils[tests]'Note:A significant performance improvement can be achieved by installing the GMPY2
library.$python-mpipinstall'tno.mpc.encryption_schemes.utils[gmpy]'
Package: tno.mpc.mpyc.exponentiation
TNO MPC Lab - MPyC - Secure ExponentiationThe TNO MPC lab consists of generic software components, procedures, and functionalities developed and maintained on a regular basis to facilitate and aid in the development of MPC solutions. The lab is a cross-project initiative allowing us to integrate and reuse previously developed MPC functionalities to boost the development of new protocols and solutions.The package tno.mpc.mpyc.exponentiation is part of the TNO Python Toolbox.The package contains a generic extension to MPyC that allows you to securely compute $a^{[x]}$, where $a$ is a non-negative, plain-text base (floating point or integer) and $x$ is a secure number (SecFxp or SecInt).Limitations in (end-)use: the content of this software package may solely be used for applications that comply with international export control laws.This implementation of cryptographic software has not been audited. Use at your own risk.DocumentationDocumentation of the tno.mpc.mpyc.exponentiation package can be foundhere.InstallEasily install the tno.mpc.mpyc.exponentiation package using pip:$python-mpipinstalltno.mpc.mpyc.exponentiationNote:A significant performance improvement can be achieved by installing the GMPY2 library.$python-mpipinstall'tno.mpc.mpyc.exponentiation[gmpy]'If you wish to run the tests you can use:$python-mpipinstall'tno.mpc.mpyc.exponentiation[tests]'UsageMinimal exampleexample.pyimportmathfrommpyc.runtimeimportmpcfromtno.mpc.mpyc.exponentiationimportsecure_powasyncdefmain(base=math.e,x=[-1.5,2.3,4.5]):asyncwithmpc:stype=mpc.SecFxp()sec_x=([stype(xx,integral=False)forxxinx]ifisinstance(x,list)elsestype(x))result=secure_pow(base,sec_x)revealed_result=awaitmpc.output(result)plain_result=[base**xxforxxinx]ifisinstance(x,list)elsebase**xprint(f"Result of secure exponentiation is{revealed_result}")print(f"In the plain we would have gotten{plain_result}")diff=([abs(sec-plain)forsec,plaininzip(revealed_result,plain_result)]ifisinstance(x,list)elseabs(revealed_result-plain_result))print(f"The absolute difference is{diff}")if__name__=="__main__":mpc.run(main())
Package: tno.mpc.mpyc.matrix-inverse
TNO MPC Lab - MPyC - Matrix InverseThe TNO MPC lab consists of generic software components, procedures, and functionalities developed and maintained on a regular basis to facilitate and aid in the development of MPC solutions. The lab is a cross-project initiative allowing us to integrate and reuse previously developed MPC functionalities to boost the development of new protocols and solutions.The package tno.mpc.mpyc.matrix_inverse is part of the TNO Python Toolbox.This package is based on the demoridgeregression.pyfrom the MPyC library on Feb 26th, 2020, as implemented by
Frank Blom.https://github.com/lschoe/mpyc/blob/2de1dd76db632bdc2a48acfbbaab841fa73cf8bd/demos/ridgeregression.py. The
underlying theory is published in the paper 'Efficient Secure Ridge Regression from
Randomized Gaussian Elimination' by Frank Blom, Niek J. Bouman, Berry
Schoenmakers, and Niels de Vreede, presented at TPMPC 2019 by Frank Blom.
Seehttps://eprint.iacr.org/2019/773(orhttps://ia.cr/2019/773).Note: we added support for secure fixed points (SecFxp).Limitations in (end-)use: the content of this software package may solely be used for applications that comply with international export control laws.This implementation of cryptographic software has not been audited. Use at your own risk.DocumentationDocumentation of the tno.mpc.mpyc.matrix_inverse package can be foundhere.InstallEasily install the tno.mpc.mpyc.matrix_inverse package using pip:$python-mpipinstalltno.mpc.mpyc.matrix_inverseNote:A significant performance improvement can be achieved by installing the GMPY2 library.$python-mpipinstall'tno.mpc.mpyc.matrix_inverse[gmpy]'If you wish to run the tests you can use:$python-mpipinstall'tno.mpc.mpyc.matrix_inverse[tests]'UsageUsageexample.pyimportnumpyasnpfrommpyc.runtimeimportmpcfromtno.mpc.mpyc.matrix_inverseimportmatrix_inverseasyncdefmain():X=(np.random.randint(low=-1000,high=1000,size=(5,5))/10).tolist()Xinv=np.linalg.inv(X).tolist()awaitmpc.start()secfxp=mpc.SecFxp()X_mpc=[[secfxp(x)forxinrow]forrowinX]X_mpc=[mpc.input(row,0)forrowinX_mpc]inverse=matrix_inverse(X_mpc)Xinv_mpc=[awaitmpc.output(_)for_ininverse]Xinv_mpc=[[float(xx)forxxinx]forxinXinv_mpc]checker=mpc.matrix_prod(X_mpc,inverse)checker=[awaitmpc.output(_)for_inchecker]diff=np.array(Xinv)-np.array(Xinv_mpc)rel_diff=np.divide(diff,np.array(Xinv),out=np.zeros_like(diff),where=np.array(Xinv)!=0)awaitmpc.shutdown()print(f"X =\n{np.array(X)}\n")print(f"Xinv =\n{np.array(Xinv)}\n")print(f"Xinv_mpc =\n{np.array(Xinv_mpc)}\n")print(f"X * Xinv_mpc =\n{np.array(checker)}\n")print(f"max absolute diff ={np.abs(diff).max()}")print(f"max relative diff (nonzero entries) ={np.abs(rel_diff).max()}")if__name__=="__main__":mpc.run(main())
Package: tno.mpc.mpyc.statistics
TNO MPC Lab - MPyC - StatisticsThe TNO MPC lab consists of generic software components, procedures, and functionalities developed and maintained on a regular basis to facilitate and aid in the development of MPC solutions. The lab is a cross-project initiative allowing us to integrate and reuse previously developed MPC functionalities to boost the development of new protocols and solutions.The package tno.mpc.mpyc.statistics is part of the TNO Python Toolbox.Within theLANCELOTproject, a collaboration between TNO, IKNL and Janssen, TNO developed and implemented secure statistics. LANCELOT is partly funded by PPS-surcharge for Research and Innovation of the Dutch Ministry of Economic Affairs and Climate Policy. The Appl.AI projectSELECTED, partly funded by NLAIC, also contributed to specific components in secure statistics (correlation, covariance).Limitations in (end-)use: the content of this software package may solely be used for applications that comply with international export control laws.This implementation of cryptographic software has not been audited. Use at your own risk.DocumentationDocumentation of the tno.mpc.mpyc.statistics package can be foundhere.InstallEasily install the tno.mpc.mpyc.statistics package using pip:$python-mpipinstalltno.mpc.mpyc.statisticsIf you wish to run the tests you can use:$python-mpipinstall'tno.mpc.mpyc.statistics[tests]'Note:A significant performance improvement can be achieved by installing the GMPY2 library.$python-mpipinstall'tno.mpc.mpyc.statistics[gmpy]'UsageThe statistics module can be used as follows:importnumpyasnpfrommpyc.runtimeimportmpcfromtno.mpc.mpyc.statisticsimportcovariancesecnum=mpc.SecFxp(l=64,f=32)defget_mpc_data(row_1,row_2):row_1_mpc=[secnum(x)forxinrow_1]row_2_mpc=[secnum(y)foryinrow_2]returnrow_1_mpc,row_2_mpcdefdistribute_data_over_players(row_1_mpc,row_2_mpc):row_1_mpc_shared=mpc.input(row_1_mpc,senders=0)row_2_mpc_shared=mpc.input(row_2_mpc,senders=0)returnrow_1_mpc_shared,row_2_mpc_sharedasyncdefcovariance_example():print("Covariance example")row_1=[1.0,3.0,2.0,1.0,5.0,6.0,3.0]row_2=[2.0,11.0,9.0,0.0,8.0,2.0,2.1]row_1_np=np.array(row_1)row_2_np=np.array(row_2)row_1_mpc,row_2_mpc=get_mpc_data(row_1_np,row_2_np)asyncwithmpc:row_1_mpc_shared,row_2_mpc_shared=distribute_data_over_players(row_1_mpc,row_2_mpc)secure_cov=covariance(row_1_mpc_shared,row_2_mpc_shared)revealed_cov=awaitmpc.output(secure_cov)np_cov=np.cov(row_1,row_2)[0][1]print("Secure Covariance: ",revealed_cov)print("Numpy Covariance:",np_cov)if__name__=="__main__":mpc.run(covariance_example())
Package: tno.mpc.mpyc.stubs
TNO MPC Lab - MPyC - StubsThe TNO MPC lab consists of generic software components, procedures, and functionalities developed and maintained on a regular basis to facilitate and aid in the development of MPC solutions. The lab is a cross-project initiative allowing us to integrate and reuse previously developed MPC functionalities to boost the development of new protocols and solutions.The package tno.mpc.mpyc.stubs is part of the TNO Python Toolbox.This package contains stubs to use for type hintingMPyC.Limitations in (end-)use: the content of this software package may solely be used for applications that comply with international export control laws.This implementation of cryptographic software has not been audited. Use at your own risk.InstallEasily install the tno.mpc.mpyc.stubs package using pip:$python-mpipinstalltno.mpc.mpyc.stubs
Package: tno.quantum.ml.classifiers.vc
TNO Quantum: Variational classifierTNO Quantum provides generic software components aimed at facilitating the development
of quantum applications.Thetno.quantum.ml.classifiers.vcpackage provides aVariationalClassifierclass, which has been implemented
in accordance with thescikit-learn estimator API.
This means that the classifier can be used as any other (binary and multiclass)
scikit-learn classifier and combined with transforms throughPipelines.
In addition, theVariationalClassifiermakes use ofPyTorchtensors, optimizers, and loss
functions.Limitations in (end-)use: the content of this software package may solely be used for applications that comply with international export control laws.DocumentationDocumentation of thetno.quantum.ml.classifiers.vcpackage can be foundhere.InstallEasily install thetno.quantum.ml.classifiers.vcpackage using pip:$python-mpipinstalltno.quantum.ml.classifiers.vcIf you wish to run the tests you can use:$python-mpipinstall'tno.quantum.ml.classifiers.vc[tests]'ExampleHere's an example of how theVariationalClassifierclass can be used for
classification based on theIris dataset:
Note thattno.quantum.ml.datasetsis required for this example.fromtno.quantum.ml.classifiers.vcimportVariationalClassifierfromtno.quantum.ml.datasetsimportget_iris_datasetX_training,y_training,X_validation,y_validation=get_iris_dataset()vc=VariationalClassifier()vc=vc.fit(X_training,y_training)predictions_validation=vc.predict(X_validation)
Package: tno.quantum.ml.datasets
TNO Quantum: DatasetsTNO Quantum provides generic software components aimed at facilitating the development of quantum applications.Thetno.quantum.ml.datasetspackage wraps some of the functionality of thesklearn.datasets.
This package is used for testing thetno.quantum.mlclassifiers and clustering algorithms in an easy, reproducible and consistent way.Limitations in (end-)use: the content of this software package may solely be used for applications that comply with international export control laws.DocumentationDocumentation of thetno.quantum.ml.datasetspackage can be foundhere.InstallEasily install thetno.quantum.ml.datasetspackage using pip:$python-mpipinstalltno.quantum.ml.datasetsIf you wish to run the tests you can use:$python-mpipinstall'tno.quantum.ml.datasets[tests]'UsageHere's an example of how thedatasetspackage can be used to load an iris dataset.fromtno.quantum.ml.datasetsimportget_iris_datasetX_train,y_train,X_val,y_val=get_iris_dataset()
Package: tnorma
tnormaTemporal normalization (from 0 to 100% with step interval).Temporal normalization is usually employed for the temporal alignment of data obtained from different trials with different duration (number of points). This code implements a procedure knwown as the normalization to percent cycle.This code can perform simple linear interpolation passing through each datum or spline interpolation (up to quintic splines) passing through each datum (knots) or not (in case a smoothing parameter > 0 is inputted).NaNs and any value inputted as a mask parameter and that appears at the extremities might be removed or replaced by the first/last not-NaN value before the interpolation because this code does not perform extrapolation.For a 2D array, the entire row with NaN or a mask value at the extermity might be removed because of alignment issues with the data from different columns. As result, if there is a column of only NaNs in the data, the temporal normalization can't be performed (an empty NaNs and any value inputted as a mask parameter and that appears in the middle of the data (which may represent missing data) are ignored and the interpolation is performed through these points.InstallationpipinstalltnormaOrcondainstall-cduartexyztnormaExamples>>># Default options: cubic spline interpolation passing through>>># each datum, 101 points, and no plot>>>y=[5,4,10,8,1,10,2,7,1,3]>>>tnorma(y)>>># Deal with missing data (use NaN as mask)>>>x=np.linspace(-3,3,100)>>>y=np.exp(-x**2)+np.random.randn(100)/10>>>y[:10]=np.NaN# first ten points are missing>>>y[30:41]=np.NaN# make other 10 missing points>>>yn,tn,indie=tnorma(y,step=-50,k=3,smooth=1,show=True)>>># Deal with 2-D array>>>x=np.linspace(-3,3,100)>>>y=np.exp(-x**2)+np.random.randn(100)/10>>>y=np.vstack((y-1,y[::-1])).T>>>yn,tn,indie=tnorma(y,step=-50,k=3,smooth=1,show=True)tnorma.ipynbHow to cite this workHere is a suggestion to cite this GitHub repository:Duarte, M. (2020) tnorma: A Python module for temporal normalization (from 0 to 100% with step interval),https://github.com/demotu/tnorma.And a possible BibTeX entry:@misc{Duarte2020,  
    author ={Duarte, M.},
    title ={tnorma: A Python module for temporal normalization (from 0 to 100% with step interval)},year ={2020},  
    publisher ={GitHub},  
    journal ={GitHub repository},  
    howpublished ={\url{https://github.com/demotu/tnorma}}}LicenseThe non-software content of this project is licensed under aCreative Commons Attribution 4.0 International License, and the software code is licensed under theMIT license.
Package: t-normalizer
TextNormalizerTextNormalizeris a strings normalizer that usesSentenceTransformersas a backbone to obtain vector representations of sentences.
It is designed for repeated normalization of strings against a large corpus of strings.The main contribution ofTextNormalizeris to gain time by eliminating the need to compute the normalized strings embeddings every time.Setuppipinstallt-normalizerUsageCreate and instance ofTextNormalizer, can be initialized with aSentenceTransformermodel or aSentenceTransformermodel path.Obtain the vector representation of the normalized string with.fitmethod.Transform the string with to the most similar normalized form using the.transformmethod.fromtextnormalizerimportTextNormalizernormalizer=TextNormalizer()normalized_text=['senior software engineer','solutions architect','junior software developer']to_normalize=['experienced software engineer','software architect','entry level software engineer']normalizer.fit(normalized_text)transformed=normalizer.transform(to_normalize)The model along with the normalized strings and their  vector representations can be saved and loaded with.saveand.loadmethods.Serialization# savenormalizer.save('path/to/model')# loadmodel=TextNormalizer.load('path/to/model')
Package: tno.sdg.graph.gen.graphbin
TNO PET Lab - Synthetic Data Generation (SDG) - Graph - Generation - GraphBinThe TNO PET Lab consists of generic software components, procedures, and
functionalities developed and maintained on a regular basis to facilitate and
aid in the development of PET solutions. The lab is a cross-project initiative
allowing us to integrate and reuse previously developed PET functionalities to
boost the development of new protocols and solutions.The packagetno.sdg.graph.gen.graphbinis part of the TNO Python Toolbox.The research activities that led to this protocol and implementation were
supported by TNO's Appl.AI programme.Limitations in (end-)use: the content of this software package may solely be
used for applications that comply with international export control laws.This implementation of software has not been audited. Use at your own risk.DocumentationDocumentation of thetno.sdg.graph.gen.graphbinpackage can be foundhere.InstallEasily install thetno.sdg.graph.gen.graphbinpackage using pip:$python-mpipinstalltno.sdg.graph.gen.graphbinThe package has two groups of optional dependencies:tests: Required packages for running the tests included in this packagescripts: The packages required to run the example scriptUsageThis repository implements part of the GraphBin algorithm. Currently, the edge
generation step of GraphBin is implemented, but not the node generation. It is
only supported to generate synthetic graphs "from scratch", i.e. without a
source graph from which characteristics are learned. Instead, the current
implementation provides the methodGraphBin.from_scratch, which generates a
new random graph based on the provided parameters.The parameters are as follows:n_samples: The number of nodes to generateparam_feature: Parameter governing exponential distribution from which the
value of the "feature" is sampled (i.e. transaction amount)param_degree: Parameter governing the powerlaw distribution from which the
degrees of the nodes are sampledcor: Specify the correlation betweenparam_featureandparam_degreeparam_edges: Roughly related to the strength of the binning on the edge
probabilitiesBelow, examples of feature and degree distributions are shown for different
values ofparam_featureandparam_degree.Example ScriptBe sure to install thescriptsoptional dependency group (see installation
instructions).importmatplotlib.pyplotaspltimportnetworkxasnxfromtno.sdg.graph.gen.graphbinimportGraphBinN=200graphbin=GraphBin.from_scratch(n_samples=N,param_feature=2000,param_degree=19,cor=0.3,param_edges=4000,random_state=80,)graph=graphbin.generate()Plot the node degree & node feature.plt.figure(figsize=(15,10),dpi=300)plt.scatter(graph.degree,graph.feature,s=150,alpha=0.65)plt.xlabel("Node degree")plt.ylabel("Node feature")plt.title("Node degree and node feature (node-level feature), for "+str(N)+" nodes")plt.show()And the graph:plt.figure(figsize=(15,10),dpi=300)G=nx.Graph()G.add_nodes_from(graph.index)G.add_edges_from(tuple(map(tuple,graph.edges)))pos=nx.spring_layout(G,k=100/N)nx.draw(G,node_size=350,node_color=graph.feature,pos=pos)plt.title("Synthetic graph with nodes colored by feature value")plt.show()