feat: Please review the whole project and add optimizations #29
85
README.md
85
README.md
@ -113,6 +113,90 @@ Response:
|
||||
{"result": 255}
|
||||
```
|
||||
|
||||
### POST /api/v1/calculator/average
|
||||
|
||||
Compute the arithmetic mean of a list of values.
|
||||
|
||||
Request:
|
||||
|
||||
```json
|
||||
{"values": [1, 2, 3, 4, 5]}
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```json
|
||||
{"result": 3.0}
|
||||
```
|
||||
|
||||
An empty list produces a 422 validation response.
|
||||
|
||||
### POST /api/v1/calculator/median
|
||||
|
||||
Compute the median of a list of values. Values are sorted internally; an even-length list returns the average of the two middle values as a float.
|
||||
|
||||
Request:
|
||||
|
||||
```json
|
||||
{"values": [1, 3, 5]}
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```json
|
||||
{"result": 3.0}
|
||||
```
|
||||
|
||||
Request (even length):
|
||||
|
||||
```json
|
||||
{"values": [1, 2, 3, 4]}
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```json
|
||||
{"result": 2.5}
|
||||
```
|
||||
|
||||
An empty list produces a 422 validation response.
|
||||
|
||||
### POST /api/v1/calculator/variance
|
||||
|
||||
Compute the population variance of a list of values.
|
||||
|
||||
Request:
|
||||
|
||||
```json
|
||||
{"values": [1, 2, 3, 4, 5]}
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```json
|
||||
{"result": 2.0}
|
||||
```
|
||||
|
||||
An empty list produces a 422 validation response.
|
||||
|
||||
### POST /api/v1/calculator/percentage
|
||||
|
||||
Compute what percentage `value` is of `total`.
|
||||
|
||||
Request:
|
||||
|
||||
```json
|
||||
{"value": 50, "total": 100}
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```json
|
||||
{"result": 50.0}
|
||||
```
|
||||
|
||||
A zero `total` produces a 422 validation response.
|
||||
|
||||
## Verification
|
||||
|
||||
```sh
|
||||
@ -121,3 +205,4 @@ make verify
|
||||
|
||||
Runs compile-all checks against all source and test files, then executes the full test suite.
|
||||
Zero warnings are tolerated.
|
||||
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning, module="starlette")
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
@ -248,3 +251,4 @@ class TestCalculatorPercentageEndpoint(unittest.TestCase):
|
||||
self.assertEqual(response.status_code, 422)
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user