Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Python 3.9 support #178

Merged
merged 6 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{matrix.os}}
Expand All @@ -30,12 +30,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install -e ".[dev]"
python -m pip install --upgrade uv
uv pip install -e ".[dev]" --system
- name: Check package versions
run: |
pip show -V elementembeddings
pip show -V pytest
pip show -V matplotlib
uv pip show -V elementembeddings
uv pip show -V pytest
uv pip show -V matplotlib

- name: Run tests
run: python -m pytest --mpl --mpl-baseline-path=src/elementembeddings/tests/baseline --cov=src/elementembeddings --cov-report=xml -v
Expand Down
63 changes: 61 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,73 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools"] # PEP 508 specifications.
requires = ["setuptools>=65.0.0"] # PEP 508 specifications.
build-backend = "setuptools.build_meta"

[project]
name = "ElementEmbeddings"
version = "0.6.1"
description = "Element Embeddings"
readme = "README.md"
requires-python = ">=3.10"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Dependencies not ready for Python 3.13

While the project declares Python 3.13 support, several key dependencies don't explicitly support Python 3.13 yet:

  • pymatgen (up to 3.12)
  • seaborn (up to 3.12)
  • umap-learn (up to 3.12)
  • llvmlite (up to 3.12)
  • adjustText (no version info)
  • openTSNE (generic Python 3)

Consider removing Python 3.13 from classifiers until these dependencies add support for it.

🔗 Analysis chain

Verify Python version compatibility

The Python version requirement and classifiers align with dropping Python 3.9 support. However, ensure all dependencies support Python 3.13.

Run this script to check dependency compatibility with Python 3.13:

Also applies to: 16-21

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check dependency compatibility with Python 3.13
# Test: Extract dependencies and check their Python version support

# Get all dependencies
rg '^    "[^"]+[>=<]+[0-9.]+' pyproject.toml | while read -r dep; do
    pkg=$(echo "$dep" | sed 's/^    "\([^"]*\)[>=<].*/\1/')
    echo "Checking $pkg..."
    curl -s "https://pypi.org/pypi/$pkg/json" | jq -r '.info.classifiers[] | select(contains("Programming Language :: Python"))'
done

Length of output: 3305


Script:

#!/bin/bash
# Description: Check dependency compatibility with Python 3.13 (fixed version)
# Get all dependencies including optional ones
rg '^    "[^"]+"' pyproject.toml | sed 's/^    "\([^"]*\).*/\1/' | while read -r pkg; do
    # Skip empty lines and section headers
    if [[ -z "$pkg" || "$pkg" == "["* ]]; then
        continue
    fi
    echo "Checking $pkg..."
    curl -s "https://pypi.org/pypi/${pkg%,}/json" | jq -r '.info.classifiers[] | select(contains("Programming Language :: Python :: 3"))'
done

Length of output: 32163


Script:

#!/bin/bash
# Description: Check dependency compatibility with Python 3.13 (improved version)
# Get dependencies section only
echo "Main dependencies:"
rg '^\[project\.dependencies\]' -A 50 pyproject.toml | while read -r line; do
    if [[ $line == "["* && $line != "[project.dependencies]" ]]; then
        break
    fi
    if [[ $line =~ ^\"([^\"]+)\" ]]; then
        pkg="${BASH_REMATCH[1]}"
        echo "Checking $pkg..."
        curl -s "https://pypi.org/pypi/$pkg/json" | jq -r '.info.classifiers[] | select(contains("Programming Language :: Python :: 3"))'
        echo "---"
    fi
done

Length of output: 116


Script:

#!/bin/bash
# First, let's see the content structure
echo "File content:"
cat pyproject.toml
echo -e "\n=== Now checking dependencies ===\n"
# Extract dependencies using a simpler pattern
cat pyproject.toml | awk '/^dependencies = \[/,/\]/' | grep '"' | tr -d '", ' | while read -r pkg; do
    if [[ $pkg == *"="* ]]; then
        pkg=${pkg%%=*}
    fi
    if [[ -n $pkg ]]; then
        echo "Checking $pkg..."
        curl -s "https://pypi.org/pypi/$pkg/json" | jq -r '.info.classifiers[] | select(contains("Programming Language :: Python :: 3"))'
        echo "---"
    fi
done

Length of output: 11297


Script:

#!/bin/bash
# Check main dependencies for Python 3.13 support
echo "Checking core dependencies for Python 3.13 support:"
for pkg in numpy scipy pymatgen seaborn matplotlib scikit-learn umap-learn adjustText openTSNE typing-extensions llvmlite; do
    echo "=== Checking $pkg ==="
    curl -s "https://pypi.org/pypi/$pkg/json" | jq -r '.info.classifiers[] | select(contains("Programming Language :: Python :: 3"))'
    echo "---"
done

Length of output: 5712

license = { text = "MIT" }
authors = [
{ name = "Anthony O. Onwuli", email = "[email protected]" }
]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Chemistry",
"License :: OSI Approved :: MIT License",
]
dependencies = [
"numpy>=1.23.3,<3",
"scipy>=1.10.1",
"pymatgen>2022.9.21",
"seaborn>=0.13.0",
"matplotlib>=3.7.1",
"scikit-learn>=1.3.0",
"umap-learn>=0.5.3",
"adjustText>=0.8",
"openTSNE>=1.0.0",
"typing-extensions",
"llvmlite>=0.40",
]

[project.optional-dependencies]
dev = [
"pre-commit",
"black",
"isort",
"pytest",
"pytest-subtests",
"nbqa",
"flake8",
"pyupgrade",
"autopep8",
"pytest-cov",
"pytest-mpl",
]
docs = [
"mkdocs",
"mkdocs-material",
"mkdocstrings",
"mkdocstrings-python",
"mike",
"mkdocs-jupyter",
]

[tool.semantic_release]
version_variable = "setup.py:__version__"
version_source = "tag"

[tool.ruff]
target-version = "py39"
target-version = "py310"
line-length = 120
force-exclude = true

Expand Down
82 changes: 0 additions & 82 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/elementembeddings/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def standardise(self, inplace: bool = False):
embeddings_copy = self.embeddings.copy()
embeddings_array = np.array(list(embeddings_copy.values()))
embeddings_array = StandardScaler().fit_transform(embeddings_array)
for el, emb in zip(embeddings_copy.keys(), embeddings_array):
for el, emb in zip(embeddings_copy.keys(), embeddings_array, strict=False):
embeddings_copy[el] = emb
if inplace:
self.embeddings = embeddings_copy
Expand Down
2 changes: 1 addition & 1 deletion src/elementembeddings/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def standardise(self, inplace: bool = False):
embeddings_copy = self.embeddings.copy()
embeddings_array = np.array(list(embeddings_copy.values()))
embeddings_array = StandardScaler().fit_transform(embeddings_array)
for el, emb in zip(embeddings_copy.keys(), embeddings_array):
for el, emb in zip(embeddings_copy.keys(), embeddings_array, strict=False):
embeddings_copy[el] = emb

if inplace:
Expand Down
2 changes: 1 addition & 1 deletion src/elementembeddings/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def dimension_plotter(

species_labels = [
rf"$\mathregular{{{element}^{{{abs(charge)}{sign}}}}}$"
for (element, charge), sign in zip(parsed_species, signs)
for (element, charge), sign in zip(parsed_species, signs, strict=False)
]

texts = [ax.text(df["x"][i], df["y"][i], species_labels[i], fontsize=12) for i in range(len(df))]
Expand Down
Loading