semvec/pypi-packages huggingface dataset:
http-test-client 0.3.2
Library to simplify writing HTTP REST service integration tests
License: MIT

****************
http-test-client
****************

Library to simplify writing HTTP REST service integration tests.

Allows to build a HTTP REST client with automatic resource cleanup.

Example
=======

.. code:: python

    from http_test_client import Client, HttpTransport, RestResources, resources

    class ArticleResources(RestResources):
        def search(self, query):
            return self._request('/search', method='POST', data={'query': query})

        class Resource(RestResources.Resource):
            def publish(self):
                return self._request('/publish', method='POST')

            comments = resources('/comments')

    class MyClient(Client):
        users = resources('/users')
        articles = resources('/articles', ArticleResources)

    client = MyClient(HttpTransport('http://localhost:8888'))

    # managing resources
    client.users.list() # => [{'id': '1', 'name': 'John'}, ...]
    client.users.create({'name': 'Jane'}) # => {'id': '2'}
    client.users['1'].get() # => {'id': '1', 'name': 'John'}
    client.users['1'].delete()

    # delete all resources that were created during this client session
    client.cleanup()

    # custom action
    client.articles['123'].publish()

    # nested resources
    client.articles['123'].comments.list()


Installation
============
::

    $ pip install http-test-client


Requirements
============

- Python >= 2.7 and <= 3.6
- `requests <http://docs.python-requests.org/en/master/>`_ >= 2.14
- six >= 1.10

Project Links
=============

- PyPI: https://pypi.python.org/pypi/http-test-client
- Issues: https://github.com/maximkulkin/http-test-client/issues

License
=======

MIT licensed. See the bundled `LICENSE <https://github.com/maximkulkin/http-test-client/blob/master/LICENSE>`_ file for more details.
stochasticdp 0.4
 A simple implementation of backwards induction for solving finite-horizon, finite-state stochastic dynamic programs. 
License: MIT

stochasticdp
============

A simple implementation of backwards induction for solving
finite-horizon, finite-space stochastic dynamic programs.

Installation
------------

``stochasticdp`` is available on PyPI:

.. code:: bash

    pip install stochasticdp

Usage
-----

To initialize a stochastic dynamic program:

.. code:: python

    dp = StochasticDP(number_of_stages, states, decisions, minimize)

where

-  ``number_of_stages`` is an integer
-  ``states`` is a list
-  ``decisions`` is a list
-  ``minimize`` is a boolean

This results in a stochastic dynamic program with stages numbered
``0, ..., number_of_stages - 1``, and initializes the following
dictionaries:

-  ``dp.probability``, where ``dp.probability[m, n, t, x]`` is the
   probability of moving from state ``n`` to state ``m`` in stage ``t``
   under decision ``x``
-  ``dp.contribution``, where ``dp.contribution[m, n, t, x]`` is the
   immediate contribution of resulting from moving from state ``n`` to
   state ``m`` in stage ``t`` under decision ``x``
-  ``dp.boundary``, where ``dp.boundary[n]`` is the boundary condition
   for the value-to-go function at state ``n``

You only need to define probabilities and contributions for transitions
that occur with positive probability.

You can use the following helper functions to populate these
dictionaries:

.. code:: python

    # This sets dp.probability[m, n, t, x] = p and dp.contribution[m, n, t, x] = c
    dp.add_transition(stage=t, from_state=n, decision=x, to_state=m, probability=p, contribution=c)

    # This sets dp.boundary[n] = v
    dp.boundary(state=n, value=v)

To solve the stochastic dynamic program:

.. code:: python

    value, policy = dp.solve()

where

-  ``value`` is a dictionary: ``value[t, n]`` is the value-to-go
   function at stage ``t`` and state ``n``
-  ``policy`` is a dictionary: ``policy[t, n]`` is the set of optimizers
   of ``value[t, n]``