Skip to content

Commit 56926b1

Browse files
authored
Merge pull request #10 from linien-org/release/1.2.0
Release v1.2.0
2 parents 2203037 + 6778d69 commit 56926b1

File tree

12 files changed

+82
-156
lines changed

12 files changed

+82
-156
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,3 @@ $RECYCLE.BIN/
199199
# Windows shortcuts
200200
*.lnk
201201

202-
# Custom rules
203-
pyrp3/_version.py

pyrp3/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
import importlib_metadata
2-
3-
__version__ = importlib_metadata.version("pyrp3") # noqa: F401
1+
from ._version import __version__ # noqa F401

pyrp3/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "1.1.1"

pyrp3/client_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33

4-
class ClientMemory(object):
4+
class ClientMemory:
55
def __init__(self, remote_connection):
66
self.remote_connection = remote_connection
77
self.remote_interface = remote_connection.root.mem()

pyrp3/enum/enum.py renamed to pyrp3/enum.py

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,6 @@ def __call__(cls, key=None):
5757
return cls._reverse_dct[int(key)]
5858

5959

60-
class FullEnumMetaclass(EnumMetaclass):
61-
"""Metaclass for full enumerations.
62-
63-
A full enumeration displays all the values defined in base classes.
64-
"""
65-
66-
def __init__(cls, name, bases, dict):
67-
super(FullEnumMetaclass, cls).__init__(name, bases, dict)
68-
for obj in cls.__mro__:
69-
if isinstance(obj, EnumMetaclass):
70-
cls._reverse_dct.update(obj._reverse_dct)
71-
for attr in obj._members:
72-
# XXX inefficient
73-
if attr not in cls._members:
74-
cls._members.append(attr)
75-
76-
7760
class EnumInstance(int):
7861
"""Class to represent an enumeration value.
7962
@@ -99,96 +82,3 @@ def __str__(self):
9982

10083
class Enum(metaclass=EnumMetaclass):
10184
pass
102-
103-
104-
class FullEnum(metaclass=FullEnumMetaclass):
105-
pass
106-
107-
108-
def _test():
109-
class Color(Enum):
110-
red = 1
111-
green = 2
112-
blue = 3
113-
114-
print(Color.red)
115-
116-
print(repr(Color.red))
117-
print(Color.red == Color.red)
118-
print(Color.red == Color.blue)
119-
print(Color.red == 1)
120-
print(Color.red == 2)
121-
122-
class ExtendedColor(Color):
123-
white = 0
124-
orange = 4
125-
yellow = 5
126-
purple = 6
127-
black = 7
128-
129-
print(ExtendedColor.orange)
130-
print(ExtendedColor.red)
131-
132-
print(Color.red == ExtendedColor.red)
133-
134-
class OtherColor(Enum):
135-
white = 4
136-
blue = 5
137-
138-
class MergedColor(Color, OtherColor):
139-
pass
140-
141-
print(MergedColor.red)
142-
print(MergedColor.white)
143-
144-
print(Color)
145-
print(ExtendedColor)
146-
print(OtherColor)
147-
print(MergedColor)
148-
149-
150-
def _test2():
151-
class Color(FullEnum):
152-
red = 1
153-
green = 2
154-
blue = 3
155-
156-
print(Color.red)
157-
158-
print(repr(Color.red))
159-
print(Color.red == Color.red)
160-
print(Color.red == Color.blue)
161-
print(Color.red == 1)
162-
print(Color.red == 2)
163-
164-
class ExtendedColor(Color):
165-
white = 0
166-
orange = 4
167-
yellow = 5
168-
purple = 6
169-
black = 7
170-
171-
print(ExtendedColor.orange)
172-
print(ExtendedColor.red)
173-
174-
print(Color.red == ExtendedColor.red)
175-
176-
class OtherColor(FullEnum):
177-
white = 4
178-
blue = 5
179-
180-
class MergedColor(Color, OtherColor):
181-
pass
182-
183-
print(MergedColor.red)
184-
print(MergedColor.white)
185-
186-
print(Color)
187-
print(ExtendedColor)
188-
print(OtherColor)
189-
print(MergedColor)
190-
191-
192-
if __name__ == "__main__":
193-
_test()
194-
_test2()

pyrp3/enum/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyrp3/instrument.py

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .memory import MemoryInterface
88

99

10-
class UnsignedInteger(object):
10+
class UnsignedInteger:
1111
def __init__(self, size):
1212
self.size = size
1313

@@ -18,7 +18,7 @@ def to_binary(self, val):
1818
return intbv(val, max=2**self.size, min=0)._val
1919

2020

21-
class SignedInteger(object):
21+
class SignedInteger:
2222
def __init__(self, size):
2323
self.size = size
2424

@@ -36,7 +36,6 @@ def to_binary(self, val):
3636
class EnumTypeWrapper(UnsignedInteger):
3737
def __init__(self, enum_type):
3838
self._enum_type = enum_type
39-
maximum = max(self._enum_type._reverse_dct.keys())
4039
size = int(ceil(log(16, 2)))
4140
super(EnumTypeWrapper, self).__init__(size=size)
4241

@@ -90,7 +89,7 @@ def to_binary(self, val):
9089
return out[32:]._val
9190

9291

93-
class RegisterProperty(object):
92+
class RegisterProperty:
9493
def __init__(self, addr, register_type, size=None):
9594
if isinstance(register_type, type) and issubclass(register_type, Enum):
9695
register_type = EnumTypeWrapper(register_type)
@@ -121,7 +120,7 @@ class GetSetRegister(SetRegister, GetRegister):
121120
pass
122121

123122

124-
class GetSetBit(object):
123+
class GetSetBit:
125124
def __init__(self, addr, pos, bit_type=None):
126125
self._bit_type = bit_type
127126
self.addr = addr
@@ -141,13 +140,6 @@ def __set__(self, instance, value):
141140
return instance.write(self.addr, int(new_value))
142141

143142

144-
# class EnumRegister(GetSetRegister):
145-
# def __init__(self, addr, enum_type):
146-
# assert issubclass(enum_type, Enum)
147-
# register_type = EnumType(enum_type)
148-
# super(EnumRegister, self).__init__(addr, register_type)
149-
150-
151143
class HK(MemoryInterface):
152144
def __init__(self, addr_base=0x40000000, **kwd):
153145
kwd["addr_base"] = addr_base
@@ -200,10 +192,10 @@ def __init__(self, addr_base=0x40400000, **kwd):
200192
class TriggerSource(Enum):
201193
none = 0
202194
immediately = 1
203-
chA_posedge = 2
204-
chA_negedge = 3
205-
chB_posedge = 4
206-
chB_negedge = 5
195+
cha_posedge = 2
196+
cha_negedge = 3
197+
chb_posedge = 4
198+
chb_negedge = 5
207199
ext_posedge = 6
208200
ext_negedge = 7
209201
awg_posedge = 8
@@ -248,7 +240,7 @@ def arm_trigger(self, v=True):
248240
dac2_on_ch1 = GetSetBit(0x50, pos=0)
249241
dac1_on_ch2 = GetSetBit(0x50, pos=1)
250242

251-
## Function specific to read the array of data
243+
# Function specific to read the array of data
252244
def get_rawdata(self, addr):
253245
x = self.reads(addr, self.data_length)
254246
y = x.copy()
@@ -295,7 +287,7 @@ def setup(self, frequency=1, trigger_source=TriggerSource.immediately):
295287
self.arm_trigger()
296288

297289
def rearm(self, frequency=None, trigger_source=8):
298-
if not frequency is None:
290+
if frequency is not None:
299291
self.frequency = frequency
300292
self.trigger_delay = self.data_length
301293
self.trigger_source = trigger_source
@@ -515,7 +507,7 @@ def setup(self, frequency=1):
515507
self.sm_reset = False
516508

517509
def trig(self, frequency=None):
518-
if not frequency is None:
510+
if frequency is not None:
519511
self.frequency = frequency
520512
self.start_offset = 0
521513
self.trig_selector = 1
@@ -582,15 +574,15 @@ def derivative(self, val):
582574

583575
def initialize(self, setpoint=None, integral=0, proportional=0, derivative=0):
584576
self.reset = True
585-
if not setpoint is None:
577+
if setpoint is not None:
586578
self.setpoint = setpoint
587579
self.integral = integral
588580
self.proportional = proportional
589581
self.derivative = derivative
590582
self.reset = False
591583

592584

593-
class InterfaceDescriptor(object):
585+
class InterfaceDescriptor:
594586
def __init__(self, cls, **kwd):
595587
self._cls = cls
596588
self.kwd = kwd
@@ -601,7 +593,7 @@ def __get__(self, instance, owner):
601593
return self._cls(parent_memory=instance, **self.kwd)
602594

603595

604-
class RedPitaya(object):
596+
class RedPitaya:
605597
hk = InterfaceDescriptor(HK)
606598
ams = InterfaceDescriptor(AMS)
607599
scope = InterfaceDescriptor(Scope)
@@ -613,21 +605,10 @@ class RedPitaya(object):
613605
asgb = InterfaceDescriptor(ASG, channel="B")
614606

615607

616-
# class BoardRedPitaya(RedPitaya, BoardRawMemory):
617-
# pass
618-
619-
620-
# class PCRedPitaya(RedPitaya, ClientMemory):
621-
# pass
622-
623608
if __name__ == "__main__":
624609
from time import sleep, time
625610

626-
import rpyc
627-
628-
# conn = rpyc.connect('134.157.6.206', 18861)
629-
# red_pitaya = PCRedPitaya(remote_connection = conn)
630-
red_pitaya = BoardRedPitaya()
611+
red_pitaya = RedPitaya()
631612
red_pitaya.scope.arm_trigger()
632613
red_pitaya.scope.trigger_source = 1
633614
sleep(1)

pyrp3/memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class MemoryInterface(object):
1+
class MemoryInterface:
22
def __init__(self, addr_base=0x00000000, parent_memory=None):
33
self.addr_base = addr_base
44
self._parent = parent_memory

pyrp3/raw_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Specify output types of read_value to uint32
1616

1717

18-
class BoardRawMemory(object):
18+
class BoardRawMemory:
1919
"""Classes uses to interface de RedPitaya memory
2020
2121
This is a one to one match to the libmonitor.so library"""

setup.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
1+
import re
12
from distutils.core import Extension, setup
23
from pathlib import Path
34

5+
# from https://stackoverflow.com/a/7071358/2750945
6+
VERSIONFILE = "pyrp3/_version.py"
7+
verstrline = open(VERSIONFILE, "rt").read()
8+
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
9+
mo = re.search(VSRE, verstrline, re.M)
10+
if mo:
11+
verstr = mo.group(1)
12+
else:
13+
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
414
this_directory = Path(__file__).parent
515
long_description = (this_directory / "README.rst").read_text()
616

717
setup(
818
name="pyrp3",
9-
version="1.1.1",
19+
version="1.2.0",
1020
description="Python utilities for redpitaya",
1121
author="Pierre Cladé",
1222
author_email="[email protected]",
1323
maintainer="Bastian Leykauf",
1424
maintainer_email="[email protected]",
1525
long_description=long_description,
1626
long_description_content_type="text/x-rst",
17-
packages=["pyrp3", "pyrp3.enum"],
18-
install_requires=["myhdl", "rpyc", "cached_property", "numpy"],
27+
packages=["pyrp3"],
28+
python_requires=">=3.5",
29+
install_requires=[
30+
"myhdl>=0.11",
31+
"rpyc>=4.0,<5.0",
32+
"cached_property>=1.5.2",
33+
"numpy>=1.11.0",
34+
],
1935
classifiers=[
2036
"Intended Audience :: Developers",
2137
"Intended Audience :: Education",

0 commit comments

Comments
 (0)