Skip to content

Commit

Permalink
bump nptyping (#722)
Browse files Browse the repository at this point in the history
* update nptyping

Signed-off-by: Andrey Parfenov <[email protected]>
  • Loading branch information
Andrey1994 authored May 9, 2024
1 parent 41c304e commit ea23a6f
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 84 deletions.
10 changes: 5 additions & 5 deletions python_package/brainflow/board_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pkg_resources
from brainflow.exit_codes import BrainFlowExitCodes, BrainFlowError
from brainflow.utils import LogLevels
from nptyping import NDArray, Float64
from nptyping import NDArray, Float64, Shape
from numpy.ctypeslib import ndpointer


Expand Down Expand Up @@ -1266,15 +1266,15 @@ def release_session(self) -> None:
if res != BrainFlowExitCodes.STATUS_OK.value:
raise BrainFlowError('unable to release streaming session', res)

def get_current_board_data(self, num_samples: int, preset: int = BrainFlowPresets.DEFAULT_PRESET) -> NDArray[Float64]:
def get_current_board_data(self, num_samples: int, preset: int = BrainFlowPresets.DEFAULT_PRESET) -> NDArray[Shape["*, *"], Float64]:
"""Get specified amount of data or less if there is not enough data, doesnt remove data from ringbuffer
:param num_samples: max number of samples
:type num_samples: int
:param preset: preset
:type preset: int
:return: latest data from a board
:rtype: NDArray[Float64]
:rtype: NDArray[Shape["*, *"], Float64]
"""

package_length = BoardShim.get_num_rows(self._master_board_id, preset)
Expand Down Expand Up @@ -1345,15 +1345,15 @@ def is_prepared(self) -> bool:
raise BrainFlowError('unable to check session status', res)
return bool(prepared[0])

def get_board_data(self, num_samples=None, preset: int = BrainFlowPresets.DEFAULT_PRESET) -> NDArray[Float64]:
def get_board_data(self, num_samples=None, preset: int = BrainFlowPresets.DEFAULT_PRESET) -> NDArray[Shape["*, *"], Float64]:
"""Get board data and remove data from ringbuffer
:param num_samples: number of packages to get
:type num_samples: int
:param preset: preset
:type preset: int
:return: all data from a board if num_samples is None, num_samples packages or less if not None
:rtype: NDArray[Float64]
:rtype: NDArray[Shape["*, *"], Float64]
"""

data_size = self.get_board_data_count(preset)
Expand Down
130 changes: 65 additions & 65 deletions python_package/brainflow/data_filter.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions python_package/brainflow/ml_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pkg_resources
from brainflow.board_shim import BrainFlowError, LogLevels
from brainflow.exit_codes import BrainFlowExitCodes
from nptyping import NDArray
from nptyping import NDArray, Float64, Shape
from numpy.ctypeslib import ndpointer


Expand Down Expand Up @@ -262,11 +262,11 @@ def release(self) -> None:
if res != BrainFlowExitCodes.STATUS_OK.value:
raise BrainFlowError('unable to release classifier', res)

def predict(self, data: NDArray) -> List:
def predict(self, data: NDArray[Shape["*"], Float64]) -> List:
"""calculate metric from data
:param data: input array
:type data: NDArray
:type data: NDArray[Shape["*"], Float64]
:return: metric value
:rtype: List
"""
Expand Down
1 change: 0 additions & 1 deletion python_package/examples/tests/board_descr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import brainflow
from brainflow.board_shim import BoardShim

BoardShim.enable_dev_board_logger()
Expand Down
2 changes: 1 addition & 1 deletion python_package/examples/tests/brainflow_get_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import time

from brainflow.board_shim import BoardShim, BrainFlowInputParams, BoardIds, BrainFlowPresets
from brainflow.board_shim import BoardShim, BrainFlowInputParams, BoardIds


def main():
Expand Down
2 changes: 1 addition & 1 deletion python_package/examples/tests/csp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def main():

data = np.array([[[6, 3, 1, 5], [3, 0, 5, 1]], [[1, 5, 6, 2], [5, 1, 2, 2]]]).astype('float64')

filters, eigvals = DataFilter.get_csp(data, labels);
filters, eigvals = DataFilter.get_csp(data, labels)

true_filters = np.array([[-0.313406, 0.0792153], [-0.280803, -0.480046]])

Expand Down
2 changes: 1 addition & 1 deletion python_package/examples/tests/data_collector.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import time

from brainflow.board_shim import BoardShim, BrainFlowInputParams, BoardIds, BrainFlowPresets
from brainflow.board_shim import BoardShim, BrainFlowInputParams


def main():
Expand Down
2 changes: 1 addition & 1 deletion python_package/examples/tests/ganglion_resist.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def main():
board.prepare_session()
# expected result: 5 seconds of resistance data(unknown sampling rate) after that 5 seconds of exg data
board.config_board('z')
board.start_stream(45000, f'file://raw_data.csv:w')
board.start_stream(45000, 'file://raw_data.csv:w')
time.sleep(5)
board.config_board('Z')
time.sleep(5)
Expand Down
4 changes: 2 additions & 2 deletions python_package/examples/tests/ganglion_wifi_resist.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def main():
BoardShim.enable_dev_board_logger()

params = BrainFlowInputParams()
params.ip_address = args.ip_address;
params.ip_port = args.ip_port;
params.ip_address = args.ip_address
params.ip_port = args.ip_port
board = BoardShim(BoardIds.GANGLION_WIFI_BOARD.value, params)
board.prepare_session()

Expand Down
2 changes: 1 addition & 1 deletion python_package/examples/tests/peaks_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import matplotlib.pyplot as plt

from brainflow.board_shim import BoardShim, BrainFlowInputParams, LogLevels, BoardIds
from brainflow.data_filter import DataFilter, ThresholdTypes, AggOperations, NoiseTypes, WaveletTypes, DetrendOperations
from brainflow.data_filter import DataFilter, NoiseTypes, WaveletTypes, DetrendOperations


def main():
Expand Down
4 changes: 2 additions & 2 deletions python_package/examples/tests/plotjuggler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import time

from brainflow.board_shim import BoardShim, BrainFlowInputParams, BoardIds, BrainFlowPresets
from brainflow.board_shim import BoardShim, BrainFlowInputParams, BoardIds


def main():
Expand Down Expand Up @@ -44,7 +44,7 @@ def main():
for preset in presets:
# to stream to plotjuggler
board.add_streamer(
f'plotjuggler_udp://127.0.0.1:9870', preset)
'plotjuggler_udp://127.0.0.1:9870', preset)
# to store data in a file
board.add_streamer(f'file://data_{preset}.csv:w', preset)
board.start_stream ()
Expand Down
3 changes: 2 additions & 1 deletion python_package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
packages=find_packages(),
install_requires=[
'numpy',
'nptyping==1.4.4'
'nptyping>=2.0.0',
'setuptools'
],
package_data={
'brainflow': [
Expand Down
1 change: 1 addition & 0 deletions src/board_controller/brainalive/brainalive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ int BrainAlive::start_stream (int buffer_size, const char *streamer_params)
return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR;
}
int res = prepare_for_acquisition (buffer_size, streamer_params);

if (res == (int)BrainFlowExitCodes::STATUS_OK)
{
res = config_board ("0a8100000d");
Expand Down

0 comments on commit ea23a6f

Please sign in to comment.