* fix : different ways of matplotlib import unified.

* edit : test system optimized.

* edit : Install section modified.

* fix : doctest issues fixed.

* fix : usecases of `matplotlib` unified.

* pep8 : autpep8ed.

* fix : usecases of `matplotlib` unified.

* delete : `Test with pytest` is now in all Python versions.
pull/195/head
Sadra Sabouri 2023-05-09 17:21:49 +03:30 zatwierdzone przez GitHub
rodzic 76f3f485fc
commit ad05ef464d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
7 zmienionych plików z 32 dodań i 33 usunięć

Wyświetl plik

@ -5,6 +5,10 @@ name: CI
on: [push, pull_request]
env:
TEST_PYTHON_VERSION: 3.9
TEST_OS: 'ubuntu-20.04'
jobs:
build:
@ -34,33 +38,32 @@ jobs:
- name: Test with pytest
run: |
python -m pytest --ignore-glob="*nft_upload_test.py" test --cov=samila --cov-report=term
if: matrix.python-version != 3.5
- name: Test with pytest (+ NFT upload test)
run: |
python -m pytest test --cov=samila --cov-report=term
env:
NFT_STORAGE_API_KEY: ${{ secrets.NFT_STORAGE_API_KEY }}
if: matrix.python-version == 3.8 && matrix.os == 'ubuntu-20.04'
if: matrix.python-version == env.TEST_PYTHON_VERSION && matrix.os == env.TEST_OS
- name: Version check
run: |
python otherfiles/version_check.py
if: matrix.python-version == 3.8
if: matrix.python-version == env.TEST_PYTHON_VERSION
- name: Other tests
run: |
python -m vulture samila/ setup.py --min-confidence 65 --exclude=__init__.py --sort-by-size
python -m bandit -r samila -s B311,B307
python -m pydocstyle -v --match-dir=samila
if: matrix.python-version == 3.8
if: matrix.python-version == env.TEST_PYTHON_VERSION
- name: Notebook check
run: |
pip install notebook>=5.2.2
python otherfiles/notebook_check.py
if: matrix.python-version == 3.8 && matrix.os == 'ubuntu-20.04'
if: matrix.python-version == env.TEST_PYTHON_VERSION && matrix.os == env.TEST_OS
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
if: matrix.python-version == 3.8 && matrix.os == 'ubuntu-20.04'
if: matrix.python-version == env.TEST_PYTHON_VERSION && matrix.os == env.TEST_OS
- name: cProfile
run: |
python -m cProfile -s cumtime otherfiles/samila_profile.py

Wyświetl plik

@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- `get_cmap` function
### Changed
- minor edits in `functions.py`
- `DEFAULT_CMAP` renamed to `DEFAULT_CMAP_NAME`
- `pillow` added to conda dependencies
- `codecov` removed from `dev-requirements.txt`

Wyświetl plik

@ -86,21 +86,14 @@ Samila is a generative art generator written in Python, Samila lets you create i
## Installation
### PyPI
- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
- Run `pip install samila==1.1` (Need root access)
### Source code
- Download [Version 1.1](https://github.com/sepandhaghighi/samila/archive/v1.1.zip) or [Latest Source](https://github.com/sepandhaghighi/samila/archive/dev.zip)
- Run `pip install -r requirements.txt` or `pip3 install -r requirements.txt` (Need root access)
- Run `python3 setup.py install` or `python setup.py install` (Need root access)
### PyPI
- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
- Run `pip install samila==1.1` or `pip3 install samila==1.1` (Need root access)
### Easy install
- Run `easy_install --upgrade samila` (Need root access)
- Run `pip install .`
### Conda

Wyświetl plik

@ -12,8 +12,7 @@ SETUP_ITEMS = [
'https://github.com/sepandhaghighi/samila/tarball/v{0}']
README_ITEMS = [
"[Version {0}](https://github.com/sepandhaghighi/samila/archive/v{0}.zip)",
"pip install samila=={0}",
"pip3 install samila=={0}"]
"pip install samila=={0}"]
CHANGELOG_ITEMS = [
"## [{0}]",
"https://github.com/sepandhaghighi/samila/compare/v{0}...dev",

Wyświetl plik

@ -9,8 +9,6 @@ import re
import json
import random
import matplotlib
from matplotlib import cm
from matplotlib.colors import ListedColormap
from PIL import Image
from .params import SAMILA_VERSION
from .params import DEFAULT_MARKER, DEFAULT_START, DEFAULT_STOP, DEFAULT_STEP, DEFAULT_COLOR, DEFAULT_IMAGE_SIZE, DEFAULT_DEPTH
@ -181,8 +179,8 @@ def get_cmap(name=DEFAULT_CMAP_NAME, lut=256):
"""
try:
return matplotlib.colormaps.get_cmap(name)
except BaseException: # pragma: no cover
return cm.get_cmap(name, lut)
except BaseException: # pragma: no cover
return matplotlib.cm.get_cmap(name, lut)
def filter_cmap(cmap):
@ -201,10 +199,10 @@ def filter_cmap(cmap):
return cmap
if isinstance(cmap, (matplotlib.colors.LinearSegmentedColormap)):
cmap = cmap(range(DEFAULT_CMAP_RANGE))
return ListedColormap(cmap)
return matplotlib.colors.ListedColormap(cmap)
if isinstance(cmap, list):
cmap = list(map(select_color, cmap))
return ListedColormap(cmap)
return matplotlib.colors.ListedColormap(cmap)
return None
@ -800,7 +798,7 @@ def _load_cmap(config):
if "cmap" not in config:
return get_cmap()
cmap = config["cmap"]
return ListedColormap(cmap)
return matplotlib.colors.ListedColormap(cmap)
def load_data(g, data):

Wyświetl plik

@ -2,7 +2,7 @@
"""Samila params."""
import math
from enum import Enum
from matplotlib import colors as mcolors
import matplotlib
SAMILA_VERSION = "1.1" # pragma: no cover
@ -30,7 +30,10 @@ DEFAULT_PROJECTION = "rectilinear"
DEFAULT_MARKER = "."
SEED_LOWER_BOUND = 0
SEED_UPPER_BOUND = 2**20
VALID_COLORS = list(dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS).keys())
VALID_COLORS = list(
dict(
matplotlib.colors.BASE_COLORS,
**matplotlib.colors.CSS4_COLORS).keys())
HEX_COLOR_PATTERN = r'^#(?:[0-9a-fA-F]{3}){1,2}$'
NFT_STORAGE_API = "https://api.nft.storage/upload"
NFT_STORAGE_LINK = "https://ipfs.io/ipfs/{}"
@ -57,6 +60,7 @@ class Projection(Enum):
"""
Samila Projection type class.
>>> import samila
>>> projection = samila.Projection.POLAR
"""
@ -74,6 +78,7 @@ class Marker(Enum):
"""
Samila Marker type class.
>>> import samila
>>> marker = samila.Marker.POINT
"""

Wyświetl plik

@ -7,7 +7,7 @@
>>> import socket
>>> import json
>>> import sys
>>> from matplotlib.colors import Colormap, ListedColormap
>>> import matplotlib
>>> def guard(*args, **kwargs):
... raise Exception("No internet connection!")
>>> from samila import GenerativeImage, Projection, Marker
@ -309,7 +309,7 @@ False
>>> g = GenerativeImage(config=open("config.json", 'r'))
>>> g = GenerativeImage()
>>> g.generate()
>>> cm = Colormap(name="Purples")
>>> cm = matplotlib.colors.Colormap(name="Purples")
>>> g.plot(cmap=cm)
>>> result = g.save_config("config.json")
>>> result["status"]
@ -326,10 +326,10 @@ True
>>> g_.cmap.colors == g.cmap.colors
True
>>> g.plot(cmap="Purples")
>>> cm = Colormap(name="viridis")
>>> cm = matplotlib.colors.Colormap(name="viridis")
>>> g.plot(cmap=cm)
>>> cmap = [[0.7, 0.2, 0.2, 1], [0.6, 0.2, 0.2, 1], [0.3, 0.2, 0.2, 1], [0.2, 0.2, 0.2, 1]]
>>> g.plot(cmap=ListedColormap(cmap))
>>> g.plot(cmap=matplotlib.colors.ListedColormap(cmap))
>>> g = GenerativeImage()
>>> g.generate()
>>> g.plot(cmap=cmap, color=g.data1)