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

chore: refactor #26

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.2
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi, jupyter ]
args: [ "--fix"]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
7 changes: 0 additions & 7 deletions pyaer/__about__.py

This file was deleted.

23 changes: 7 additions & 16 deletions pyaer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
"""Properly init the package.

Author: Yuhuang Hu
Email : duguyue100@gmail.com
"""
from __future__ import absolute_import
from __future__ import print_function

import os

from pyaer import log
from pyaer.__about__ import __author__ # noqa
from pyaer.__about__ import __version__ # noqa

FILE_PATH = os.path.realpath(__file__)
CURR_PATH = os.path.dirname(os.path.realpath(__file__))
PKG_PATH = os.path.dirname(CURR_PATH)

# System logging level

LOG_LEVEL = log.DEBUG

try:
from pyaer import libcaer_wrap as libcaer # noqa
from pyaer import libcaer_wrap as libcaer
except ImportError:
raise ImportError(
"libcaer might not be in the LD_LIBRARY_PATH "
"or your numpy might not be the required version. "
"Try to load _libcaer_wrap.so from the package "
"directory, this will provide more information."
)

from pyaer.event_camera import EventCamera # noqa # noreorder


__all__ = ["libcaer", "EventCamera"]
32 changes: 13 additions & 19 deletions pyaer/comm.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
"""Communication Module.

This script includes class definitions for communication
between processes. Example usage is to have a process for
fetching data from the event cameras and other processes for
processing the data.
The communication protocol is implemented through zeromq package.

The design principle is similar to ROS where there is a hub for
central scheduling, a group of publishers for sending data, and
a group of subscribers to get/process data.

Author: Yuhuang Hu
Email : yuhuang.hu@ini.uzh.ch
This script includes class definitions for communication between processes. Example
usage is to have a process for fetching data from the event cameras and other processes
for processing the data. The communication protocol is implemented through zeromq
package.

The design principle is similar to ROS where there is a hub for central scheduling, a
group of publishers for sending data, and a group of subscribers to get/process data.
"""

import json
import signal
import subprocess
Expand All @@ -25,6 +21,7 @@
import numpy as np
import zmq


try:
import zarr
except Exception:
Expand Down Expand Up @@ -181,7 +178,6 @@ def __init__(
name : str
the name of the publisher
"""

self.__dict__.update(kwargs)

self.url = url
Expand Down Expand Up @@ -271,7 +267,7 @@ def __init__(
port=5100,
master_topic="",
name="",
**kwargs
**kwargs,
):
"""AERPublisher.

Expand Down Expand Up @@ -605,15 +601,14 @@ def __init__(
sub_port=5099,
sub_topic="",
sub_name="",
**kwargs
**kwargs,
):
"""Publisher-Subscriber.

This is a shell implementation.

Intend to use as a processing unit.
First subscribe on a topic, process it, and then publish to
a topic
Intend to use as a processing unit. First subscribe on a topic, process it, and
then publish to a topic
"""
self.__dict__.update(kwargs)

Expand Down Expand Up @@ -760,7 +755,6 @@ def get_keys(self):

def get_frame(self, device_name, group_name):
"""Get frame events at this packet."""

try:
frame_events = self.aer_file[device_name][group_name]["frame_events"][()]

Expand Down
2 changes: 2 additions & 0 deletions pyaer/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DISABLE_MAX_CONTAINER_SIZE = 0
DEFAULT_MAX_PACKET_INTERVAL = 10000 # 10ms
11 changes: 1 addition & 10 deletions pyaer/container.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
"""Event Container.

Motivation: After the events are read from the event packet,
it's difficult to use and less informative to return them
as single variables, therefore, I decide to introduce a
container that can manage all the returned Python variables.

Author: Yuhuang Hu
Email : duguyue100@gmail.com
"""
from __future__ import annotations

from typing import Optional

Expand Down
9 changes: 2 additions & 7 deletions pyaer/davis.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"""DAVIS Camera.
from __future__ import annotations

Author: Yuhuang Hu
Email : duguyue100@gmail.com
"""
import numpy as np

from pyaer import libcaer
Expand Down Expand Up @@ -855,7 +852,6 @@ def get_bias(self):
bias_obj: `dict`<br/>
dictionary that contains DAVIS current bias settings.
"""

bias_obj = {}
# output sources
bias_obj["aps_enabled"] = self.get_config(
Expand Down Expand Up @@ -1310,7 +1306,6 @@ def get_event_container(self):

Instead of returning different variables, return an event container.
"""

data = self.get_event()

if data is None:
Expand Down Expand Up @@ -1447,7 +1442,7 @@ def get_event(self, mode="events"):
num_imu_event,
)
else:
return None,0,None,0,None,0,None,0
return None, 0, None, 0, None, 0, None, 0


class DAVISFX2(DAVIS):
Expand Down
Loading
Loading