https://github.com/wearepal/data-science-types
Mypy stubs, i.e., type information, for numpy, pandas and matplotlib
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
3 of 52 committers (5.8%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.3%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Mypy stubs, i.e., type information, for numpy, pandas and matplotlib
Basic Info
Statistics
- Stars: 203
- Watchers: 9
- Forks: 51
- Open Issues: 39
- Releases: 0
Topics
Metadata Files
README.md
Mypy type stubs for NumPy, pandas, and Matplotlib
⚠️ this project has mostly stopped development ⚠️
The pandas team and the numpy team are both in the process of integrating type stubs into their codebases, and we don't see the point of competing with them.
This is a PEP-561-compliant stub-only package which provides type information for matplotlib, numpy and pandas. The mypy type checker (or pytype or PyCharm) can recognize the types in these packages by installing this package.
NOTE: This is a work in progress
Many functions are already typed, but a lot is still missing (NumPy and pandas are huge libraries). Chances are, you will see a message from Mypy claiming that a function does not exist when it does exist. If you encounter missing functions, we would be delighted for you to send a PR. If you are unsure of how to type a function, we can discuss it.
Installing
You can get this package from PyPI:
bash
pip install data-science-types
To get the most up-to-date version, install it directly from GitHub:
bash
pip install git+https://github.com/predictive-analytics-lab/data-science-types
Or clone the repository somewhere and do pip install -e ..
Examples
These are the kinds of things that can be checked:
Array creation
```python import numpy as np
arr1: np.ndarray[np.int64] = np.array([3, 7, 39, -3]) # OK arr2: np.ndarray[np.int32] = np.array([3, 7, 39, -3]) # Type error arr3: np.ndarray[np.int32] = np.array([3, 7, 39, -3], dtype=np.int32) # OK arr4: np.ndarray[float] = np.array([3, 7, 39, -3], dtype=float) # Type error: the type of ndarray can not be just "float" arr5: np.ndarray[np.float64] = np.array([3, 7, 39, -3], dtype=float) # OK ```
Operations
```python import numpy as np
arr1: np.ndarray[np.int64] = np.array([3, 7, 39, -3]) arr2: np.ndarray[np.int64] = np.array([4, 12, 9, -1])
result1: np.ndarray[np.int64] = np.divide(arr1, arr2) # Type error result2: np.ndarray[np.float64] = np.divide(arr1, arr2) # OK
compare: np.ndarray[np.bool_] = (arr1 == arr2) ```
Reductions
```python import numpy as np
arr: np.ndarray[np.float64] = np.array([[1.3, 0.7], [-43.0, 5.6]])
sum1: int = np.sum(arr) # Type error sum2: np.float64 = np.sum(arr) # OK sum3: float = np.sum(arr) # Also OK: np.float64 is a subclass of float sum4: np.ndarray[np.float64] = np.sum(arr, axis=0) # OK
the same works with np.max, np.min and np.prod
```
Philosophy
The goal is not to recreate the APIs exactly. The main goal is to have useful checks on our code. Often the actual APIs in the libraries is more permissive than the type signatures in our stubs; but this is (usually) a feature and not a bug.
Contributing
We always welcome contributions. All pull requests are subject to CI checks. We check for compliance with Mypy and that the file formatting conforms to our Black specification.
You can install these dev dependencies via
bash
pip install -e '.[dev]'
This will also install NumPy, pandas, and Matplotlib to be able to run the tests.
Running CI locally (recommended)
We include a script for running the CI checks that are triggered when a PR is opened. To test these out locally, you need to install the type stubs in your environment. Typically, you would do this with
bash
pip install -e .
Then use the check_all.sh script to run all tests:
bash
./check_all.sh
Below we describe how to run the various checks individually,
but check_all.sh should be easier to use.
Checking compliance with Mypy
The settings for Mypy are specified in the mypy.ini file in the repository.
Just running
bash
mypy tests
from the base directory should take these settings into account. We enforce 0 Mypy errors.
Formatting with black
We use Black to format the stub files.
First, install black and then run
bash
black .
from the base directory.
Pytest
bash
python -m pytest -vv tests/
Flake8
bash
flake8 *-stubs
License
Owner
- Name: Predictive Analytics Lab
- Login: wearepal
- Kind: organization
- Location: University of Sussex, Brighton, UK
- Website: https://wearepal.ai/
- Twitter: WeArePal_ai
- Repositories: 25
- Profile: https://github.com/wearepal
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| thomkeh | 7****h | 89 |
| Myles Bartlett | 4****t | 50 |
| Thomas M | t****x@g****m | 37 |
| Oliver Thomas | 1****s | 21 |
| Adam Weeden | a****n@n****g | 19 |
| Michał Krassowski | 5****i | 11 |
| Elena | e****a@g****m | 9 |
| Arthur Guillon | a****n@e****m | 8 |
| SaraR-1 | S****1 | 7 |
| Oliver Thomas | o****4@s****k | 7 |
| Zack Simon | z****n@c****m | 7 |
| Clouds | C****g@g****m | 6 |
| Henri Vlot | h****t@h****m | 5 |
| Jeremiah Edwards | j****s@s****m | 5 |
| Oliver Thomas | o****6@g****m | 5 |
| lmcnichols | l****s@g****m | 5 |
| fabiencelier | f****r@p****u | 4 |
| Robert P. Goldman | r****n@g****g | 4 |
| Vito De Tullio | v****s@s****t | 4 |
| Robert P. Goldman | r****n@s****t | 4 |
| Maarten-vd-Sande | m****e@h****m | 4 |
| David Assefa Tofu | d****t@b****u | 4 |
| Adam Weeden | a****n@g****m | 4 |
| Jan Margeta | j****a@g****m | 4 |
| Joseph Egan | j****n@g****m | 3 |
| Kolen Cheung | c****n@g****m | 3 |
| Daniele Varrazzo | d****o@g****m | 3 |
| Bruno Oliveira | n****s@g****m | 3 |
| pmav99 | p****9 | 3 |
| ZHSimon | Z****n | 3 |
| and 22 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 42
- Total pull requests: 58
- Average time to close issues: 12 days
- Average time to close pull requests: 5 days
- Total issue authors: 27
- Total pull request authors: 32
- Average comments per issue: 0.86
- Average comments per pull request: 1.64
- Merged pull requests: 53
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- fabiencelier (6)
- kevinhu (5)
- EdwardJRoss (2)
- DeltaSigma130 (2)
- LuisBlanche (2)
- lrob (2)
- jgonsior (2)
- ghost (2)
- TheCleric (1)
- brenoyano (1)
- sfolje0 (1)
- LukasSalchow (1)
- uihsnv (1)
- ZeeD (1)
- pbnoxious (1)
Pull Request Authors
- tmke8 (14)
- olliethomas (5)
- nicoddemus (3)
- Hvlot (2)
- clouds56 (2)
- eganjs (2)
- ghost (2)
- TheCleric (2)
- ickc (2)
- tadeu (1)
- sinemetu1 (1)
- melentye (1)
- grthr (1)
- fabiencelier (1)
- vladdoster (1)