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

87 make hdf datasets always be float64 unless they are pcap bits #93

12 changes: 6 additions & 6 deletions .github/pages/make_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
from argparse import ArgumentParser
from pathlib import Path
from subprocess import CalledProcessError, check_output
from typing import List, Optional
from typing import Optional


def report_output(stdout: bytes, label: str) -> List[str]:
def report_output(stdout: bytes, label: str) -> list[str]:
ret = stdout.decode().strip().split("\n")
print(f"{label}: {ret}")
return ret


def get_branch_contents(ref: str) -> List[str]:
def get_branch_contents(ref: str) -> list[str]:
"""Get the list of directories in a branch."""
stdout = check_output(["git", "ls-tree", "-d", "--name-only", ref])
return report_output(stdout, "Branch contents")


def get_sorted_tags_list() -> List[str]:
def get_sorted_tags_list() -> list[str]:
"""Get a list of sorted tags in descending order from the repository."""
stdout = check_output(["git", "tag", "-l", "--sort=-v:refname"])
return report_output(stdout, "Tags list")


def get_versions(ref: str, add: Optional[str]) -> List[str]:
def get_versions(ref: str, add: Optional[str]) -> list[str]:
"""Generate the file containing the list of all GitHub Pages builds."""
# Get the directories (i.e. builds) from the GitHub Pages branch
try:
Expand All @@ -41,7 +41,7 @@ def get_versions(ref: str, add: Optional[str]) -> List[str]:
tags = get_sorted_tags_list()

# Make the sorted versions list from main branches and tags
versions: List[str] = []
versions: list[str] = []
for version in ["master", "main"] + tags:
if version in builds:
versions.append(version)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
runs-on: ["ubuntu-latest"] # can add windows-latest, macos-latest
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
include:
# Include one that runs in the dev environment
- runs-on: "ubuntu-latest"
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ name = "pandablocks"
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -18,7 +16,7 @@ dependencies = ["typing-extensions;python_version<'3.8'", "numpy", "click"]
dynamic = ["version"]
license.file = "LICENSE"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.9"

[project.optional-dependencies]
h5py = ["h5py", "matplotlib"]
Expand Down
12 changes: 6 additions & 6 deletions src/pandablocks/_control.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from string import digits
from typing import Dict, List, Optional
from typing import Optional

from .blocking import BlockingClient
from .commands import FieldInfo, GetBlockInfo, GetFieldInfo, Raw, is_multiline_command
Expand All @@ -25,7 +25,7 @@
STATIC_STAR_COMMANDS.append(f"*CHANGES{suff}=") # Reset reported changes


def _get_user_input(prompt) -> List[str]:
def _get_user_input(prompt) -> list[str]:
lines = [input(prompt)]
if is_multiline_command(lines[0]):
while lines[-1]:
Expand All @@ -39,30 +39,30 @@ def text_matches(t1, t2):

class BlockCompleter:
def __init__(self, client: BlockingClient):
self.matches: List[str] = []
self.matches: list[str] = []
self._client = client
self._blocks = self._client.send(
GetBlockInfo(skip_description=True), timeout=TIMEOUT
)
self._fields = self._get_fields(list(self._blocks))
# TODO: Extend use of _fields now we have enum labels available?

def _get_fields(self, blocks: List[str]) -> Dict[str, Dict[str, FieldInfo]]:
def _get_fields(self, blocks: list[str]) -> dict[str, dict[str, FieldInfo]]:
fields = self._client.send(
[GetFieldInfo(block, extended_metadata=False) for block in blocks],
timeout=TIMEOUT,
)
return dict(zip(blocks, fields))

def _with_suffixes(self, block: str, numbers: bool) -> List[str]:
def _with_suffixes(self, block: str, numbers: bool) -> list[str]:
block_info = self._blocks[block]
num = block_info.number
if numbers and num > 1:
return [f"{block}{i}" for i in range(1, num + 1)]
else:
return [block]

def _block_field_matches(self, text: str, prefix="") -> List[str]:
def _block_field_matches(self, text: str, prefix="") -> list[str]:
matches = []
text = text[len(prefix) :]
split = text.split(".", maxsplit=1)
Expand Down
11 changes: 6 additions & 5 deletions src/pandablocks/_exchange.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Generator, List, TypeVar, Union
from collections.abc import Generator
from typing import TypeVar, Union

T = TypeVar("T")

Expand All @@ -7,12 +8,12 @@ class Exchange:
"""A helper class representing the lines to send to PandA and
the lines received"""

def __init__(self, to_send: Union[str, List[str]]):
def __init__(self, to_send: Union[str, list[str]]):
if isinstance(to_send, str):
self.to_send = [to_send]
else:
self.to_send = to_send
self.received: List[str] = []
self.received: list[str] = []
self.is_multiline = False

@property
Expand All @@ -22,12 +23,12 @@ def line(self) -> str:
return self.received[0]

@property
def multiline(self) -> List[str]:
def multiline(self) -> list[str]:
"""Return the multiline received lines, processed to remove markup"""
assert self.is_multiline
# Remove the ! and . markup
return [line[1:] for line in self.received[:-1]]


Exchanges = Union[Exchange, List[Exchange]]
Exchanges = Union[Exchange, list[Exchange]]
ExchangeGenerator = Generator[Exchanges, None, T]
5 changes: 3 additions & 2 deletions src/pandablocks/asyncio.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import asyncio
import logging
from asyncio.streams import StreamReader, StreamWriter
from collections.abc import AsyncGenerator, Iterable
from contextlib import suppress
from typing import AsyncGenerator, Dict, Iterable, Optional
from typing import Optional

from .commands import Command, T
from .connections import ControlConnection, DataConnection
Expand Down Expand Up @@ -67,7 +68,7 @@ def __init__(self, host: str):
self._host = host
self._ctrl_connection = ControlConnection()
self._ctrl_task: Optional[asyncio.Task] = None
self._ctrl_queues: Dict[int, asyncio.Queue] = {}
self._ctrl_queues: dict[int, asyncio.Queue] = {}
self._ctrl_stream = _StreamHelper()

async def connect(self):
Expand Down
5 changes: 3 additions & 2 deletions src/pandablocks/blocking.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import socket
from typing import Iterable, Iterator, List, Optional, Union, overload
from collections.abc import Iterable, Iterator
from typing import Optional, Union, overload

from .commands import Command, T
from .connections import ControlConnection, DataConnection
Expand Down Expand Up @@ -69,7 +70,7 @@ def send(self, commands: Command[T], timeout: Optional[int] = None) -> T: ...
@overload
def send(
self, commands: Iterable[Command], timeout: Optional[int] = None
) -> List: ...
) -> list: ...

def send(
self,
Expand Down
6 changes: 3 additions & 3 deletions src/pandablocks/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import io
import logging
import pathlib
from typing import Awaitable, List
from collections.abc import Awaitable

import click
from click.exceptions import ClickException
Expand Down Expand Up @@ -69,7 +69,7 @@ def save(host: str, outfile: io.TextIOWrapper):
Save the current blocks configuration of HOST to OUTFILE
"""

async def _save(host: str) -> List[str]:
async def _save(host: str) -> list[str]:
async with AsyncioClient(host) as client:
return await client.send(GetState())

Expand All @@ -93,7 +93,7 @@ def load(host: str, infile: io.TextIOWrapper, tutorial: bool):
else:
state = infile.read().splitlines()

async def _load(host: str, state: List[str]):
async def _load(host: str, state: list[str]):
async with AsyncioClient(host) as client:
await client.send(SetState(state))

Expand Down
Loading
Loading