Saravanan666/pypi-org huggingface dataset:
Package: order
If you're designing a high-energy physics analysis (e.g. with data recorded by anLHCexperiment atCERN, manual bookkeeping of external data can get complicated quite fast.orderprovides a pythonic class collection that helps you structuringanalyses,MC campaigns,datasets,physics process and cross sections,channels,categories,variables, andsystematic shifts.Getting startedSee theintro.ipynbnotebook for an introduction to the most important classes and an example setup of a small analysis.
You can also run the notebook interactively on colab or binder:You can find the fullAPI documentation on readthedocs.Projects using orderuhh-cms/cmsdbtbaInstallation and dependenciesInstallorderviapip:pipinstallorderThe only dependencies arescinumandsix(Python 2 support that will be dropped soon), which are installed with the above command.Contributing and testingIf you like to contribute, feel free to open a pull request 🎉.
Just make sure to add new test cases and run them via:python-munittesttestsIn general, tests should be run for Python 2.7, 3.6 - 3.11.
To run tests in a docker container, do# run the tests./tests/docker.shpython:3.9# or interactively by adding a flag "1" to the command./tests/docker.shpython:3.91>pipinstall-rrequirements.txt
>python-munittesttestsIn addition,PEP 8compatibility should be checked withflake8:flake8ordertestssetup.pyDevelopmentSource hosted atGitHubReport issues, questions, feature requests onGitHub Issues
Package: orderby
Python key functions for multi-field ordering in SQL ORDER BY fashionMeant to be used with built-insorted()key function.Supports alsolist.sort()doingin-place sorting.Implementation usesoperator.itemgetter()+ some internal helper classes to allow descending sorting order.So far this is tested and used onlists of dictionaries. Adding support for named tuples and others would
be possible (usingoperator.attrgetter()).UsageSQL-like:orderby('fooASC, bar DESC')chained:asc('foo').desc('bar')usagemultiple fields at once:asc('foo','bar')Examplesorderby()string syntax:>>>fromorderbyimportorderby>>>importjson>>>files=[...{'size':1234,'path':'foo/bar.txt'},...{'size':0,'path':'/dev/null'},...{'size':1234,'path':'foo/abc.bin'},...]>>>print(json.dumps(sorted(files,key=orderby('size DESC, path')),indent=2))[{"size":1234,"path":"foo/abc.bin"},{"size":1234,"path":"foo/bar.txt"},{"size":0,"path":"/dev/null"}]Chainedasc()anddesc()usage:>>>fromorderbyimportasc,desc>>>print(json.dumps(sorted(files,key=desc('size').asc('path')),indent=2))[{"size":1234,"path":"foo/abc.bin"},{"size":1234,"path":"foo/bar.txt"},{"size":0,"path":"/dev/null"}]In-place sorting of a list:>>>files.sort(key=desc('path'))>>>print(json.dumps(files,indent=2))[{"size":1234,"path":"foo/bar.txt"},{"size":1234,"path":"foo/abc.bin"},{"size":0,"path":"/dev/null"}]>>>files.sort(key=desc('size').asc('path'))>>>print(json.dumps(files,indent=2))[{"size":1234,"path":"foo/abc.bin"},{"size":1234,"path":"foo/bar.txt"},{"size":0,"path":"/dev/null"}]InternalsTo be explained here later…
Package: ordered-argparse
ordered_argparseVersion of Python's standard library'sargparsewhich also remembers the order of command line arguments.InstallationInstall withpip install ordered_argparse.UsageCreate an instance ofArgumentParseras usual. Usenamespace=ordered_argparse.OrderedNamespace(). Access arguments in declaration order by calling parser's.ordered()method.importordered_argparseparser=ordered_argparse.ArgumentParser()parser.add_argument("--foo",action="store_true",help="foo")parser.add_argument("--bar",action="store_true",help="bar")# Use OrderedNamespace when parsing CLI argumentsargs=parser.parse_args(["--foo","--bar"],namespace=ordered_argparse.OrderedNamespace())# Access ordered arguments by calling .ordered()forarginargs.ordered():print(f"{arg}")Compatibility with argcompleteordered_argparse only works withargcompleteas long as you don't use subparsers. If you use subparsers, you needordered_argcomplete.
Package: orderedbunch
IntroductionThe is a simplification and redesign of the orderedbunch package from tinytools.
The package ontains an OrderedBunch object class with associated
bunchify/unbunchify methods, similar to other bunch implementations but
built off an OrderedDict with ipython table-complete overloaded to the
data memebers.  It removes theordered_dictionarifyfunction that is in
tinytools and and leaves the development of the nested dictionaries to
external code.  The motivation is that it is quite complicated to infer what
the user is wanting - and therefore error prone.IPython has also recently changed its handling of the__dir__method and it
is unclear under which cases it is respected for tab completion or not.  It
seems, though, that for ipython 6, it is possible to remove mothods from
the tab completion through theIPCompleter.*configuration options.InstallingpipinstallorderedbunchImportimportorderedbunchQuick StartfromorderedbunchimportOrderedBunch## OrderedBunchfromcollectionsimportOrderedDict# Create an OrderedBunch from and return it to an OrderedDictod=OrderedDict({'a':1,'b':2,'c':{'aa':1.23,'bb':'string'}})ob=orderedbunch.ordered_bunchify(od)ob.a# Explore the OrderdBunch with tab completeob['a']# Equivalent to aboveob.c.bb# orderd_bunchify is recursive on nested Dict objectsob['c']['bb']# Equivalent to aboveod2=tt.bunch.ordered_unbunchify(ob)
Package: ordered-demuxer
Ordered Demultiplexer in PythonSingle pass approach to Demultiplexing/DemuxingBreak an iterator into multiple iterators based on a set of filters.Typical demuxers will place elements into different iterators,
such as splitting [0,1,2,3] into ([0,2], [1,3]) based on odd or
even elements. Ordered Demuxers focus on breaking iterators into
contiguous blocks that are meant to be immediately worked upon,
without having to iterate over the list more than once.This makes them appropriate to use with iterators where the contents
cannot be fully held in memory, such as retrieving data online.ExampleWith any iterable input such asx=iter([(_,0),(_,1),(MessageEnd,2),(_,3),(_,4),(MessageEnd,5)])This can be broken into;Iterator[Iterator[(_,0),(_,1),(MessageEnd,2)],Iterator[(_,3),(_,4),(MessageEnd,5)]]Without passing over each element of data multiple times. This allows for methods like;fordata_streamindemuxed_stream:forelementindata_stream:function(element)Or more interestingly;deffoo(x:Iterator[T]):...fordata_streamindemuxed_stream:foo(data_stream)foowill consume part of the original iterator, up until the next break point, but still behave identically to passing it an iterator of just the data required.Due to the way the filters are available within the Demuxer, it's also possible to send these partial iterators to functions according to the relevant filter, i.e.conditions=[FilterCondition(lambdax:x[0]=='MessageEnd','SuccessfulMessageStream'),FilterCondition(lambdax:x[0]=='MessageFailed','FailedMessageStream')]fordata_streamindemuxed_stream:ifdemuxed_stream.condition_metisnotNone:matchdemuxed_stream.condition_met.name:case'SuccessfulMessageStream':foo(data_stream)case'FailedMessageStream':foo2(data_stream)else:foo3(data_stream)Although it requires the consumption of each iterator entirely to make this possible.Installationpython-mpipinstallordered-demuxerUsage>>>fromordered_demuxerimportFilterCondition,OrderedDemuxer>>>x=[1,2,3,4]>>>y=FilterCondition(lambdax:x==2)>>>splt=OrderedDemuxer(data_source=iter(x),filter=y,split_after=True)>>>x_iter=splt.__next__()>>>print(list(x_iter))[1,2]
Package: ordered-enum
ordered_enumordered_enumis a small library for adding (total) orderings toenum.Enums.It provides two ordering behaviors:ordered_enum.OrderedEnum: total ordering by definitionordered_enum.ValueOrderedEnum: "total" ordering by member valuesInstallationordered_enumrequires Python 3.7 or newer.pip3installordered_enumUsageTo useordered_enum, just useOrderedEnumorValueOrderedEnumas your parent class:fromordered_enumimportOrderedEnumclassState(OrderedEnum):Disabled=4Loaded=3Waiting=2Running=1Dead=0assert(State.Disabled<State.Loaded)assert(sorted([State.Dead,State.Waiting])==[State.Waiting,State.Dead])OrderedEnumdoesn't require@enum.unique(or unique values at all); it uses the order of
definition to impose an ordering between members.If you'd like to impose an ordering based on member values, you can useValueOrderedEnuminstead:importenumfromordered_enumimportValueOrderedEnum@enum.uniqueclassState(ValueOrderedEnum):Disabled=4Loaded=3Waiting=2Running=1Dead=0assert(State.Disabled>State.Loaded)assert(sorted([State.Waiting,State.Dead])==[State.Dead,State.Waiting])ValueOrderedEnumdoesrequire unique values, which can be enforced via@enum.unique.
Failing to make aValueOrderedEnum's values unique will result in a silently broken ordering.CaveatsAs mentioned above,ordered_enum.OrderedEnumprovides an ordering of enum values based on their order
of definition in the class. This means that:Enum values doesn't have to be unique forordered_enumto workEnum values can be heterogeneously typedMoving enum values around changes their orderingTherefore, you should either not depend on a specific orderingorensure that your
order of definition is the order you'd like.
Package: ordered-hash-set
ordered-hash-set is data structure that stores immutable unique elements.
Unlike built-in set in python, it also keeps the insertion order.InstallationInstall viapip:pip install ordered-hash-setOr install from source:python3 setup.py installBasic Usagefromordered_hash_setimportOrderedSets=OrderedSet()s.add("London")s.add("Tokyo")# you can add multiple entries at once, like this:s.update("Paris","Istanbul")s.add("London")s.remove("Tokyo")print(s)# prints: OrderedSet(London, Paris, Istanbul)# Thanks to the hashing. Time complexity of checking# if an element present in a collection is O(1).# Which is faster than regular list: O(n).if"Paris"ins:print("Paris is in the set.")# It is also possible, but not recommended due to inefficiency,# to get the item by index:asserts[2]=="Istanbul"API DocumentationPlease seeAPI Reference Page
Package: orderedpy
OrderedPy is an ordered version of the ordinary python list.Installation>>> pip install orderedpyDocumentationContains most of the list methods. +all_indecies/returns first and last index of an element/,last_index/returns last index of an element/Example>>> from odrederedpy import Ordered
>>>
>>> o = Ordered([1, 2, 5, 1, 2, 3])
>>> o
[1, 1, 2, 2, 3, 5]
>>> other = [2, 1, 3, 4]
>>> o == other
False
>>> o.extend([4, 1, 2])
>>> o
[1, 1, 1, 2, 2, 2, 3, 4, 5]
>>> o.append(1)
>>> o
[1, 1, 1, 1, 2, 2, 2, 3, 4, 5]
>>> o.insert(2, 3)
IndexError
>>> o.insert(0, 1)
[1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 5]
>>> o[0] = 0
>>> o
[0, 1, 1, 1, 1, 2, 2, 2, 3, 4, 5]LICENSEMIT LicenseUPDATES13/01/2020>>> ``key``, ``reverse`` options were added
>>> ``>=`` was fixed
Package: orderedset
An Ordered Set implementation in Cython. Based onRaymond Hettinger’s OrderedSet recipe.Example:>>>fromorderedsetimportOrderedSet>>>oset=OrderedSet([1,2,3])>>>osetOrderedSet([1,2,3])>>>oset|[5,4,3,2,1]OrderedSet([1,2,3,5,4])Free software: BSD licenseDocumentation:http://orderedset.rtfd.org.FeaturesWorks like a regular set, but remembers insertion order;Is approximately 5 times faster than the pure Python implementation overall
(and 5 times slower thanset);Compatible with Python 2.7 through 3.8;Supports the full set interface;Supports some list methods, likeindexand__getitem__.Supports set methods against iterables.Changelog2.0.3 - 2020-02-26bugfix: Generate new C file to fix compile issues2.0.2 - 2020-02-25bugfix: Fix deprecation warning for collections.abc in Python 3.8+2.0.1 - 2018-03-20bugfix: Fixisdisjointto return True when the sets are disjointbuild: Include 3.6 when testingdist: Include test files in sdistdocs: Make the Readme a bit prettier2.0 - 2016-02-02breaking change: All comparisons, other thaneq, against other ordered sets
are now performed unordered; i.e., they are treated as regular sets.isorderedsubsetandisorderedsupersethave been added to perform ordered
comparisons against other sequences. Using these methods with unordered
collections wield yield arbitrary (and depending on Python implementation,
unstable) results.1.2 - 2015-09-29bugfix: Set operations only worked with iterables if the OrderedSet was on the
left-hand side. They now work both ways.bugfix: The order of an intersection was the right-hand side’s order. It is now
fixed to be the left-hand side’s order.1.1.2 - 2014-10-02Make comparisons work with sets and lists, and not crash when compared with None.1.1.1 - 2014-08-24Add pickle/copy support to OrderedSet1.1 - 2014-06-04Make OrderedSets handle slicing in __getitem__().1.0.2 - 2014-05-14Add proper attribution and licenses.1.0.1 - 2014-05-13Don’t require Cython to build an sdist.1.0 - 2014-05-11First implementation.
Package: ordered-set-minghu6
An OrderedSet is a custom MutableSet that remembers its order, so that every
entry has an index that can be looked up.Based on a recipe originally posted to ActiveState Recipes by Raymond Hettiger,
and released under the MIT license:http://code.activestate.com/recipes/576694-orderedset/Rob Speer’s changes are as follows:changed the content from a doubly-linked list to a regular Python list.
Seriously, who wants O(1) deletes but O(N) lookups by index?add() returns the index of the added itemindex() just returns the index of an itemadded a __getstate__ and __setstate__ so it can be pickledadded __getitem____getitem__ and index() can be passed lists or arrays, looking up all
the elements in them to perform NumPy-like “fancy indexing”minghu6’s changes are as follow:restrict the OrderedSet operation object: only themselves.
Because OrderededSet’s element consists of its index and value,
Python set’s element only consists of its value, however.
I have written a new class OrderedSetAdapter to adapt Python set.writtern a new class OrderedSetAdapterrewrittern some contradictory method from collections.MutableSetTested on Python 2.7, 3.3, 3.4, 3.5, 3.6, PyPy, and PyPy3.
Package: orderedsets
orderedsetsAn implementation of mutable and immutable ordered sets as thin wrappers around
Python'sdictclass.
These classes are meant as drop-in replacements for Python's builtinsetandfrozensetclasses. Care has been taken to provide the same functionality as the Python classes,
without API additions or removals, to allow easy switching between set implementations.In contrast to Python's builtinsetandfrozensetclasses, the order of
items is kept (generally, insertion order), such that iterating over items in
the set as well as mutating operations are deterministic.This package has no external dependencies.UsageInstall this package with:$ pip install orderedsetsUsage example:fromorderedsetsimportOrderedSet,FrozenOrderedSetos=OrderedSet([1,2,4])os.add(0)assertlist(os)==[1,2,4,0]os.remove(0)fos=FrozenOrderedSet([1,2,4])# a.add(0)  # raises AttributeError: 'FrozenOrderedSet' object has no attribute 'add'assertlist(fos)==[1,2,4]# sets with the same elements compare equalassertos==fos==set([1,2,4])==frozenset([1,2,4])# only immutable sets can be hashedasserthash(fos)==hash(frozenset([1,2,4]))Please also see thedocumentation.ReferencesOther packageshttps://github.com/rindPHI/proxyorderedset/(not 100% compatible with set)https://pypi.org/project/ordered-set/(no frozen/immutable class)https://pypi.org/project/stableset/(no frozen/immutable class)https://pypi.org/project/orderedset/(Cython, no frozen/immutable class)https://pypi.org/project/Ordered-set-37/(no frozen/immutable class)Discussionshttps://discuss.python.org/t/add-orderedset-to-stdlib/12730Python implementationshttps://github.com/python/cpython/blob/main/Objects/setobject.chttps://github.com/python/cpython/blob/main/Objects/dictobject.c
Package: ordereduuid
Ordered UUIDGenerates UUIDs ordered by time generated.OverviewExamplesThe default constructor generates a UUID using a random multicast MAC
address as the node:>>> from ordereduuid import OrderedUUID
>>> OrderedUUID()
OrderedUUID('1ea96141-1da3-c3ef-e978-ab415e52aca4')If a private MAC is not preferred, use the set theprivate_mackeyword argument toFalse:>>> OrderedUUID(private_mac=False)
OrderedUUID('1ea961a5-25a5-c3bf-e26f-ffffffffffff')REQUIRES TESTING/REVIEW -- UUIDs generated are designed to be used as
keys in databases. Consider the following Django example:from django.db import models

from ordereduuid import OrderedUUID

class Subscriber(models.Model):
    id = models.UUIDField(
        primary_key=True, default=OrderedUUID, editable=False
    )
Package: orderfix
Reorder solutions of parametric studies (assumed to be in random order) to make continuous curves.The common use case is postprocessing of numerically computed eigenvalues from parametric studies of linear PDE boundary-value problems.
The ordering of the numerically computed eigenvalues may suddenly change, as the problem parameter sweeps through the range of interest.The reordering allows the plotting of continuous curves, which are much more readable visually than scatterplots of disconnected points.Supports Python 2.7 and 3.4.
Package: ordering
A data structure toimpose a total orderon a collection of objects.Dependenciesorderingrequires Python 3.6+.
If the type hints were removed, it would probably work in earlier versions, as well.UsageAn ordering is represented by an Ordering object.
The order may be different to the usual order between objects, or even between objects that are not normally comparable.>>>fromorderingimportOrdering>>>order=Ordering([2,0,1])We can then compare the objects in our ordering, to check if the first object comes before the second in the order.>>>order.compare(0,1)# 1 after 0True>>>order.compare(0,2)# 2 before 0FalseOur ordering is mutable, and we can add elements on either end, or immediately before or after an existing element.>>>order.insert_end(3)# Add 3 on the end>>>order.compare(1,3)# 3 after 1True>>>order.insert_after(0,4)# Insert 4 immediately after 0>>>order.compare(0,4)# 4 after 0True>>>order.compare(1,4)# 4 before 1FalseOrderings are iterable, yielding their items in order.>>>list(order)[2,0,4,1,3]And can be used as a key in sorting functions, to sort with respect to that order.>>>sorted(range(3),key=order)[2,0,1]
Package: orderings
orderingsOrdering enumeration and protocols.InstallingPython 3.8 or above is required.pipInstalling the library withpipis quite simple:$pipinstallorderingsAlternatively, the library can be installed from source:$gitclonehttps://github.com/nekitdev/orderings.git$cdorderings$python-mpipinstall.poetryYou can addorderingsas a dependency with the following command:$poetryaddorderingsOr by directly specifying it in the configuration like so:[tool.poetry.dependencies]orderings="^1.3.1"Alternatively, you can add it directly from the source:[tool.poetry.dependencies.orderings]git="https://github.com/nekitdev/orderings.git"MotivationSometimes it's simpler to handle ordering in one method, for example when comparing iterators;
then it's trivial to implement the regular ordering methods using thecomparemethod.ExamplesCoreThe core oforderingsis theOrderingenumeration
and theCompareprotocol:fromtypingimportGeneric,TypeVarfromattrsimportfrozenfromorderingsimportCompare,Ordering,StrictOrderedfromtyping_extensionsimportSelfT=TypeVar("T",bound=StrictOrdered)@frozen()classWrap(Compare,Generic[T]):value:Tdefcompare(self,other:Self)->Ordering:self_value=self.valueother_value=other.valueifself_value<other_value:returnOrdering.LESSifself_value>other_value:returnOrdering.GREATERreturnOrdering.EQUALCompareimplements all ordering operations
(==,!=,<,>,<=,>=) using thecomparemethod.DocumentationYou can find the documentationhere.SupportIf you need support with the library, you can send anemailor refer to the officialDiscord server.ChangelogYou can find the changeloghere.Security PolicyYou can find the Security Policy oforderingshere.ContributingIf you are interested in contributing toorderings, make sure to take a look at theContributing Guide, as well as theCode of Conduct.Licenseorderingsis licensed under the MIT License terms. SeeLicensefor details.
Package: orderlyweb-api
orderlyweb-apiPython client forOrderlyWeb.Initial use case is to run a report only.UsageInstantiate theOrderlyWebAPIclass, providing base url and bearer token as parameters:api = OrderlyWebAPI('http://localhost:8080', 'H2AAbjvhjbbhbhjlh')The bearer token must be obtained externally to this client. Use theMontagu Python clientto obtain a token by
authenticating with Montagu.To run a report:api.run_report(report_name, report_paraneters, timeout)wherereport_parametersis a dictionary or JSON string, andtimeoutis an
integer.Timeoutsets a timeout for the report run in seconds, after which the
run will be halted. The default timeout is 600.DevelopmentClone the repo anywhere and install dependencies with (from the repo root):pip3 install --user -r requirements.txtRun dependencies (a local copy of Montagu API and database, and OrderlyWeb) withscripts/run-dev-dependencies.sh. This will also
add a test user to Montagu.TestingRun dependencies as described above, then runpytestPublishingThis repository is published toPyPI.Building and publishing is done manually, with local sources.Publishing configuration can be found insetup.py, and any classes, methods etc which should be accessible to users of the package
must be added toorderlyweb_api/__init__.py.
Remember to incrementversioninsetup.pybefore publishing a new build.To publish:Delete the following folders:.eggs,build,dist,orderlyweb_api.egg-info.Build the package with:python3 setup.py sdist bdist_wheelPublish with:python3 -m twine upload dist/*To use the OrderlyWebAPI class as a client of the package, includeorderlyweb-apiin yourrequirements.txt. Import withimport orderlyweb_api, and instantiate the API class withorderlyweb_api.OrderlyWebAPI(url, token)See general instructions for publishing Python packageshere.Some troubleshooting tips for publishing Python packages can be found in theconsellations repo.
Package: order-matching
Order Book Matching EngineOverviewThis package is a simple order book matching engine implementation in Python. Its main features are:price-time prioritylimit and market ordersorder cancellation and expirationconversion into pandas DataFrame of orders, executed trades, order book summaryInstallpipinstallorder-matchingDocumentationorder-book-matching-engine.readthedocs.ioUsage>>>frompprintimportpp>>>importpandasaspd>>>fromorder_matching.matching_engineimportMatchingEngine>>>fromorder_matching.orderimportLimitOrder>>>fromorder_matching.sideimportSide>>>fromorder_matching.ordersimportOrders>>>matching_engine=MatchingEngine(seed=123)>>>timestamp=pd.Timestamp("2023-01-01")>>>transaction_timestamp=timestamp+pd.Timedelta(1,unit="D")>>>buy_order=LimitOrder(side=Side.BUY,price=1.2,size=2.3,timestamp=timestamp,order_id="a",trader_id="x")>>>sell_order=LimitOrder(side=Side.SELL,price=0.8,size=1.6,timestamp=timestamp,order_id="b",trader_id="y")>>>executed_trades=matching_engine.match(orders=Orders([buy_order,sell_order]),timestamp=transaction_timestamp)>>>pp(executed_trades.trades)[Trade(side=SELL,price=1.2,size=1.6,incoming_order_id='b',book_order_id='a',execution=LIMIT,trade_id='c4da537c-1651-4dae-8486-7db30d67b366',timestamp=Timestamp('2023-01-02 00:00:00'))]Related Projectsbmoscon/orderbookKautenja/limit-order-bookContributeCreate a virtual environment and activate it:python-mvenvvenvsourcevenv/bin/activateInstall development dependencies:pipinstall-e.[dev]and use pre-commit to make sure that your code is formatted usingblackandisortautomatically:pre-commitinstallRun tests:pipinstall-e.[test]pytestRun benchmark and see the result either in the terminal or as a plot inbenchmark_history.svg:./benchmark.shBuild and serve documentation website:pipinstall-e.[doc]mkdocsserve