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

Fixed pylint errors #644

Merged
merged 37 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8dc55a3
Refactoring methods without arguments into functions.
mathisrichter Feb 25, 2023
f07e890
Raising ValueError instead of str.
mathisrichter Feb 25, 2023
7329baa
Defining members before use.
mathisrichter Feb 26, 2023
d5d0063
Fixed pylint error about non-callable variable.
mathisrichter Feb 26, 2023
c941cd5
Merge branch 'main' of https://github.com/lava-nc/lava into no_argume…
mathisrichter May 6, 2023
d6c702b
Fixed deprecation warning.
mathisrichter May 6, 2023
9133f25
Defined members before use.
mathisrichter May 6, 2023
da57ff9
Removed unused imports.
mathisrichter May 6, 2023
4fed421
Removed unused variables.
mathisrichter May 6, 2023
4973e54
Removed unnecessary pass statements.
mathisrichter May 7, 2023
f8f7b0c
Fixed attributes defined outside __init__.
mathisrichter May 8, 2023
39b829f
Activated linting checks in poetry.
mathisrichter May 8, 2023
1efa83e
Revert "Refactoring methods without arguments into functions."
mathisrichter May 8, 2023
4d9aff3
Deactivated flake8 plugins for now.
mathisrichter May 8, 2023
4af90ef
Fixed shadowing of built-in variable names.
mathisrichter May 8, 2023
dfcee1b
Fixed reimported modules.
mathisrichter May 8, 2023
22f4802
Explicitly disabling plugins again.
mathisrichter May 8, 2023
3479862
Fixed pointless string statement errors.
mathisrichter May 18, 2023
c1c24b8
Fixed linter errors for abstract methods.
mathisrichter May 18, 2023
7e4f403
Fixed renamed arguments.
mathisrichter May 18, 2023
6810666
Fixed calling init method of non-parent class.
mathisrichter May 18, 2023
38fa4cc
Fixed unit tests.
mathisrichter May 19, 2023
f6fcc63
Ignored linter errors with subprocess module.
mathisrichter May 19, 2023
aa8632b
Ignored linter error about renamed variable.
mathisrichter May 19, 2023
71cf62d
Added a description on linter ignore.
mathisrichter May 19, 2023
bfde547
Ignored arguments-differ linter error.
mathisrichter May 19, 2023
a4580cc
Fixed unused-variable linter error.
mathisrichter May 19, 2023
8a7927a
Merge branch 'main' of https://github.com/lava-nc/lava into no_argume…
mathisrichter May 19, 2023
4ff8ef8
Fixed linter errors.
mathisrichter May 19, 2023
f844501
Merge branch 'main' of https://github.com/lava-nc/lava into no_argume…
mathisrichter May 25, 2023
f71f3d2
Reverted linter changes in runtime to fix unit tests in lava-loihi.
mathisrichter May 26, 2023
5937131
Merge branch 'main' into no_argument_methods
mathisrichter May 26, 2023
458899a
Merge branch 'main' into no_argument_methods
mathisrichter May 26, 2023
e02062c
Fixed remark issues in Markdown files.
mathisrichter May 26, 2023
73e81a6
Merge branch 'no_argument_methods' of https://github.com/mathisrichte…
mathisrichter May 26, 2023
cb26d7f
Fixed remark issues in Markdown files.
mathisrichter May 26, 2023
4918f83
Fixed remark issues in Markdown files.
mathisrichter May 26, 2023
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
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ pep8-naming = ["-*"]
# mccabe = ["+*"]
# pep8-naming = ["+*"]
# pyflakes = ["+*"]
# pylint = ["+*"]
pylint = ["+*"]

pycodestyle = ["+*", "-W503", "-E203"]
pyflakes = ["-*"] # Disable temporarily until lint fix is pushed
pylint = ["-*"] # Disable temporarily until lint fix is pushed
# pyflakes = ["-*"] # Disable temporarily until lint fix is pushed
# pylint = ["-*"] # Disable temporarily until lint fix is pushed

[tool.flakeheaven.exceptions."tests/"]
pycodestyle = ["-F401"] # Disable a check
Expand Down
1 change: 0 additions & 1 deletion src/lava/magma/compiler/builders/channel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,3 @@ def build(
Exception
Can't build channel of type specified
"""
pass
2 changes: 0 additions & 2 deletions src/lava/magma/compiler/builders/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class AbstractBuilder(ABC):
@abstractmethod
def build(self):
"""Build the actual process."""
pass


class ResourceAddress(ABC):
Expand All @@ -24,7 +23,6 @@ class ResourceAddress(ABC):
class Resource(ABC):
def write(self, hw: ty.Any):
"""Given hw, write this compiled resource"""
pass


class CompiledResource(Resource):
Expand Down
22 changes: 13 additions & 9 deletions src/lava/magma/compiler/channels/pypychannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, name, shm, proto, size, req, ack):
self._done = False
self._array = []
self._semaphore = None
self.observer = None
self.observer: ty.Optional[ty.Callable[[], ty.Any]] = None
self.thread = None

@property
Expand Down Expand Up @@ -210,7 +210,7 @@ def __init__(self, name, shm, proto, size, req, ack):
self._done = False
self._array = []
self._queue = None
self.observer = None
self.observer: ty.Optional[ty.Callable[[], ty.Any]] = None
self.thread = None

@property
Expand Down Expand Up @@ -311,26 +311,30 @@ def _changed(self):
with self._cv:
self._cv.notify_all()

def _set_observer(self, channel_actions, observer):
@staticmethod
def _set_observer(
channel_actions: ty.Tuple,
observer: ty.Union[ty.Callable[[], ty.Any], None]) -> None:
for channel, _ in channel_actions:
channel.observer = observer

def select(
self,
*args: ty.Tuple[
ty.Union[CspSendPort, CspRecvPort], ty.Callable[[], ty.Any]
*channel_actions: ty.Tuple[
ty.Union[CspSendPort, CspRecvPort],
ty.Callable[[], ty.Any]
],
):
) -> None:
"""
Wait for any channel to become ready, then execute the corresponding
callable and return the result.
"""
with self._cv:
self._set_observer(args, self._changed)
self._set_observer(channel_actions, self._changed)
while True:
for channel, action in args:
for channel, action in channel_actions:
if channel.probe():
self._set_observer(args, None)
self._set_observer(channel_actions, None)
return action()
self._cv.wait()

Expand Down
2 changes: 1 addition & 1 deletion src/lava/magma/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def compile(
proc_builders, channel_map = self._compile_proc_groups(
proc_groups, channel_map
)
py_builders, c_builders, nc_builders = split_proc_builders_by_type(
_, c_builders, nc_builders = split_proc_builders_by_type(
proc_builders
)

Expand Down
1 change: 0 additions & 1 deletion src/lava/magma/compiler/compiler_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import itertools
import os
import pkgutil
import re
import sys
import types
import typing as ty
Expand Down
3 changes: 1 addition & 2 deletions src/lava/magma/compiler/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def map_cores(self, executable: Executable,
executable: Compiled Executable

"""
py_builders, c_builders, nc_builders = split_proc_builders_by_type(
_, c_builders, nc_builders = split_proc_builders_by_type(
executable.proc_builders)
# Iterate over all the ncbuilder and map them
for ncb in nc_builders.values():
Expand Down Expand Up @@ -124,7 +124,6 @@ def map_cores(self, executable: Executable,
# src or dst and its initializers
for port_pair in channel_map:
src = port_pair.src
dst = port_pair.dst
# Checking if the initializers are same
if channel_map[port_pair].src_port_initializer == ports[
port]:
Expand Down
5 changes: 2 additions & 3 deletions src/lava/magma/compiler/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from __future__ import annotations

import typing
import typing as ty
from collections import UserList, OrderedDict

Expand All @@ -27,7 +26,7 @@ def __init__(
processes: ty.List[AbstractProcess],
):
self.id: int = -1
self.node_type: typing.Type[AbstractNode] = node_type
self.node_type: ty.Type[AbstractNode] = node_type
self.processes = processes

def add_process(self, process: AbstractProcess):
Expand Down Expand Up @@ -57,7 +56,7 @@ def __str__(self):
result.append(str(self.node_map))
return "\n".join(result)

def append(self, node: Node):
def append(self, node: Node): # pylint: disable=arguments-renamed
"""Appends a new node to the NodeConfig."""
node.id = self._node_ctr
self._node_ctr += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ def from_channel_map(
src_pt_init.connected_port_type = LoihiConnectedPortType.C_PY
dst_pt_init.connected_port_type = LoihiConnectedPortType.C_PY
if ch_type is ChannelType.PyC:
p_port, c_port = src_port, dst_port
p_port = src_port
pi = dst_pt_init
else:
c_port, p_port = src_port, dst_port
p_port = dst_port
pi = src_pt_init
lt = getattr(p_port.process.model_class, p_port.name).cls
if lt in [PyInPort.VEC_DENSE, PyOutPort.VEC_DENSE]:
Expand Down
2 changes: 0 additions & 2 deletions src/lava/magma/compiler/subcompilers/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ class AbstractSubCompiler(ABC):
def compile(self, channel_map: ChannelMap) -> ChannelMap:
"""Partitions all Processes in the SubCompiler's ProcGroup onto the
available resources."""
pass

@abstractmethod
def get_builders(
self, channel_map: ChannelMap
) -> ty.Tuple[ty.Dict[AbstractProcess, AbstractProcessBuilder], ChannelMap]:
"""After compilation, creates and returns builders for all Processes."""
pass


class SubCompiler(AbstractSubCompiler):
Expand Down
2 changes: 0 additions & 2 deletions src/lava/magma/compiler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ class LoihiIOPortInitializer(LoihiPortInitializer):
@dataclass
class LoihiInPortInitializer(LoihiIOPortInitializer):
"""Port Initializer for a InPort for C/NC Models"""
pass


@dataclass
Expand All @@ -141,7 +140,6 @@ class LoihiCInPortInitializer(LoihiIOPortInitializer):
@dataclass
class LoihiOutPortInitializer(LoihiIOPortInitializer):
"""Port Initializer for a OutPort for C/NC Models"""
pass


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion src/lava/magma/core/learning/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# See: https://spdx.org/licenses/

from enum import IntEnum, auto
from enum import IntEnum
import lava.magma.core.learning.string_symbols as str_symbols

# ---------------------------------------------------------------------------
Expand Down
12 changes: 5 additions & 7 deletions src/lava/magma/core/learning/symbolic_equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# See: https://spdx.org/licenses/

import re
from abc import abstractmethod
from abc import ABC, abstractmethod
import typing as ty
import ast

import lava.magma.core.learning.string_symbols as str_symbols


class Symbol(object):
class Symbol(ABC):
"""Super class for all possible symbols."""

def __init__(self, expr: ty.Optional[str] = "") -> None:
Expand Down Expand Up @@ -50,8 +50,9 @@ def __str__(self):
pass

@staticmethod
def find_expr(expr: str, reg_expr: str, symbol: "Symbol") \
-> ty.Tuple[ty.Optional["Symbol"], str]:
def find_expr(expr: str,
reg_expr: str,
symbol: "Symbol") -> ty.Tuple[ty.Optional["Symbol"], str]:
"""Factory method for creating symbols.

Matches an expression to a regular expression and if there is a match,
Expand Down Expand Up @@ -132,7 +133,6 @@ def __str__(self) -> str:

class Operator(Symbol):
"""Abstract super class for operator Symbols."""
pass


class Addition(Operator):
Expand Down Expand Up @@ -231,8 +231,6 @@ def __str__(self):
class FactorSym(Symbol):
"""Abstract super class for factor Symbols."""

pass


class Dependency(FactorSym):
"""Abstract super class for dependency Symbols."""
Expand Down
1 change: 0 additions & 1 deletion src/lava/magma/core/learning/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import typing as ty
import struct


def stochastic_round(values: np.ndarray,
Expand Down
1 change: 0 additions & 1 deletion src/lava/magma/core/model/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def shape(self) -> ty.Tuple[int, ...]:
@abstractmethod
def csp_ports(self) -> ty.List[AbstractCspPort]:
"""Returns all csp ports of the port."""
pass

def start(self):
"""Start all csp ports."""
Expand Down
5 changes: 4 additions & 1 deletion src/lava/magma/core/model/py/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def _create_learning_rule_applier(
pass

@abstractmethod
def _init_randoms(self):
def _init_randoms(self) -> None:
pass

@property
Expand Down Expand Up @@ -1561,3 +1561,6 @@ def _saturate_synaptic_variable(
f"'tag_1', or 'tag_2'."
f"Got {synaptic_variable_name=}."
)

def _init_randoms(self) -> None:
pass
4 changes: 1 addition & 3 deletions src/lava/magma/core/model/py/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _get_var(self):
for value in var_iter:
data_port.send(enum_to_np(value, np.float64))
elif isinstance(var, csr_matrix):
dst, src, values = find(var, explicit_zeros=True)
_, _, values = find(var, explicit_zeros=True)
num_items = var.data.size
data_port.send(enum_to_np(num_items))
for value in values:
Expand Down Expand Up @@ -242,7 +242,6 @@ def add_ports_for_polling(self):
"""
Add various ports to poll for communication on ports
"""
pass

def join(self):
"""
Expand All @@ -257,7 +256,6 @@ def on_var_update(self):
"""This method is called if a Var is updated. It
can be used as callback function to calculate dependent
changes."""
pass


class PyLoihiProcessModel(AbstractPyProcessModel):
Expand Down
1 change: 0 additions & 1 deletion src/lava/magma/core/model/py/ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def csp_ports(self) -> ty.List[AbstractCspPort]:
-------
A list of all CSP Ports connected to the PyPort.
"""
pass


class AbstractPyIOPort(AbstractPyPort):
Expand Down
Loading