Saravanan666/pypi-org huggingface dataset:
Package: tymongo
TyMongo 🐍📦PyMongo + Pydantic = TyMongo 🤩TyMongo is a Python package designed to simplify your interaction with MongoDB by leveraging the power ofpymongofor database connectivity andpydanticfor efficient modeling and type creation through classes.FeaturesSeamless connection to MongoDB using pymongo. 🌐Data modeling and type creation with pydantic classes. 🧱Automatic data validation and type conversion. ✅Automatic data serialization and deserialization. 📦Installation 📥To install TyMongo, simply use pip:pipinstalltymongoSetup 🛠️All you really need to do is to create.envfile in your project root directory and add the following variables:DATABASE_URL=your_database_urlDATABASE_NAME=your_database_nameAnd now you're ready to go! 🚀Usage 📝Creating a ModelTo create a model, simply inherit fromTyMongoModeland define your fields:classUser(TyMongoModel):name:strage:intclassConfig:collection="users"Will work 100% likeBaseModelfrom pydantic, but with some extra features. 🤩Make sure you define inner classConfigand setcollectionto the name of the collection you want to use in your database. 📁You don't have to define_idfield, it will be automatically created for you. 🆔Creating a Useruser=User(name="Majid",age=21)# oruser_dict={"name":"Majid","age":21}user=User(**user_dict)You can pass any value to any field, it will be automatically converted to the type you defined. 🔄You can also pass a dictionary to the model, it will be automatically converted to the model. 🔄Saving a Useruser.save()Now you have a new user in your database! 🎉Editing a Useruser.age=22user.save()Now your user's age is 22 in your database! 🎉Deleting a Useruser.delete()Now your user is deleted from your database! 🎉Extra Features 🤩Querying & Fields Validationquery={"age":22}users=User.find(query)Just like pymongo, you can pass a query tofindmethod and it will return a list of all the users that match the query as a list of models, just make sure the dictionary keys match the model fields. 🔑query={'x':'some value','age':21,}users=User.find(query)This will raise an error becausexis not a field in the model. ❌Get a Single Document by IDuser=User.get("xxxxxxxxxxxxxxxxxxxxxxxx")Get a Single Document by Queryq={'name':'Majid'}user=User.find_one(q)What if I want to use pymongo directly? 🤔You can access the collection object directly from the model:collection=User.__collection__()users=collection.find({"age":22})LicenseTyMongo is licensed under the terms of theMIT License.Contributing 🤝Majid Saleh Al-RaimiContact 📧EmailAcknowledgements 🙏pymongopydanticThank you for using TyMongo! 🙌 happy coding! 🚀
Package: tympy
Thecomparefunction is designed to compare the execution speed of different Python functions on a set of files. It takes three arguments:FILES(List of Strings): This argument accepts a list of file names. Each file should point to a Python file that you want to run.FUNCTIONS(Single String or List of Strings): This argument can be either a single function name (as a string) or a list of function names (as a list of strings). If you pass a single function name, it will be applied to all files. If you pass a list of function names, the number of function names should match the number of files.ARGS(Single String, List of Strings, Tuple, or List of Tuples): This argument can be one argument (as a string), one argument (as a tuple), or multiple arguments (as a list of tuples). If you pass a single argument, it will be applied to all functions. If you pass multiple arguments, the number of arguments should match the number of functions, and each argument should be passed as a tuple.Here is an example of how to use thecomparefunction:First install and import the package:importtympyasTOExample 1: Compare Execution Speed of Multiple Functions in Multiple FilesTO.compare(["example_1.py","example_2.py","example_3.py"],["sum","SuM","SuMIT"],[(5,9),(9,5),(5,9)])Example 2: Compare Execution Speed of a Single Function Across Multiple FilesTO.compare(["example_1.py","example_2.py"],"subtract",[(5,9),(9,5)])Example 3: Compare Execution Speed of Multiple Functions with Single ArgumentTO.compare(["example_1.py","example_3.py"],["sum","SuMIT"],(5,9))Example 4: Compare Execution Speed of Multiple Functions with Single String ArgumentTO.compare(["example_1.py","example_2.py"],["printNOW","printNoW"],"Hello World!")When comparing multiple files that perform similar tasks, it's important to note that they may have slight differences. Here's a suggested approach:File Selection: Select the files you wish to compare.Function Identification: Verify if the functions within these files have similar names. If not, create a list that maps the functions to their corresponding files based on their positioning.Argument Verification: Check if there are any arguments that need to be passed to these functions.
Package: tyo-mq-client
tyo-mq-client-pythonA TYO-MQ python client for TYO-MQ server.TYO-MQ serverplease refer to [TYO-MQ Server]{https://github.com/tyolab/tyo-mq}/server.jsIn short, TYO-MQ is an implementation of pub/sub message distribution service using socket.io(webscoket).Creating a messaging servervarMessageServer=require("tyo-mq").server;varmq=newMessageServer();mq.start();Creating a message producer and consumerfromtyo_mq_client.message_queueimportMessageQueuefromtyo_mq_client.socketimportSocketfromtyo_mq_client.loggerimportLoggerfromtyo_mq_client.constantsimportConstantssubscriber=Noneproducer=Noneready=[False,False]mq=MessageQueue()producer=mq.createPublisher("TYO Lab")# A producer can be also a consumersubscriber=producerdefon_message_published(message):print("received message"+json.dumps(message))os._exit(1)defcheck():if(ready[0]andready[1]):producer.produce({"message":"Hello World"})defsubscriber_on_connect():Logger.log("Subscriber is connected")ready[0]=Truesubscriber.subscribe(producer.name,Constants.EVENT_DEFAULT,on_message_published,False)defon_subscription(data):print("received subscription")producer.produce({"message1":"Hello World"})producer.on('test',on_message_published)producer.socket.emit('test')producer.produce({"message2":"Hello World"},producer.eventDefault,Constants.METHOD_BROADCAST)defproducer_on_connect():subscriber_on_connect()Logger.log("Producer is connected")ready[1]=Trueproducer.on_subscription_listener=on_subscriptionproducer.on_subscriber_lost(on_subscriber_lost)defon_subscriber_lost(data):message=json.dumps(data)Logger.log('Informed that connection with a subscriber ('+message["consumer"]+') was lost')producer.add_on_connect_listener(producer_on_connect)producer.connect(-1)MaintainerEric Tang@TYO LAB
Package: typ
typ is a simple program for testing command line executables and Python code.When testing Python code, it is basically a wrapper around the standard
unittest module, but it provides the following bits of additional
functionality:Parallel test execution.Clean output in the style of the Ninja build tool.A more flexible mechanism for discovering tests from the
command line and controlling how they are run:Support for importing tests by directory, filename, or module.Support for specifying tests to skip, tests to run in parallel,
and tests that need to be run by themselvesSupport for producing traces of test times compatible with Chrome’s
tracing infrastructure (trace_viewer).Integrated test coverage reporting (including parallel coverage).Integrated support for debugging tests.Support for uploading test results automatically to a server
(useful for continuous integration monitoring of test results).An abstraction of operating system functionality called the
Host class. This can be used by other python code to write more
portable and easily testable code by wrapping the multiprocessing,
os, subprocess, and time modules.Simple libraries for integrating Ninja-style statistics and line
printing into your own code (the Stats and Printer classes).Support for processing arbitrary arguments from calling code to
test cases.Support for once-per-process setup and teardown hooks.(These last two bullet points allow one to write tests that do not require
Python globals).Historytyp originated out of work on the Blink and Chromium projects, as a way to
provide a friendlier interface to the Python unittest modules.Work remainingtyp is still a work in progress, but it’s getting close to being done.
Things remaining for 1.0, roughly in priority order:Implement a non-python file format for testing command line interfacesWrite documentationPossible future workMainTestCase.check() improvements:check all arguments and show all errors at once?make multi-line regexp matches easier to follow?–debugger improvements:make it skip the initial breakpoint?Support testing javascript, java, c++/gtest-style binaries?Support for test sharding in addition to parallel execution (so that
run-webkit-tests can re-use as much of the code as possible)?Support for non-unittest runtest invocation (for run-webkit-tests,
other harnesses?)
Package: typar
typarA fully-typed combinatorial parsing library in Python.InstallationpipinstalltyparExampleExecutepython -m typar.exampleto run the example below:importtyparyear=typar.regex("[0-9]{4}")month=typar.regex("[0-9]{2}")day=typar.regex("[0-9]{2}")dash=typar.string("-")fulldate=year+dash+month+dash+day<<typar.eof()print(fulldate.parse("2019-01-01"))# Result(index=10, value=(((('2019', '-'), '01'), '-'), '01'))print(fulldate.parse("2019-01-01x"))# Result(index=10, value=<ERR>)
Package: typarse
TyparseThis is a small project born out of my frustration with simple argument parsing in Python.Not only do I have to instantiate some object whose name I can never remember, then I get way too many
function parameters to get them right... It's a mess. And I don't even need half the features.So this is an attempt at streamlining this process while simultaneously promoting some better type safety, by using the
magic of Python type hints!Really all the magic here is happening in the BaseParser class. You just need to subclass it, add a few typed parameters,
perhaps with some extra information in dictionaries... and you're done! For examples, just look at, well, examples.Supported typesFirst of all, all the basic types supported by argparse are also supported here. Things like:str,int,float.bools are automatically interpreted as flags, False by default. Each type can be wrapped in aListto support reading them like--list 1 2 3 4. Each type can also be madeOptionalwhich makes it, well, optinal.Simple illustrative examplefromtyparseimportBaseParserfromtypingimportListclassParser(BaseParser):nums:List[int]square:booldefault:int=0_abbrev={"nums":"n","square":"s","default":"d"}_help={"nums":"List of numbers to sum","square":"Whether the result should be squared","default":"Initial value, added to the sum"}args=Parser()print(args.default+sum(args.nums)**(1+args.square))Functionality 2: ConfigIn the spirit of the library, I added a config management component.
Similarly to parsing, you can define a config using type annotations on a class -- also in a nested manner.Example:fromtyparseimportBaseConfigfromtypingimportListclassConfig(BaseConfig):rate:float=0.1amount:float=0.01limit:float=1.classPolicyConfig(BaseConfig):layers:List[int]=[32,32,32]activation:str="relu"config={"rate":0.5,"PolicyConfig":{"layers":[64,64]}}InstallationIt's on PyPi so install it withpip install typarse,poetry add typarseor whatever you want. If you want to install it from the source, it's pure Python so I'm sure you can figure it out.
Package: type2fuzzy
Type2Fuzzy ProjectA type-2 fuzzy logic library providing:Ways to define and work with general type-2 fuzzy setsWays to define and work with interval type-2 fuzzy setsWays to generate z-sliced sets from general type-2 fuzzy setsFunctions to perform wavy-slice type-reduction (Mendel-John) on general type-2 fuzzy setsFunctions to perform interval type-2 reduction (Karnik-Mendel)Functions to perform partial-centroid type-reduction on general type-2 fuzzy setsFunctions to perform defuzzification of type-1 fuzzy setsTools to measure the performance of algorithmsTools to plot general, interval and z-sliced type-2 fuzzy sets and type-1 fuzzy sets and moreWays to define and work with type-1 fuzzy setsWays to define and work with type-1 linguistic variablesand moreAll type2fuzzy wheels distributed on PyPI are BSD licensed.Examples of how this library was used to work some famous type-2 fuzzy logic papers can be foundhere.WebsiteThe official website for this library can be foundhere.Change Historyversion 0.1.49 - 04.04.2022updated numpy and matplotlib versionsversion 0.1.48 - 04.04.2022Renamed add_element in IntervalType2FuzzySet to add_element_from_crispsetAdded add_element_from_values to IntervalType2FuzzySetversion 0.1.43 - 11.03.2020new version of documentation in htmlversion 0.1.42 - 11.03.2020type-1 fuzzy variable implementedstrtype-1 fuzzy variable implemented get_settype-1 fuzzy variable add_triangular_set returns created setversion 0.1.41 - 10.03.2020Type-1 fuzzy set has a name attribute and a name propertyType-1 fuzzy variable has a name attribute and a name propertyUnit tests for aboveversion 0.1.39 - 09.03.2020added type-1 fuzzy variableversion 0.1.37 - 07.03.2020Fixed bugs in creation of type-1 fuzzy setsMoved project in a virtualenvAdded more type-1 fuzzy set unit testsversion 0.1.36 - 18.02.2020Added generation of triangular type-1 sets unit test. Removed extended methodversion 0.1.35 - 18.02.2020Fixed bug in generation of triangular type-1 setsversion 0.1.34 - 18.11.2019Ability tocreate Interval Type-2 fuzzy sets having a gaussian function with fixed mean and fixed standard deviationas per Karnik and Mendel 1996 - Karnik, Nilesh N., and Jerry M. Mendel. "Introduction to type-2 fuzzy logic systems." 1998 IEEE International Conference on Fuzzy Systems Proceedings. IEEE World Congress on Computational Intelligence (Cat. No. 98CH36228). Vol. 2. IEEE, 1998.An experimental way todefine General Type-2 fuzzy sets through horizontal slicesversion 0.1.33 - 15.11.2019Updated repo informationversion 0.1.32 - 15.11.2019Get domain limits for a type-1 fuzzy setversion 0.1.31 - 12.11.2019Added librarywebsiteConvert a gt2fs into an it2fs-An it2fs can be generated form a gt2fs by using from_general_type2_setCreation of it2fs as found in literature-Creation of it2fs as specified by Karnik and Mendel
Package: type3detect
Type III Radio Burst Automatic Recognition AlgorithmThe automatic recognition of the Type III radio burst using Hough Transform.InstallationPythoninstall from pypipipinstalltype3detectinstall from gitgitclonehttps://github.com/peijin94/type3detect.gitcdsrc/python
pythonpipinstall.Matlab:gitclonehttps://github.com/peijin94/type3detect.gitcdsrc/matlabExampleRead fits file and detect type III radio bursts in dynamic spectrum.importmatplotlib.datesasmdatesimportmatplotlib.pyplotaspltimportnumpyasnpfromtype3detectimportdetectRadioburstasdrbfromtype3detectimportradioToolsasrtfname='./LOFAR_20220701_070000_LBA_OUTER_S0.fits'# preprocess(dyspec,t_fits,f_fits,hdu)=drb.read_fits(fname)# read LOFAR dynspec fits(dyspec,f_fits)=drb.cut_low(dyspec,f_fits,f_low_cut_val=30)# remove below freq (RFI)(data_fits_new,data_fits_new_smooth)=drb.preproc(dyspec,gauss_sigma=1.5)# binarizationbmap=drb.binarization(data_fits_new,N_order=6,peak_r=1.002)# detect verticle featureslines=drb.hough_detect(bmap,dyspec,threshold=40,line_gap=10,line_length=30,theta=np.linspace(np.pi/2-np.pi/8,np.pi/2-1/180*np.pi,300))line_sets=drb.line_grouping(lines)# get electron beam information from radio bursts(v_beam,f_range_burst,t_range_burst,model_curve_set,t_set_arr_set,f_set_arr_set,t_model_arr,f_model_arr)=drb.get_info_from_linegroup(line_sets,t_fits,f_fits)# detailed demo in ./type3detect_demo.ipynbExample: Implementation with for LOFAR dynamic spectrum.Demo Notebook:type3detect_demo.ipynbBinarizationUse several ways to transform the flux intensity data into binary. (LocalMax(matlab)) (binarization(Python))Active-Contour method for BackboneThe Active Contour Method for the backbone of the radio burst (ACBone)Take the result of the Hough transform as a initail position and iteratively move the line to find the backbone position. The demo code : (ACBone-Matlab,ACBone-Python)Eventually, we can obtain the centerline of a Type III radio burst.CitationMake sure to cite the paper if you use the idea or code in this repo:A type III radio burst automatic analysis system and statistic results for a half solar cycle with Nançay Decameter Array dataPeijin Zhang. A&A 2018.10bibtex:@article{zhang2018type,
  title={A type III radio burst automatic analysis system and statistic results for a half solar cycle with Nan{\c{c}}ay Decameter Array data},
  author={Zhang, PJ and Wang, Chuan Bing and Ye, Lin},
  journal={Astronomy \& Astrophysics},
  volume={618},
  pages={A165},
  year={2018},
  publisher={EDP Sciences}
}
Package: type-annotations-generator
type-annotations-generatortype-annotations-generator provides a function for generating type annotations. That can be useful if you work with a API which has a complex data structure.
It supportsPEP 585andPEP 604.importtype_annotations_generatordata={"elements":[{"name":"foo","age":42}],"count":1}print(type_annotations_generator.generate_annotations(data))# Dict[str, Union[List[Dict[str, Union[str, int]]], int]]print(type_annotations_generator.generate_annotations(data,pep_585=True))# dict[str, Union[list[dict[str, Union[str, int]]], int]]print(type_annotations_generator.generate_annotations(data,pep_585=True,pep_604=True))# dict[str, list[dict[str, str | int]] | int]
Package: typeargs
Smarter positional argument handlingInstallationInstall via pip:$pipinstalltypeargsDone.If you insist on the (slightly) harder way of installing, from source,
you know how to do it already and don’t need my help.I might later upload the source to:https://github.com/TaylorSMarks/typeargsDocumentationWhen you call an ordinary Python function, it blindly passes in your positional arguments, and then it passes in your keyword arguments.Suppose you had a function with a signature like this, as is the case for many things in Tkinter:defmakeWidget(master=None,contents='',x=0,y=0,xSpan=1,ySpan=1):You want to call this function now, without specifying a master. Here are your options normally:makeWidget(None,'This is impossible to read.',5,7,2,2)Quick! Without looking at the signature, what the heck are those numbers at the end? Normally you solve it with this:makeWidget(s='Better, but so much typing...',x=5,y=7,xSpan=2,ySpan=2)Now that you include all the names, it’s easier to tell what each argument is, but its so verbose… it’s kind of heavy.This is where typeargs comes in. If you go back to the original function and decorate it with typeargs as such:@typeargs(Master,str,int,int,int,int)defmakeWidget(master=None,s='',x=0,y=0,xSpan=1,ySpan=1):Now a caller can just type this:makeWidget('Hello World!',2,2,x=5,y=7)Okay now, what’s what? Obviously our string is Hello World!, x is 5, y is 7, and we have two more arguments of ints. Those must be xSpan and ySpan, and no master was included, so it’ll use the default None.By intelligently handling positional arguments based on their types, you can skip over arguments you want default values for, without using key-word arguments for every name.Another example - lets say that you want to pass in master at the end:makeWidget('Hello World!',2,2,x=5,y=7,master=Master('Window'))makeWidget('Hello World!',2,2,Master('Window'),x=5,y=7)Either one will work - we’re just making argument delivery just a bit smarter than normal.One more example, new in 1.1.0, you can now match string arguments using regular expressions, if you want. No need to define the re objects in advance - they can be right in the decorator call if you want.fromtypeargsimportre,typeargsphoneNumber=re(r'\d{3}-\d{4}')ssn=re(r'\d{3}-\d{2}-\d{4}')fullName=re(r'\w+ \w+')@typeargs(fullName,ssn,phoneNumber)definfos(fullName,ssn,phoneNumber):print(fullName,ssn,phoneNumber)infos('752-2723','Taylor Marks','123-45-6789')# Prints out ('Taylor Marks', '123-45-6789', '752-2723')CopyrightThis software is Copyright (c) 2016 Taylor Marks <taylor@marksfam.com>.See the bundled LICENSE file for more information.
Package: type-asserter
Type Asserter: A tool to typeThis package enforces the functions'type hintsat runtime, making sure that the types of the actual parameters and the return value match the types specified in the function signature.InstallationThe source code is currently hosted on GitHub at:https://github.com/ValerioNeriGit/type_asserterBinary installers for the latest released version are available at the Python package index.pip3installtype_asserterUsageDefine your function using the Python3.8 type hints and add the@enforce_type_hintsdecoratorfromtype_asserterimportenforce_type_hints@enforce_type_hintsdefpower(num:int,pow:int,verbose:bool=False)->int:result=num**powifverbose:print("The result is:",result)returnresultpower(3,4,verbose=True)When one or more type mismatches are found, for each mismatched parameter is shown its name (as in the function's signature, its expected type, and its actual type:TypeError: Parameter's type mismatch
   Parameter's name: num, expected: <class 'int'> but got: <class 'str'>
   Parameter's name: pow, expected: <class 'int'> but got: <class 'str'>PerformanceThe package endeavors to impact as little as possible on the performance of your program, but still, it introduces some overhead.You can disable the type check in order to maximize performance settingdisable=Trueas in the example belowIf you want to disable the type check forfromtype_asserterimportenforce_type_hints@enforce_type_hints(disable=True)defpower(num:int,pow:int)->int:returnnum**powShow a warning instead of an errorIt is possible to setwarning_instead_of_error=Truein order to have a non-interrupting warning instead of a TypeError, as in the example below.fromtype_asserterimportenforce_type_hints@enforce_type_hints(warning_instead_of_error=True)defpower(num:int,pow:int)->int:returnnum**powAuthorValerio Neri-github
Package: typebuf
TypeBufDead simple way to create shared type definitions between applicationsOther tools have too much setup? Too much boilerplate? Do too much "magic"? Just:Define your Types intypes.yamlRun TypeBuf:$ typebuf compile -f types.yaml -l python -l typescriptInstallpip install typebufpoetry add --dev typebufQuickstartCreate a file calledtypes.yaml, it can be anywhere in your project repoAdd the following lines to the newly created file:---
typedefs:
  - typename: User
    imports:
      python:
        - 'from typing import Optional'
    fields:
      - name: first_name
        type: string
      - name: age
        type: int
        optional: trueNow call TypeBuf with:$ typebuf compile -l python -l typescriptYou now have two new files, one calleduser.pyand one calleduser.tsthat can you use for
things like data serialization/deserialization, validation, subclassing, etcGenerated Python:"""User type definition file generated by TypeBufNote: Any changes made to this file will be overwrittenduring next compilation"""fromtypingimportOptionalclassUser:first_name:strage:Optional[int]Generated TypeScript:/*** User type definition file generated by TypeBuf* Note: Any changes made to this file will be overwritten*       during next compilation*/interfaceUser{first_name:string;age?:number;}Note: So far only Python and TypeScript are supported. More languages coming soon!DemoHere's a quick demo of me using TypeBuf 0.1.1. First I show the contents of thetypes.yamlfile
then I generate Python and TypeScript source code and show the contents of the new filesDocumentationInsidetypes.yamlthere is an array calledtypedefs. This is where you add your shared type definitionsEach type can have the following fields (required fields inbold):typename:stringimports:map[string, array[str]]fields:array[Field]AFieldhas the following attributes:name:stringtype:stringoptional:booleanIn a type definition you can also specify custom/requiredimportsfor any depedencies your classes may need:typedefs:
  - typename: Address
    imports:
      python:
        - 'from mymodule.user import User'
        - 'from typing import Optional'
      typescript:
        - 'import { User } from "./User";'
    fields:
      - ...,