semvec/pypi-packages huggingface dataset:
pytest-api 0.1.4
An ASGI middleware to populate OpenAPI Specification examples from pytest functions
License: MIT
Requires Python: >=3.8,<4.0
Keywords: fastapi,pytest

# PyTest-API: Populate OpenAPI Examples from Python Tests

![purpose](https://img.shields.io/badge/purpose-testing-green.svg)
![PyPI](https://img.shields.io/pypi/v/pytest-api.svg)

PyTest-API is an [ASGI middleware](https://asgi.readthedocs.io/en/latest/specs/main.html#middleware) that populates [OpenAPI-Specification](https://github.com/OAI/OpenAPI-Specification/) examples from [pytest](https://pypi.org/project/pytest/) functions. 


## Installation

```
poetry add --dev pytest-api
```

## How to use it:

Starting with `test_main.py` file: 

```python
from .main import spec


@spec.describe(route="/behavior-example/")
def test_example_body(client):
    """
    GIVEN behavior in body
    WHEN example behavior endpoint is called with POST method
    THEN response with status 200 and body OK is returned
    """
    assert client.post(
        "/behavior-example/", json={"name": "behavior"},
        headers={"spec-example": test_example_body.id}
    ).json() == {"message": "OK"}
```

Impliment solution in `/main.py` file:

```python
from fastapi import FastAPI
from pydantic import BaseModel

from pytest_api import ASGIMiddleware

app = FastAPI()
spec = ASGIMiddleware

app.add_middleware(spec)

app.openapi = spec.openapi_behaviors(app)


class Behavior(BaseModel):
    name: str


@app.post("/behavior-example/")
async def example_body(behavior: Behavior):
    return {"message": "OK"}
```

Run FastAPI app:
```bash
poetry run uvicorn test_app.main:app --reload
```

Open your browser to http://localhost:8000/docs#/ too find the doc string is populated into the description.

![Your doc string will now be populated into the description.](./OpenAPI.png)

## Implimentation Details

Under the hood the `ASGIMiddleware` uses the `describe` decorator to store the `pytest` function by its `id`: 

```python
def wrap_behavior(*args, **kwargs):
                try:
                    BEHAVIORS[route]
                except KeyError as e:
                    if route in e.args:
                        BEHAVIORS[route] = {str(id(func)): func}
                BEHAVIORS[route][str(id(func))] = func
```

When `pytest` calls your API the `SpecificationResponder` is looking for the coresponding `id` in the `headers` of the request:

```python
    def handle_spec(self, headers):
        behaviors = BEHAVIORS[self.path]
        self.should_update_example = headers.get("spec-example", "") in behaviors
        self.should_update_description = (
            headers.get("spec-description", "") in behaviors
        )

        if self.should_update_example:
            self.func = behaviors[headers.get("spec-example")]
        elif self.should_update_description:
            self.func = behaviors[headers.get("spec-description")]
```

This is possible thanks to python's first-class `functions` i.e. [Closure_(computer_programming)](https://en.wikipedia.org/wiki/Closure_(computer_programming)).
n-const 1.1.0
Necst Constants and ObservatioN Specification Translator.
License: MIT
Requires Python: >=3.6,<4.0

# N-CONST

[![PyPI](https://img.shields.io/pypi/v/n-const.svg?label=PyPI&style=flat-square)](https://pypi.org/pypi/n-const/)
[![Python](https://img.shields.io/pypi/pyversions/n-const.svg?label=Python&color=yellow&style=flat-square)](https://pypi.org/pypi/n-const/)
[![Test](https://img.shields.io/github/workflow/status/nanten2/N-const/Test?logo=github&label=Test&style=flat-square)](https://github.com/nanten2/NASCO-tools/actions)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?label=License&style=flat-square)](LICENSE)

Necst Constants and ObservatioN Specification Translator.

## Features

This library provides:

- constants of the telescope system as useful python objects
- parsers for parameter files unique to NECST

## Installation

```shell
pip install n-const
```

## Usage

Be careful of the package name! Use underscore instead of hyphen.

### Constants

Solid constants such as location of the telescope are declared in `constants` module. To use the constants:

```python
>>> import n_const
>>> n_const.LOC_NANTEN2
EarthLocation(2230866.39573496, -5440247.68222275, -2475554.41874542) m
>>> n_const.XFFTS.ch_num
32768
```

`Constants` objects support both keys and dot notations to access its components. So you can write:

```python
>>> n_const.XFFTS['ch_num']
32768
```

You now can get all the parameters packed in the `Constants` using `dict` method:

```python
>>> n_const.XFFTS.keys()
dict_keys(['ch_num', 'bandwidth'])
>>> n_const.REST_FREQ.values()
dict_values([<Quantity 115.27 GHz>, <Quantity 110.20 GHz>, ..., <Quantity 219.56 GHz>])
>>> n_const.XFFTS.items()
dict_items([('ch_num', 32768), ('bandwidth', <Quantity 2. GHz>)])
```

### Parameters

Pointing error parameter (parameters to correct pointing error) and observation parameters are extracted via `pointing` and `obsparam` modules respectively.

To get the pointing error parameters:

```python
>>> from n_const.pointing import PointingError
>>> params = PointingError.from_file("path/to/param_file")
>>> params.dAz
Quantity 5314.24667547 arcsec

# This module also supports keys to access the components:

>>> params['dAz']
Quantity 5314.24667547 arcsec
```

To get the observation parameters:

```python
>>> from n_const import obsparams
>>> params = obsparams.OTFParams.from_file("path/to/obs_file")
>>> params.Beta_on
<Angle 15.51638889 deg>
>>> params['Beta_on']
<Angle 15.51638889 deg>
```

For conventional style obsfiles, this module provides a parser. This is a conventional one, so it provides very limited functionality;

- Dot notation is not supported, keys only.
- Return values are not combined with units.

```python
>>> params = obsparams.obsfile_parser("path/to/obs_file")
>>> params['offset_Az']
0
```

---

This library is using [Semantic Versioning](https://semver.org).
vptrade 0.0.2
vptrade is a technical indicators trading tools can be used to all instruments.
License: MIT
Keywords: technical analysis,ta,trading tools,finance,trading,analysis


# vptrade
[![MIT License](https://img.shields.io/apm/l/atomic-design-ui.svg?)](https://github.com/tterb/atomic-design-ui/blob/master/LICENSEs)

vptrade is a technical indicators trading tools can be used to all instruments.



## Requirements

- Python 3.9 or higher
## Features

- Trends Indicator 
- Oscillators Indicator



## Installation

Instal this package with pip

```bash
  pip install vptrade
```
    
# Usage/Examples

## Moving Average
```python
from vptrade.indicators.trends import Trend
import pandas as pd


data = pd.read_csv(r'YOUR PATH\TSLA.csv',
                   index_col='Date',
                   parse_dates=True)
trend = Trend(data)

#simple moving average
sma = trend.sma(period=30, volume="Close", show=True, save="sma_img.png")

#exponential moving average
ema = trend.ema(period=30, volume="Close", show=True, save="ema_img.png")

#cummulative moving average show only without save
cma = trend.cma(period=30, volume="Close", show=True)

#smoothed moving average without save and show
smma = trend.smma(period=30, volume="Close", show=False)

#lienar-weighted moving average without show and save
lwma = trend.lwma(period=30, volume="Close")
```

## Bollinger band
```python
from vptrade.indicators.trends import Trend
import pandas as pd

data = pd.read_csv(r'YOUR PATH\TSLA.csv',
                   index_col='Date',
                   parse_dates=True)
trend = Trend(data)
bollinger = trend.bollinger_bands(period=30, volume="Close", show=True, save="bolinger_band.png")
```


## Support

For support, Join my discord https://discord.gg/HZJZAVAZdr


## Contributing

Contributions are always welcome!

See `contributing.md` for ways to get started.

Please adhere to this project's `code of conduct`.