Saravanan666/pypi-org huggingface dataset:
Package: twirp
TwirpyPython implementation of Twirp RPC framework (supportsTwirp Wire Protocol v7).This repo contains a protoc plugin that generates sever and client code and a pypi package with common implementation details.For details about the twirp project, checkhttps://github.com/twitchtv/twirpInstallationGrab the protoc plugin to generate files withgo get -u github.com/verloop/twirpy/protoc-gen-twirpyAdd the twirp package to your projectpip install twirpYou'll also needuvicornto run the server.Generate and runUse the protoc plugin to generate twirp server and client code.We'll assume familiarity with the example from the docs.https://twitchtv.github.io/twirp/docs/example.htmlprotoc --python_out=./ --twirpy_out=./ ./haberdasher.protoServer code# server.pyimportrandomfromtwirp.asgiimportTwirpASGIAppfromtwirp.exceptionsimportInvalidArgumentfrom.importhaberdasher_twirp,haberdasher_pb2classHaberdasherService(object):defMakeHat(self,context,size):ifsize.inches<=0:raiseInvalidArgument(argument="inches",error="I can't make a hat that small!")returnhaberdasher_pb2.Hat(size=size.inches,color=random.choice(["white","black","brown","red","blue"]),name=random.choice(["bowler","baseball cap","top hat","derby"]))# if you are using a custom prefix, then pass it as `server_path_prefix`# param to `HaberdasherServer` class.service=haberdasher_twirp.HaberdasherServer(service=HaberdasherService())app=TwirpASGIApp()app.add_service(service)Run the server withuvicorn twirp_server:app --port=3000Client code# client.pyfromtwirp.contextimportContextfromtwirp.exceptionsimportTwirpServerExceptionfrom.importhaberdasher_twirp,haberdasher_pb2client=haberdasher_twirp.HaberdasherClient("http://localhost:3000")# if you are using a custom prefix, then pass it as `server_path_prefix`# param to `MakeHat` class.try:response=client.MakeHat(ctx=Context(),request=haberdasher_pb2.Size(inches=12))print(response)exceptTwirpServerExceptionase:print(e.code,e.message,e.meta,e.to_dict())Twirp Wire Protocol (v7)Twirpy generates the code based on the protocol v7. This is a breaking change from the previous v5 and you can see the changeshere.This new version comes with flexibility to use any prefix for the server URLs and defaults to/twirp. To use an empty prefix or any custom prefix like/my/custom/prefix, pass it as aserver_path_prefixparam to server and clients. Check the example directory, which uses/twirpyas a custom prefix.If you want to use the server and clients of v5, then use the0.0.1release.Message Body LengthCurrently, message body length limit is set to 100kb, you can override this by passingmax_receive_message_lengthtoTwirpASGIAppconstructor.# this sets max message length to be 10 bytesapp=TwirpASGIApp(max_receive_message_length=10)Support and communityPython:#twirp. Join Python community slackhereGo:#twirp. Join Gophers community slackhereStanding on the shoulders of giantsThe initial version of twirpy was made from an internal copy ofhttps://github.com/daroot/protoc-gen-twirp_python_srvTherun_in_threadpoolmethod comes fromhttps://github.com/encode/starlette
Package: twiss
twiss, 2022-2023Coupled twiss parameters (Wolski twiss matrices) computation for arbitrary even dimension.Install & build$ pip install git+https://github.com/i-a-morozov/twiss.git@mainor$ pip install twiss -UDocumentationhttps://i-a-morozov.github.io/twiss/TwissCompute tunes, normalization matrix and twiss matrices.>>>frommathimportpi>>>importtorch>>>fromtwiss.matriximportrotation>>>fromtwiss.wolskiimporttwiss>>>m=rotation(2*pi*torch.tensor(0.88,dtype=torch.float64))>>>t,n,w=twiss(m)>>>ttensor([0.8800],dtype=torch.float64)>>>ntensor([[1.0000,0.0000],[0.0000,1.0000]],dtype=torch.float64)>>>wtensor([[[1.0000,0.0000],[0.0000,1.0000]]],dtype=torch.float64)Input matrices can have arbitrary even dimension.>>>frommathimportpi>>>importtorch>>>fromtwiss.matriximportrotation>>>fromtwiss.wolskiimporttwiss>>>m=rotation(*(2*pi*torch.linspace(0.1,0.9,9,dtype=torch.float64)))>>>t,n,w=twiss(m)>>>ttensor([0.1000,0.2000,0.3000,0.4000,0.5000,0.6000,0.7000,0.8000,0.9000],dtype=torch.float64)Can be mapped over a batch of input matrices.>>>frommathimportpi>>>importtorch>>>fromtwiss.matriximportrotation>>>fromtwiss.wolskiimporttwiss>>>m=torch.func.vmap(rotation)(2*pi*torch.linspace(0.1,0.9,9,dtype=torch.float64))>>>t,n,w=torch.func.vmap(twiss)(m)>>>ttensor([[0.1000],[0.2000],[0.3000],[0.4000],[0.5000],[0.6000],[0.7000],[0.8000],[0.9000]],dtype=torch.float64)Can be used to compute derivatives of observables.>>>frommathimportpi>>>importtorch>>>fromtwiss.matriximportrotation>>>fromtwiss.wolskiimporttwiss>>>deffn(k):...m=rotation(2*pi*torch.tensor(0.88,dtype=torch.float64))...i=torch.ones_like(k)...o=torch.zeros_like(k)...m=m@torch.stack([i,k,o,i]).reshape(m.shape)...t,*_=twiss(m)...returnt>>>k=torch.tensor(0.0,dtype=torch.float64)>>>fn(k)tensor([0.8800],dtype=torch.float64)>>>torch.func.jacfwd(fn)(k)tensor([0.0796],dtype=torch.float64)
Package: twissed
TwissedOverviewTwissed is a Python package 🐍 that provides a large number of data analysis tools forbeam dynamicsandlaser wakefield accelerationsimulations.Twissed is multi-OS (Windows, Linux, Mac) and can be easily installed everywhere thanks to its low number of dependencies (numpy, pandas, scipy, h5py). It is especially made to run on HPC clusters.Twissed can read and write data from several sourcesFBPICSmileiSmilei via happi packageTraceWinAstraInstallationRequirementPython 3.7 or greaterMandatory packages: numpy pandas scipy h5py.Optional packages: matplotlib seaborn happi(smilei)InstallationAfter downloading the project:Mac OS/Linuxpython-mpipinstall-e.Windowspy-mpipinstall-e.TutorialExamples Twissed use are available athttps://github.com/Twissed/Twissed_tutorialMIT LicenseCopyright (c) 2024 TwissedPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Package: twissreader
TwissReaderRead Twiss files produced by MAD and converts it to dictionary and pandas-dataframe.For examples see theexamples.ipynb - notebookincluded in the repository.InstallationYou can install the TwissReader-module from PyPI using pip, which adds the module to your python environment:pip install twissreaderIf you want to add the twissreader to your project and don't want to require twissreader module installed in the python environment,
copy the twissreader folder in your project folder.
Package: twisstool
Python Twiss ToolThis tool can be used to read any table produced by MAD-X, not only twiss tables.InstallationIn a terminal runpipinstalltwisstoolUsagefromtwisstoolimporttwisstw=twiss('madxTableFile.txt')The created instance of twiss namedtwcontains (at least) two attributes:headercontaining a list of the columns found in the filedatacontaining a pandas dataframe containing the data found in the columnsany global parameter found in the headerIf one would want to plot $\beta_x$ as a function of $s$, one could do:importmatplotlib.pyplotaspltplt.plot(tw.data['S'],tw.data['BETX'])plt.show()Or you can use the following:tw.plot('S','BETX')
Package: twistedchecker
TwistedChecker checks Python code for compliance with theTwisted coding
standard <https://twistedmatrix.com/documents/current/core/development/policy/coding-standard.html>.This was originally a project of Google Summer of Code 2012.TwistedChecker’s dependencies are recorded in setup.py.DevelopmentGet a development environment:virtualenv build
. build/bin/activate
pip install -Ue '.[dev]'To test twistedchecker, run the following in the source directory:trial twistedcheckerCheck pyflakes status ignoring functional tests
(#68 some day we might use twistedchecker on itself):python check_pyflakes.py twistedchecker/Releasing a new version is done via Travis-CI.
First commit the version update in a master and wait for test to pass.
Create a tag on local branch and then push it:git tag 1.2.3
git push --tags
Package: twisted-dev-tools
Install`shell pip installtwisted-dev-tools`Examples`shellfetch-ticket<ticket-number>review-ticketsget-attachmentget<ticket-number># Gets latest attachment from tickettch-ticketworks :)get-attachmentapply<ticket-number># Gets latest attachment from ticket, applies it to the current git reposiory, and commits it with an appropriate message. mkbranch<branch-name># Creates an svn branch with the given nameforce-build#Force-buildsthe current git branch, assuming it has been push'd (with dcommit) to svn `
Package: twisted-fate
twisted_fateA python api wrapper to for riot's Legends of Runterra client-api including a port ofRiot Games C# implementation of the deck encoder/decoderInstallpip install twisted_fateUsageCreate Deck from deck codefromtwisted_fateimportDeckdraven_deck=Deck.decode("CEBAGAIDCQRSOCQBAQAQYDISDQTCOKBNGQAACAIBAMFQ")# resultsprint(deck.cards)#[#    Card(01NX020, Name: Draven, Cost: 3),#    Card(01NX035, Name: Draven's Biggest Fan, Cost: 1),#    Card(01NX039, Name: Vision, Cost: 3),#    Card(01PZ001, Name: Rummage, Cost: 1),#    Card(01PZ012, Name: Flame Chompers!, Cost: 2),#    Card(01PZ013, Name: Augmented Experimenter, Cost: 6), #    Card(01PZ018, Name: Academy Prodigy, Cost: 2),#    Card(01PZ028, Name: Jury-Rig, Cost: 1),#    Card(01PZ038, Name: Sump Dredger, Cost: 2),#    Card(01PZ039, Name: Get Excited!, Cost: 3),#    Card(01PZ040, Name: Jinx, Cost: 4),#    Card(01PZ045, Name: Zaunite Urchin, Cost: 1),#    Card(01PZ052, Name: Mystic Shot, Cost: 2),#    Card(01NX011, Name: Whirling Death, Cost: 3)# ]Create Deck from cards list, (in the format of a response from the client api)fromtwisted_fateimportDeck# client api responsedeck={"DeckCode":"CEBAGAIDCQRSOCQBAQAQYDISDQTCOKBNGQAACAIBAMFQ","CardsInDeck":{"01NX020":3,"01NX035":3,"01NX039":3,"01PZ001":3,"01PZ012":3,"01PZ013":3,"01PZ018":3,"01PZ028":3,"01PZ038":3,"01PZ039":3,"01PZ040":3,"01PZ045":3,"01PZ052":3,"01NX011":1,},}draven_deck=Deck(cards=deck["CardsInDeck"])print(draven_deck.encode().deck_code)# result: CEBAGAIDCQRSOCQBAQAQYDISDQTCOKBNGQAACAIBAMFQ# orprint(draven_deck.to_deck_code())# result: CEBAGAIDCQRSOCQBAQAQYDISDQTCOKBNGQAACAIBAMFQ
Package: twistedinput
# twistedinput### Reading input devices using [Twisted](http://twistedmatrix.com/trac/) frameworkTwisted is Python2 for asynchronous IO operations and event driven programming.Twistedinput is library for this framework for interacting input devices, suchas gamepads, joysticks, mouses and etc in asynchrounous fashion.An input event is represented by standar input_event structure defined inlinux/input.h header file.Communication protocol is intended for handling only those event, which you areinterested to.```pyconfrom twistedinput.device import EventDevicefrom twistedinput.protocol import EventProtocolfrom twistedinput.factory import InputEventFactoryfrom twistedinput.mapping import GamepadEventMappingfrom twisted.internet import reactorclass MyGamepad(EventProtocol):def button1(self, event):"""handle only button 1"""print "button 1:", event.valueEventDevice(MyGamepad(InputEventFactory(),GamepadEventMapping()),"/dev/input/event13").startReading()reactor.run()```### Event MappingAccordint to linux/input.h header file. any input event consists from fourfields:* timestamp* type* code* valueType and code constanc decribes inputs, which can vary device from device.For example, when I press button 1 on my gamepad, input_event with type EV_KEYand code BTN_TRIGGER. But I pressed buttin 1, not trigger.Event mapping basicyl allows you to write a driver for your device. Mapping simplydefines, that event with type EV_KEY and code BTN_TRIGGER should be handled inbutton1 method. For different device you can define different event mappingsand handle event by methods with logic names.If handler method defined in the used mapping doesn't exist in the protocol,event is ignored.### Handling Event Without Aid of MappingIn the EventProtocol constructor eventMapping is optional parameter. If isomnited, you have to override eventReceived method and handle event by yourself.### Event FactoryFactory is simple object which takes bytes representing data stream emmited byevent and returns object represnting this event.It also provides information of size of the event.
Package: twisted.internet.processes
IntroductionThe Python Global Interpreter Lock (GIL) poses some limitations on multi
processor performance by locking on all pure Python code. Although the
threading support in twisted is excellent, the GIL was holding back performance
by essentially keeping the process bound to a single CPU.In order to get around the GIL, Python brought in the multiprocessing package
as of version 2.6. The multiprocessing package has been backported to both
Python 2.4 and 2.5 and is available from the Python Package Index
(http://pypi.python.org/pypi). The multiprocessing package provides a similar
interface to the threading libraries provided by Python except that it uses
processes instead of threads.This package, twisted.internet.processes, implements a wrapper around the
multiprocessing library and provides a method, deferToProcess, that works
in the same manner as deferToThread.ImplementationA process pool is created on the reactor in the same manner that the thread
pool is created in the normal reactor when deferToThread is first called.Initially, the goal was to use the non-blocking code and callbacks from the
multiprocessing library to provide a deferToProcess method. Unfortunately,
the multiprocessing.Pool.apply_async does not call the callback in the event
of a failure. In order to retain failure callbacks, the get method from the
asynchronous result set, multiprocessing.pool.AsyncResult, is used by wrapping
it in a call to deferToThread. The thread is blocked while waiting on the
results from the call in a separate process.Using the multiprocessing.Pool.apply_async to defer to a process imposes some
additional requirements on the user code. All arguments and the function itself
must be pickleable by the Python cPickle module.LicenseCopyright 2009 Texas A&M UniversityLicensed under the Apache License, Version 2.0 (the “License”); you may not use
this file except in compliance with the License. You may obtain a copy of the
License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.Changelog1.0b1 2009/08/24Initial releaseLocked to multiprocessing 2.6.1.1 or below due to a bug in logging in 2.6.2.1No testing yetdeferToProcess based on a blocking call wrapped in deferToThread
Package: twisted-iocpsupport
An extension for use in the L{twisted.internet.iocpreactor} I/O Completion
Ports reactor.This code was initially part of the core Twisted project. It was moved into a
separate repo in order to simplify the Twisted production deployment. As such,
issues are handled via thetwisted/twisted GitHub Issues systemAdditionally, this package provides no compatability gurantees:
All use must be via theTwistedPyPI distribution andtwistedPython package.
Applications must not depend on thetwisted-iocpsupportPyPI distribution directly.
Applications must not import names from thetwisted_iocpsupportpackage directly.
See theTwisted Compatability Policyfor more info.
Package: twisted-ipython
twisted_ipythonAnIPythonextension that usescrochetto enable runningTwistedin IPython andJupyternotebooks.The Short Short VersionInstall this package into your Jupyter notebook's kernel. Then, load the extension:%load_ext twisted_ipythonand then turn on autoawait for Twisted:%autoawait twistedand with a helper for the demofromtwisted.internetimportreactorfromtwisted.internet.deferimportDeferreddefsleep(t):d=Deferred()reactor.callLater(t,d.callback,None)returndwe can now use async/await in cells like so:print('Going to sleep...')awaitsleep(1)print('I HAVE AWAKENED!')I Want To Know More!Check out the much more completeREADME.ipynb!
Package: twistedschedule
MotivationTwisted provides excellent support for creating delayed calls and looping calls,
but when a daemon runs for extended periods of time, it is often necessary to
schedule tasks to run in a manner that would be more easily described by a
schedule instead of a number of seconds delay. The twistedschedule module
provides an interface for describing a schedule and a single implementation, a
subset of the cron schedules from linux/Unix. In order to use these schedules,
a ScheduledCall class has been created that acts like the
twisted.internet.task.LoopingCall class. In the future, an extension of the
twisted.application.internet.TimerService may be provided that would use the
ScheduledCall instead of LoopingCall to provide a similar service.CronThe cron syntax used follows the crontab syntax listed on the Wikipedia page
with the exceptions of the names of the days of the week which is not supported
and the shortcuts which are also not supported.http://en.wikipedia.org/wiki/Cron1.0b1twistedschedule.task.ScheduledCall completedtwistedschedule.cron.CronSchedule completedunittests added for twistedschedule.task.ScheduledCallunittests added for twistedschedule.cron0.1Planning phase. A few different ideas were tested before deciding upon the
current implementation.
Package: twisted.scheduling
NoteThis package has been renamed to TxScheduling.IntroductionTwisted provides excellent support for creating delayed calls and looping calls,
but when a daemon runs for extended periods of time, it is often necessary to
schedule tasks to run in a manner that would be more easily described by a
schedule instead of a number of seconds delay. The twisted.scheduling module
provides an interface for describing a schedule and a single implementation, a
subset of the cron schedules from linux/Unix. In order to use these schedules,
a ScheduledCall class has been created that acts like the
twisted.internet.task.LoopingCall class. In the future, an extension of the
twisted.application.internet.TimerService may be provided that would use the
ScheduledCall instead of LoopingCall to provide a similar service.CronThe cron syntax used follows the crontab syntax listed on theWikipedia pagewith the exceptions of the names of the
days of the week which is not supported and the shortcuts which are also not
supported.Changelog1.0 (2010/06/02)Rename package to twisted.schedulingCleaned up code and added some more error handlingCleaned up test code1.0b1 (2008/12/10)twistedschedule.task.ScheduledCall completedtwistedschedule.cron.CronSchedule completedunittests added for twistedschedule.task.ScheduledCallunittests added for twistedschedule.cron0.1 (Unreleased)Planning phase
Package: twisted-theseus
twisted-theseusADeferred-aware profiler for Python code.WhilecProfileis a very useful utility,
it is limited to recordingsynchronousexecution time.
A function that returns a Deferred will typically return very quickly,
while the Deferred it returns might not fire for seconds or even minutes.
This is where theseus comes in:
any function that returns a Deferred will be tracked by theseus.
The time from when the Deferred was returned to when it fired will be measured,
and recorded along with the function’s call stack.UsageThe public interface of theseus is a class calledTracer.
To get started:from theseus import Tracer
t = Tracer()
t.install()This is enough to start tracing execution.
Eventually, the statistics will have to be written to disk:with open('callgrind.theseus', 'wb') as outfile:
  t.write_data(outfile)The output is written incallgrind format,
which means that standard tools can be used to interpret the results,
such askcachegrind.If at any point theTraceris no longer useful,
it can be uninstalled to stop tracing:t.uninstall()Additionally,
theseus is aware ofinlineCallbacks,
and will rewrite call stacks to make them look “correct”.
For example,
given this code:from twisted.internet import defer, task

@defer.inlineCallbacks
def func(reactor):
  yield task.deferLater(reactor, 1, lambda: None)

task.react(func)The call stack according to theseus will look like this (most recent call last):__main__ in <module>
twisted.internet.task in react
__main__ in funcWhile theseus and cProfile both use aprofile hook,
as long as cProfile is installed first,
both profilers can be used at the same time.
In this case,
callinguninstall()will restore cProfile.
Package: twister2
Twister2Twister2 is a composable big data environment supporting streaming, data pipelines and analytics. Our
vision is to build robust, simple to use data analytics solutions that can leverage both clouds and
high performance computing infrastructure.We started the project with the vision described in the paperTwister2 Design of a Big Data Toolkit.The documentation is found athttps://twister2.org/ContactWe are a global open community welcoming contributions to the project in any form.Mailing ListTwister2 Google Groups:twister2@googlegroups.comSlack ChannelTwister2 Slack Channel:https://dsc-twister.slack.comLicenseLicensed under the Apache License, Version 2.0:http://www.apache.org/licenses/LICENSE-2.0
Package: twister-game
Twister is a simple python application that allows you to play the infamous
Twister game [1].You just need to paint some tails in the floor and this small application will
act as the spinner.To use it simply call the script and pass the names of the players as arguments.See:https://asciinema.org/a/HHWdrYa8rM1WIIrzyGmUdus1HHave a lot of fun![1]https://en.wikipedia.org/wiki/Twister_(game)