Skip to content

Commit

Permalink
Drop support for Python 3.7 (pasqal-io#513)
Browse files Browse the repository at this point in the history
* Dropping support for python 3.7

* Using pos-only arguments in binary operators

---------

Co-authored-by: Antoine Cornillot <[email protected]>
  • Loading branch information
HGSilveri and a-corni authored May 2, 2023
1 parent 2bc2975 commit ea0cc42
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.11"]
python-version: ["3.8", "3.11"]
steps:
- name: Check out Pulser
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Check out Pulser
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Check out Pulser
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ For a comprehensive overview of Pulser, check out [Pulser's white paper](https:/

**Note**: *Pulser v0.6 introduced a split of the ``pulser`` package that prevents it from being correctly upgraded. If you have an older version of ``pulser`` installed and wish to upgrade, make sure to uninstall it first by running ``pip uninstall pulser``.*

To install the latest release of ``pulser``, have Python 3.7.0 or higher installed, then use ``pip``:
To install the latest release of ``pulser``, have Python 3.8 or higher installed, then use ``pip``:

```bash
pip install pulser
Expand Down
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Installation

before proceeding to any of the steps below.

To install the latest release of ``pulser``, have Python 3.7.0 or higher
To install the latest release of ``pulser``, have Python 3.8 or higher
installed, then use ``pip``: ::

pip install pulser
Expand Down
15 changes: 1 addition & 14 deletions pulser-core/pulser/channels/base_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import warnings
from abc import ABC, abstractmethod
from dataclasses import dataclass, field, fields
from sys import version_info
from typing import Any, Optional, Type, TypeVar, cast
from typing import Any, Literal, Optional, Type, TypeVar, cast

import numpy as np
from numpy.typing import ArrayLike
Expand All @@ -29,18 +28,6 @@
from pulser.json.utils import obj_to_dict
from pulser.pulse import Pulse

if version_info[:2] >= (3, 8): # pragma: no cover
from typing import Literal
else: # pragma: no cover
try:
from typing_extensions import Literal # type: ignore
except ImportError:
raise ImportError(
"Using pulser with Python version 3.7 requires the"
" `typing_extensions` module. Install it by running"
" `pip install typing-extensions`."
)

# Warnings of adjusted waveform duration appear just once
warnings.filterwarnings("once", "A duration of")

Expand Down
15 changes: 1 addition & 14 deletions pulser-core/pulser/devices/_device_datacls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
from abc import ABC, abstractmethod
from collections import Counter
from dataclasses import dataclass, field, fields
from sys import version_info
from typing import Any, cast
from typing import Any, Literal, cast, get_args

import numpy as np
from scipy.spatial.distance import pdist, squareform
Expand All @@ -32,18 +31,6 @@
from pulser.register.mappable_reg import MappableRegister
from pulser.register.register_layout import COORD_PRECISION, RegisterLayout

if version_info[:2] >= (3, 8): # pragma: no cover
from typing import Literal, get_args
else: # pragma: no cover
try:
from typing_extensions import Literal, get_args # type: ignore
except ImportError:
raise ImportError(
"Using pulser with Python version 3.7 requires the"
" `typing_extensions` module. Install it by running"
" `pip install typing-extensions`."
)

DIMENSIONS = Literal[2, 3]


Expand Down
29 changes: 14 additions & 15 deletions pulser-core/pulser/parametrized/paramobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
class OpSupport:
"""Methods for supporting operators on parametrized objects."""

# TODO: Make operator methods' args pos-only when python 3.7 is dropped
# Unary operators
def __neg__(self) -> ParamObj:
return ParamObj(operator.neg, self)
Expand Down Expand Up @@ -93,46 +92,46 @@ def tan(self) -> ParamObj:
return ParamObj(np.tan, self)

# Binary operators
def __add__(self, other: Union[int, float]) -> ParamObj:
def __add__(self, other: Union[int, float], /) -> ParamObj:
return ParamObj(operator.add, self, other)

def __radd__(self, other: Union[int, float]) -> ParamObj:
def __radd__(self, other: Union[int, float], /) -> ParamObj:
return ParamObj(operator.add, other, self)

def __sub__(self, other: Union[int, float]) -> ParamObj:
def __sub__(self, other: Union[int, float], /) -> ParamObj:
return ParamObj(operator.sub, self, other)

def __rsub__(self, other: Union[int, float]) -> ParamObj:
def __rsub__(self, other: Union[int, float], /) -> ParamObj:
return ParamObj(operator.sub, other, self)

def __mul__(self, other: Union[int, float]) -> ParamObj:
def __mul__(self, other: Union[int, float], /) -> ParamObj:
return ParamObj(operator.mul, self, other)

def __rmul__(self, other: Union[int, float]) -> ParamObj:
def __rmul__(self, other: Union[int, float], /) -> ParamObj:
return ParamObj(operator.mul, other, self)

def __truediv__(self, other: Union[int, float]) -> ParamObj:
def __truediv__(self, other: Union[int, float], /) -> ParamObj:
return ParamObj(operator.truediv, self, other)

def __rtruediv__(self, other: Union[int, float]) -> ParamObj:
def __rtruediv__(self, other: Union[int, float], /) -> ParamObj:
return ParamObj(operator.truediv, other, self)

def __floordiv__(self, other: Union[int, float]) -> ParamObj:
def __floordiv__(self, other: Union[int, float], /) -> ParamObj:
return (self / other).__floor__()

def __rfloordiv__(self, other: Union[int, float]) -> ParamObj:
def __rfloordiv__(self, other: Union[int, float], /) -> ParamObj:
return (other / self).__floor__()

def __pow__(self, other: Union[int, float]) -> ParamObj:
def __pow__(self, other: Union[int, float], /) -> ParamObj:
return ParamObj(operator.pow, self, other)

def __rpow__(self, other: Union[int, float]) -> ParamObj:
def __rpow__(self, other: Union[int, float], /) -> ParamObj:
return ParamObj(operator.pow, other, self)

def __mod__(self, other: Union[int, float]) -> ParamObj:
def __mod__(self, other: Union[int, float], /) -> ParamObj:
return ParamObj(operator.mod, self, other)

def __rmod__(self, other: Union[int, float]) -> ParamObj:
def __rmod__(self, other: Union[int, float], /) -> ParamObj:
return ParamObj(operator.mod, other, self)


Expand Down
14 changes: 1 addition & 13 deletions pulser-core/pulser/register/register_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from collections.abc import Sequence as abcSequence
from dataclasses import dataclass
from functools import cached_property
from hashlib import sha256
from sys import version_info
from typing import Any, Optional, cast

import matplotlib.pyplot as plt
Expand All @@ -32,18 +32,6 @@
from pulser.register.register import Register
from pulser.register.register3d import Register3D

if version_info[:2] >= (3, 8): # pragma: no cover
from functools import cached_property
else: # pragma: no cover
try:
from backports.cached_property import cached_property # type: ignore
except ImportError:
raise ImportError(
"Using pulser with Python version 3.7 requires the"
" `backports.cached-property` module. Install it by running"
" `pip install backports.cached-property`."
)

COORD_PRECISION = 6


Expand Down
15 changes: 2 additions & 13 deletions pulser-core/pulser/sequence/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
import os
import warnings
from collections.abc import Iterable, Mapping
from sys import version_info
from typing import (
Any,
Generic,
Literal,
Optional,
Tuple,
TypeVar,
Union,
cast,
get_args,
overload,
)

Expand Down Expand Up @@ -58,18 +59,6 @@
from pulser.sequence._seq_drawer import Figure, draw_sequence
from pulser.sequence._seq_str import seq_to_str

if version_info[:2] >= (3, 8): # pragma: no cover
from typing import Literal, get_args
else: # pragma: no cover
try:
from typing_extensions import Literal, get_args # type: ignore
except ImportError:
raise ImportError(
"Using pulser with Python version 3.7 requires the"
" `typing_extensions` module. Install it by running"
" `pip install typing-extensions`."
)

DeviceType = TypeVar("DeviceType", bound=BaseDevice)

PROTOCOLS = Literal["min-delay", "no-delay", "wait-for-all"]
Expand Down
14 changes: 1 addition & 13 deletions pulser-core/pulser/waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import sys
import warnings
from abc import ABC, abstractmethod
from sys import version_info
from functools import cached_property
from types import FunctionType
from typing import TYPE_CHECKING, Any, Optional, Tuple, Union, cast

Expand All @@ -40,18 +40,6 @@
if TYPE_CHECKING:
from pulser.channels.base_channel import Channel

if version_info[:2] >= (3, 8): # pragma: no cover
from functools import cached_property
else: # pragma: no cover
try:
from backports.cached_property import cached_property # type: ignore
except ImportError:
raise ImportError(
"Using pulser with Python version 3.7 requires the"
" `backports.cached-property` module. Install it by running"
" `pip install backports.cached-property`."
)


class Waveform(ABC):
"""The abstract class for a pulse's waveform."""
Expand Down
2 changes: 0 additions & 2 deletions pulser-core/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ matplotlib
# Numpy 1.20 introduces type hints, 1.24.0 breaks matplotlib < 3.6.1
numpy >= 1.20, != 1.24.0
scipy
backports.cached-property; python_version == '3.7'
typing-extensions; python_version == '3.7'
2 changes: 1 addition & 1 deletion pulser-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
author="Pulser Development Team",
python_requires=">=3.7.0",
python_requires=">=3.8",
license="Apache 2.0",
classifiers=[
"Development Status :: 3 - Alpha",
Expand Down
2 changes: 1 addition & 1 deletion pulser-pasqal/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
author="Pulser Development Team",
python_requires=">=3.7.0",
python_requires=">=3.8",
license="Apache 2.0",
classifiers=[
"Development Status :: 3 - Alpha",
Expand Down
15 changes: 1 addition & 14 deletions pulser-simulation/pulser_simulation/simconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,11 @@
from __future__ import annotations

from dataclasses import dataclass, field
from sys import version_info
from typing import Any, Optional, Union
from typing import Any, Literal, Optional, Union, get_args

import numpy as np
import qutip

if version_info[:2] >= (3, 8): # pragma: no cover
from typing import Literal, get_args
else: # pragma: no cover
try:
from typing_extensions import Literal, get_args # type: ignore
except ImportError:
raise ImportError(
"Using pulser with Python version 3.7 requires the"
" `typing_extensions` module. Install it by running"
" `pip install typing-extensions`."
)

NOISE_TYPES = Literal[
"doppler", "amplitude", "SPAM", "dephasing", "depolarizing", "eff_noise"
]
Expand Down
1 change: 0 additions & 1 deletion pulser-simulation/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
qutip>=4.7.1
typing-extensions; python_version == '3.7'
2 changes: 1 addition & 1 deletion pulser-simulation/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
author="Pulser Development Team",
python_requires=">=3.7.0",
python_requires=">=3.8",
license="Apache 2.0",
classifiers=[
"Development Status :: 3 - Alpha",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
author="Pulser Development Team",
python_requires=">=3.7.0",
python_requires=">=3.8",
license="Apache 2.0",
classifiers=[
"Development Status :: 3 - Alpha",
Expand Down

0 comments on commit ea0cc42

Please sign in to comment.