From 8a31f47357e6811fcf657bb15aa6b059d0fa9442 Mon Sep 17 00:00:00 2001 From: Borja Esteban Date: Wed, 16 Nov 2022 08:35:03 +0000 Subject: [PATCH 1/3] fix problems at genetics module --- src/gevopy/genetics.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/gevopy/genetics.py b/src/gevopy/genetics.py index 4d62e86..0dc81a8 100755 --- a/src/gevopy/genetics.py +++ b/src/gevopy/genetics.py @@ -50,6 +50,14 @@ def __array_finalize__(self, obj): if obj is None: return + def insert(self, index, value): + """Method insert is unsupported on chromosome types""" + raise AttributeError(f"Unsupported operation by '{self.__class__}'") + + def __delitem__(self, index): + """Method delitem is unsupported on chromosome types""" + raise AttributeError(f"Unsupported operation by '{self.__class__}'") + def __mutate__(self): """Performs the chromosome mutation operation. :return: Chromosome with mutated values @@ -200,7 +208,7 @@ class GenotypeModel(BaseModel): generation: PositiveInt = Field(default=1) score: float = None - class Config: + class Config: # pylint: disable=missing-class-docstring json_encoders = {Chromosome: lambda x: x.astype("uint8").tolist()} def clone(self): @@ -218,7 +226,4 @@ def __repr__(self): together with the phenotype id. :return: String representing the genotype instance (phenotype) """ - return "{name} {id}".format( - name=self.__class__.__name__, - id=self.id, - ) + return f"{self.__class__.__name__} {self.id}" From 62b6f36dec04ac0598b92045e0c88de5d2909db7 Mon Sep 17 00:00:00 2001 From: Borja Esteban Date: Wed, 16 Nov 2022 08:36:39 +0000 Subject: [PATCH 2/3] add id to good-names in pylint --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 8f45a62..6625e53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,3 +28,4 @@ addopts = ["--import-mode=importlib"] [tool.pylint.messages_control] extension-pkg-whitelist = "pydantic" +good-names = ["id"] From 0a69de52ac5bbe85668b7fc8f5ed1286010615a6 Mon Sep 17 00:00:00 2001 From: Borja Esteban Date: Wed, 16 Nov 2022 09:14:41 +0000 Subject: [PATCH 3/3] Add python-publish workflow --- .github/workflows/python-publish.yml | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..bdaab28 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,39 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }}