Saravanan666/pypi-org huggingface dataset:
Package: pthflops
pytorch-estimate-flopsSimple pytorch utility that estimates the number of FLOPs for a given network. For now only some basic operations are supported (basically the ones I needed for my models). More will be added soon.All contributions are welcomed.InstallationYou can install the model using pip:pipinstallpthflopsor directly from the github repository:gitclonehttps://github.com/1adrianb/pytorch-estimate-flops&&cdpytorch-estimate-flops
pythonsetup.pyinstallNote: pytorch 1.8 or newer is recommended.Exampleimporttorchfromtorchvision.modelsimportresnet18frompthflopsimportcount_ops# Create a network and a corresponding inputdevice='cuda:0'model=resnet18().to(device)inp=torch.rand(1,3,224,224).to(device)# Count the number of FLOPscount_ops(model,inp)Ignoring certain layers:importtorchfromtorchimportnnfrompthflopsimportcount_opsclassCustomLayer(nn.Module):def__init__(self):super(CustomLayer,self).__init__()self.conv1=nn.Conv2d(5,5,1,1,0)# ... other layers present inside will also be ignoreddefforward(self,x):returnself.conv1(x)# Create a network and a corresponding inputinp=torch.rand(1,5,7,7)net=nn.Sequential(nn.Conv2d(5,5,1,1,0),nn.ReLU(inplace=True),CustomLayer())# Count the number of FLOPs, jit mode:count_ops(net,inp,ignore_layers=['CustomLayer'])# Note: if you are using python 1.8 or newer with fx instead of jit, the naming convention changed. As such, you will have to pass ['_2_conv1']# Please check your model definition to account for this.# Count the number of FLOPs, fx mode:count_ops(net,inp,ignore_layers=['_2_conv1'])
Package: pthogen
create a setup.cfg like:[metadata]
name = a-cool-name-here
version = 0.0.0a0

[options]
py_modules = a_cool_name_here
install_requires = pthogen

[options.entry_points]
pthogen =
    a_cool_name_here = a_cool_name_here:main

[bdist_wheel]
universal = 1and a_cool_name_here.py like:def main():
    # your cool interpreter startup hacks go here
Package: pthreading
Reimplement threading.Lock, RLock and Condition with libpthreadThe pthreading module provides Lock and Condition synchronization
objects compatible with Python native threading module.
The implementation, however, is based on POSIX thread library as delivered
by the libpthread. Lock and Condition are designed to be a drop-in
replacement for their respective threading counterpart.Take a look at threading.py of Python 2. Notice that Event.wait() wakes 20
times a second and checks if the event has been set. This CPU hogging has been
fixed in Python 3, but is not expected to change during Python 2 lifetime.To avoid this waste of resources, put in your main module:import pthreading
pthreading monkey_patch()This would hack the Linux-native threading module, and make it use Linux-native
POSIX synchronization objects.The pthreading code was originally written as part ofVdsmby Cyril Plisko, Saggi Mizrahi and
others. For questions, comments and patches please contactvdsm-devel.
Package: ptick-ptock
Ptick PtockSummaryA simple stopwatch imitating tool inspired by tic toc in MATLABHave you been a victim of scrutinous time calculation in python?The constant time subtractions and manipulations.....? I know.This library masks those steps for you; "abstracts it" as you would term it.Link to PyPiPtick-PtockProject TimelineInstallationUse the package managerpipto install ptick-ptock.pipinstallptick-ptockUsagefromptick_ptockimportptick_ptock# returns ptick-ptock objectobject=ptick_ptock()#starts time calculationobject.ptick()#returns elapsed timeobject.datetime_ptock()#prints elapsed timeobject.print_ptock()LicenseMIT* P.S. : The timeline was a joke 🤓 *
Package: ptiistild
PTIISTILDIIS Tilde Enumeration ToolInstallationpip install ptiistildAdd to PATHIf you cannot invoke the script in your terminal, its probably because its not in your PATH. Fix it by running commands below.Add to PATH for Bashecho"export PATH=\"`python3 -m site --user-base`/bin:\$PATH\"">>~/.bashrcsource~/.bashrcAdd to PATH for ZSHecho"export PATH=\"`python3 -m site --user-base`/bin:\$PATH\"">>~/.zshrcsource~/.zshrcUsage examplesptiistild -u https://www.example.com/
ptiistild -f url_list.txtOptions-u   --url         <url>           Connect to URL
-f   --file        <file>          Load urls from file
-g   --grabbing                    Grab/Bruteforce all the info
-s   --specials                    Add special characters to charset [!#$%&'()@^`{}]
-p   --proxy       <proxy>         Set proxy (e.g. http://127.0.0.1:8080)
-T   --timeout     <timeout>       Set timeout (default 15)
-c   --cookie      <cookie>        Set cookie
-ua  --user-agent  <ua>            Set User-Agent
-H   --headers     <header:value>  Set custom header(s)
-t   --threads     <threads>       Set number of threads (default 20)
-C   --cache                       Cache requests (load from tmp in future)
-v   --version                     Show script version and exit
-h   --help                        Show this help message and exit
-j   --json                        Output in JSON formatDependenciesrequests
validators
ptlibsVersion History1.0.2 - 1.0.3
    - Script improvements
1.0.0 - 1.0.1
    - Script improvements
    - Updated for latest ptlibs
0.0.1 - 0.0.2
    - Alpha releasesLicenseCopyright (c) 2023 Penterep Security s.r.o.ptiistild is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.ptiistild is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.You should have received a copy of the GNU General Public License along with ptiistild. If not, seehttps://www.gnu.org/licenses/.WarningYou are only allowed to run the tool against the websites which
you have been given permission to pentest. We do not accept any
responsibility for any damage/harm that this application causes to your
computer, or your network. Penterep is not responsible for any illegal
or malicious use of this code. Be Ethical!
Package: ptime
A tool for measuring serial and parallel execution, and comparing the results.
Provides anIPython magic%ptime.
This can be useful for measuring the benefits of parallelizing code, including
measuring the effect of theGlobal Interpreter Lock(GIL).ExampleIn [1]: %load_ext ptime

In [2]: import numpy as np

In [3]: x = np.ones((5000, 10000))

In [4]: %ptime x + x
Total serial time:   0.42 s
Total parallel time: 0.25 s
For a 1.67X speedup across 2 threads

In [5]: %ptime -n4 x + x  # use 4 threads
Total serial time:   0.82 s
Total parallel time: 0.31 s
For a 2.60X speedup across 4 threads

In [6]: res = %ptime -o x + x  # Get the result
Total serial time:   0.41 s
Total parallel time: 0.25 s
For a 1.66X speedup across 2 threads

In [7]: res.speedup
Out[7]: 1.6610825669011922

In [8]: %%ptime  # Use as a cell magic
...: x = np.ones((5000, 10000))
...: y = x + x
...:
Total serial time:   0.72 s
Total parallel time: 0.47 s
For a 1.54X speedup across 2 threadsInstallThis package is available via pip:pip install ptime
Package: ptimedelta
ptimedeltaConvert time periods represented by strings to timedelta objects and vice versa.FeaturesSupports Python2.7, Python3+.Supports time periods with days, hours, minutes, seconds, milliseconds.Installation$pipinstallptimedeltaExamples>>> import ptimedelta as ptd
>>> ptd.to_timedelta("12m34s")
datetime.timedelta(seconds=754)
>>> ptd.to_seconds("3h23m4s", as_int=True)
12184
>>> ptd.to_seconds("3.96ms")
0.00396
Package: ptimeit
ptimeitpretty timeit - simple and pretty python code profiler for measuring execution timepip install ptimeitexamplesfunction execution timeusetimeit_functiondecorator for measuring function execution timeimporttimefromptimeitimporttimeit_function@timeit_function('foo')deffoo():time.sleep(0.1)foo()outputs:->>>>>>>>         102.7ms      foo()Adding a conditional function that determines if something is printed. The function receives elapsed time in milliseconds as an input and is expected to return a boolean.importtimefromptimeitimporttimeit_function@timeit_function('foo',lambdat:t>500)deffoo():time.sleep(0.1)@timeit_function('bar',condition=lambdat:t>500)defbar():time.sleep(1)foo()bar()No output forfoo- measured time needs to be over 500ms to be printed.baroutputs:->>>>>>>>        1003.1ms      bar()Adding extra dataimporttimefromptimeitimporttimeit_function@timeit_function('foo',extra_data_to_print="This is a string")deffoo():time.sleep(0.1)foo()outputs:->>>>>>>>         103.3ms      foo() - This is a stringcode section execution timeusetimeit_sectioncontext manager for measuring code section execution timeimporttimefromptimeitimporttimeit_sectionwithtimeit_section('bar'):time.sleep(0.1)outputs:->>>>>>>>         105.1ms      barIt is also possible to use conditionalconditionfunction andextra_data_to_printthe same way as intimeit_function.nested mixture of functions and sectionsimporttimefromptimeitimporttimeit_function,timeit_section@timeit_function('foo_inner')deffoo_inner():withtimeit_section('foo_inner:section_1'):time.sleep(0.05)withtimeit_section('foo_inner:section_2'):time.sleep(0.25)@timeit_function('foo_outer')deffoo_outer():withtimeit_section('foo_outer:section_1'):time.sleep(0.2)foo_inner()withtimeit_section('foo_outer:section_2'):time.sleep(0.4)withtimeit_section('bar:outer'):foo_outer()time.sleep(0.1)outputs:->>>>>>>>         200.1ms      |   |   foo_outer:section_1
->>>>>>>>          51.3ms      |   |   |   foo_inner:section_1
->>>>>>>>         252.8ms      |   |   |   foo_inner:section_2
->>>>>>>>         304.3ms      |   |   foo_inner()
->>>>>>>>         403.0ms      |   |   foo_outer:section_2
->>>>>>>>         907.6ms      |   foo_outer()
->>>>>>>>        1010.8ms      bar:outer
Package: ptimeout
SynopsysThe ptimeout utility is a python script implementing an interface similar to
GNU timeout with the additional ability to terminate all processes launched
from the timeout session.In order to terminate all processes launched as part of the timeout
session, an environment variable is propagated along with processes creation.This heuristic enables terminations of detached processes even when
they are not anymore in the process parent-child tree.This also avoids the usage of process groups or process session leadership
which have some undesirable effect observed with timeout tools provided
with standard distributions. This approach is thus more transparent w.r.t.
to overall process management.The limitation to this approach is when some process reset its environment,
in which case it will not be tracked anymore (nor any of its child) by
the termination heuristic. In this case the sub-process tree may not
terminate as part of the timeout session.DownloadDownload the last stable version of the script from there:https://raw.githubusercontent.com/guillon/ptimeout/master/ptimeoutExamplesA typical usage of such a tool if for limiting the time of a batch job
which may fall into non terminating condition such as in validation
scripts or test processes.Also one generally expect the whole set of executed processes as part of
the job lifetime to be teminated when the job terminates, hence the
termination heuristic.Example of usage for limiting a batch script to 1 hour duration:$ ptimeout 3600 script.shBy default script.sh and all process executed from its process tree will
be terminated with SIGTERM after 3600 seconds, or killed by SIGKILL 10
seconds after if still persistent.If one wants only process garbage collection, use a timeout of 0 as in:$ ptimeout 0 script.shIn this case, the tool will not bound the execution time, but will still
garbage collect all processes when receiving an interrupting signal.The usage of ptimeout can be recursive and there is not side effect with
respect to interactive/sessions/tty modes.Get the command line help with:$ ptimeout --help
usage: ptimeout [-h] [-v] [-d] [-s SIGNAL] [-k KILL_AFTER] [-c CATCH_SIGNALS]
            [-l LIST] [-f FORMAT]
            [duration] [command] ...
....Build and InstallThis script requires python 2.6, 2.7 or 3.3+.The script can be used directly without installation.A makefile is provided anyway for completion and testing purpose.Build with:$ make all # a no-op actuallyRun unittests with:$ make checkInstall with, for instance:$ make install PREFIX=$HOME/local  # Default is PREFIX=/usr/localReferencesRefer to the project home page at:http://guillon.github.com/ptimeoutRefer to the current build and validation status at:https://travis-ci.org/guillon/ptimeout?branchesFill issues and enhancement request at:https://github.com/guillon/ptimeout/issuesLicenseThe tool is distributed under the GPLv2 license.Refer to the COPYING file:https://github.com/guillon/ptimeout/blob/master/COPYINGRefer to the COPYRIGHT file:https://github.com/guillon/ptimeout/blob/master/COPYRIGHT
Package: ptir
PTIR (Python Terminal Image Renderer)Installationpip install ptirUsageimportptirimage_path=...# Render the given imageptir.render(image_path)# Display entire 8-bit colour spaceptir.view8BitPalette()# Display entire 24-bit colour spaceptir.view24BitPalette()Documentationptir.render(image_path, width=100, height=100, interp_method='bilinear', only8Bit=False, only24Bit=False)image_path: Path to the image that will be renderedwidth: The width of the output (will be 2 *widthcharacters wide)height: The height of the output (will beheightcharacters tall)interp_method: Rescale interpolation method (Either 'bilinear' or 'nearest_neighbour')only8Bit: If True the image will be rendered without any 24-bit colouronly24Bit: If True the image will be rendered without any 8-bit colour. This mode is recommended to be used only if you are confident that the terminal will support 24-bit colour but are unsure if unicode characters are supported by the terminal fontNot all terminal windows support 24-bit colour (Visitthis websitefor more information on TrueColour support)The macOS default Terminal.app DOES NOT support 24-bit colour!By default the image will be rendered with two layers, 24-bit foreground to display properly on supporting terminals, and a 8-bit background to display if 24-bit colour is not availableExample #1Original:24-bit:8-bit:Example #2Original:24-bit:8-bit:Dependenciespillownumpy
Package: ptitprince
PtitPrinceA Python implementation of the "Raincloud plot"!
See:https://github.com/RainCloudPlots/RainCloudPlotsInstallationYou can install it viapip:pip install ptitprinceor viaconda:conda install -c conda-forge ptitprinceor by cloning this repository and running the following from the root of it:python setup.py installAcademic useTocite Raincloud plotsplease use the following information:Allen M, Poggiali D, Whitaker K et al. Raincloud plots: a multi-platform tool for robust data visualization [version 2; peer review: 2 approved]. Wellcome Open Res 2021, 4:63 (https://doi.org/10.12688/wellcomeopenres.15191.2)History of this projectThis is a Python version of the "Raincloud plot" (or "PetitPrince plot", depending on the orientation) from R (under ggplot2) to Python.
The Raincloud plot is a variant of the violin plot written in R ggplot2 byMicah Allen.
I found a tweet asking for a Python version of the Raincloud plot, and I agreed to give it a try.
Alas, the Python version for ggplot2 (plotnine) does not allow to create new styles in a comfortable way.
So I decided to write this package using theseabornlibrary as a foundation.Then I replicated the plots from the original post byMicah Allen, in Jupyter Notebooks and transformed that code into a Python package.Since then, the package has received some publicity, and is for example listed in"awesome-python-data-science".Changelogv.0.2.x* PtitPrince now relies on seaborn 0.10 and numpy >= 1.13
* kwargs can be passed to the [cloud (default), boxplot, rain/stripplot, pointplot]
                 by preponing [cloud_, box_, rain_, point_] to the argument name.
* End of support for python2, now the support covers python>=3.6Plans for the future:ask seaborn mantainers to add this new plot type(not gonna happen)add a "move" option in seabon to control the positioning of each plot, as in ggplot2.(either, added in ptitprince)get RainCloud published(done!)add logarithmic density estimate (LDE) to the options for the cloudadd the repeated measure feature
Package: ptkcmd
ptkcmdView API documentationptkcmd adapts the built-in cmd.py standard library module to use prompt-toolkit instead of readlineConstructor inputs:from ptkcmd import PtkCmd, Completion, complete_files
class MyCmd(PtkCmd):
    prompt='MyPtkCmd$ ' #change the prompt
    def __init__(self,stdin=None,stdout=None,intro=None,
		interactive=True,do_complete_cmd=True,
		default_shell=False,**psession_kwargs):

        super().__init__(stdin,stdout,intro,interactive,
		do_complete_cmd,default_shell,**psession_kwargs)stdin, stdout, intro are as defined in the standard library cmd.pyIf interactive is True, then the prompt-toolkit prompt() method will be utilized from a PromptSession.
If interactive is False, then the prompt will be written to stdout and a line read from stdinIf do_complete_cmd is True, then completion will be performed for the initial command of each line against the list of known commands.
If do_complete_cmd is False, no completion will be attempted for the initial command.
In either case, completion can be attempted for the arguments according to any 'complete_' methods defined.If default_shell is False, then receiving a command that does not have a "do_" method will result in writing an error to self.stdout.
If default_shell is True, then the command will be used as an input to subprocess.run(). The shell input to run() will be False.If additional keyword arguments are provided, they will be passed to the PromptSession constructor that is used for prompts.
The only PromptSession keyword argument not allowed is 'completer'.The following snippet defines a command named 'mycmd'.
The args input is the list of arguments entered after the command.class MyCmd(PtkCmd):
    ...

    def do_mycmd(self,args)
        self.stdout.write('mycmd args were %s\n' % repr(args))

    def complete_mycmd(self,prev_args,curr_arg,document,complete_event):
        yield from complete_files(curr_arg)Regarding the completion method,
prev_args = the arguments prior to the current one being completed
curr_arg = the current argument being completed.
curr_arg may be an empty string or the start of an argument that from the list of completable arguments.document and complete_event are as defined in the prompt-toolkit
documentationThe completion method must yield Completion objects as defined in prompt-toolkit:
Completion(text,start_position)
text = a suggested completion
start_position = non-positive number representing
how many characters from the cursor to go back
and overwrite.complete_files(curr_arg,path=None) provides the a filename completerTyping 'help mycmd' will show the docstring of do_mycmd().
To add miscellaneous help topics, define a help function:class MyCmd(PtkCmd):
    ...

    def help_mytopic(self):
    	"""
        This is a help topic named 'mytopic'.
        All topics declared in this way will show up when the help 
            command is invoked.

        Typing 'help mytopic' will execute the help function, which 
            typically will write some text to self.stdout
        """
        self.stdout.write('You called help for mytopic\n')
Package: pt-lemmatizer
This NLP package for Portuguese lemmatization is a powerful and advanced tool that can accurately transform words into their base forms or lemmas, taking into account the specific grammatical rules and variations of the Portuguese language. It is designed to handle various types of text input and supports multiple output formats, making it a versatile tool for applications such as information retrieval, machine translation, sentiment analysis, and text classification. Additionally, the package is customizable and user-friendly, allowing users to specify their own dictionaries and rules for lemmatization and providing features for error correction and word sense disambiguation.
Whether you are a researcher, developer, or linguist working with Portuguese text data, this NLP package can help you save time and improve the accuracy and quality of your analyses. With its advanced algorithms and techniques in NLP, you can trust that this tool will provide high-quality results and make the lemmatization process more efficient.A lemma is a word that stands at the head of a definition in a dictionary.WikipediaExamplefrom pt_lemmatizer import Lemmatizer

l = Lemmatizer()
l.lemmatize('apagou')  #all words must be unidecoded and lowercased
>> 'apagar'
l.lemmatize('nasalaram')
>> 'nasalar'
Package: ptlib
Parallel Timing LibraryThis library that aims to decrease the latency of shared-memory-based communication between asynchronous processes in Python. The common practice for sharing data between parallel processes is using a Python standard library multiprocessing Queue-like data structure. However, this requires that the data be serialized and transferred over a local socket, leading to a significant bottleneck when dealing with large data structures. I have been able to decrease this latency by leveraging the multiprocessing SharedMemory class added to the standard library with the release of Python 3.8. This addition allows the user to allocate bytes in memory and directly read/write to a buffer without serializing data. As it currently stands, implementing this requires an intimidating amount of familiarity with multiprocessing. I aim to abstract most of the heavy lifting in this library with the hope of increasing the readability and efficiency of asynchronous pipelines.tests show that ptlib.Queue can be more than 50 times faster than multiprocessing.Queue.TODOimplement option to directly specify job specinfer job by passing a list intooutput_job, have job map assign
indices like before, and then iterate over jobs and infer shapewrite job to be a dict. overload set item and make sure assignment fillssave key of job in job specpass in output and input job buffers when job map is createdrefer to embedded jobs as subjobs?overload getitem for jobinfer such that the first assignment allows for
something immutablecreate requirements fileway to implement task order non linear pipelinesdocument the code lolget rid of unused importsremove duplicated code from controller_set_up_tasksfix task job map documentationcreate way to specify spec in typing. for ex, job: Job[JobSpec]create several objects in _typing*** instead of creating controller, decorate tasks*** CHANGE queue to hold selection index until job is done so we dont have to copy data from buffer*** have put copy directly to output buffer (this may mean locking down output buffer before task starts)*** try to figure out optimal worker numbers under constraints*** instead of having several buffers for several I/O, have one buffer and
keep track of the offset and number of bytes*** add way to enable/disable metadata
Package: pt-library
PT Utility PackageTime Decoratordecorator to calculate execution time.from pt_library import calculate_timeNotificationCurrently, supports only Telegram Notifications.from pt_library import telegram_notificationDB ConnectionRun Query on SQL and return records.from pt_library import run_queryDate timeGet the current month date (format: yyyy_mm_dd)Get the previous month date (yyyy_mm)Get the timestamp (yyyy-mm-dd HH:MM:SS)from pt_library import get_previous_month_year, get_current_month_year, get_timestamp