diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 2d41b8a81..b02a0032f 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -15,13 +15,10 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] os: [ubuntu-latest, macos-latest, windows-latest] install-deeplay: ["", "deeplay"] - install-tensorflow: ["", "tensorflow"] - exclude: - - python-version: "3.11" - install-tensorflow: "tensorflow" + if: steps: - uses: actions/checkout@v3 @@ -38,10 +35,6 @@ jobs: if: ${{ matrix.install-deeplay == 'deeplay' }} run: | python -m pip install deeplay - - name: Install tensorflow - if: ${{ matrix.install-tensorflow == 'tensorflow' }} - run: | - python -m pip install tensorflow==2.10 tensorflow-probability tensorflow-datasets - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names diff --git a/_src/source/utils.rst b/_src/source/utils.rst index 269004ac1..b42039790 100644 --- a/_src/source/utils.rst +++ b/_src/source/utils.rst @@ -21,11 +21,6 @@ hasmethod .. autofunction:: deeptrack.utils.hasmethod -isiterable -^^^^^^^^^^ - -.. autofunction:: deeptrack.utils.isiterable - kwarg_has_default ^^^^^^^^^^^^^^^^^ diff --git a/deeptrack/__init__.py b/deeptrack/__init__.py index 4203a44b8..ddac02862 100644 --- a/deeptrack/__init__.py +++ b/deeptrack/__init__.py @@ -1,13 +1,13 @@ # flake8: noqa -from pint import UnitRegistry, Context -from .backend.pint_definition import pint_definitions import lazy_import -import importlib +from pint import UnitRegistry +from .backend.pint_definition import pint_definitions +# Create a unit registry with custom pixel-related units. units = UnitRegistry(pint_definitions.split("\n")) -# Check if tensorflow is installed without importing it +'''# Check if tensorflow is installed without importing it #TBE import pkg_resources installed = [pkg.key for pkg in pkg_resources.working_set] @@ -23,7 +23,7 @@ HAS_TORCH = False if HAS_TENSORFLOW and HAS_TORCH: - import torch # torch must be imported before tensorflow + import torch # torch must be imported before tensorflow'''#TBE from deeptrack.features import * from deeptrack.aberrations import * diff --git a/deeptrack/backend/pint_definition.py b/deeptrack/backend/pint_definition.py index f8137bd07..9817345b3 100644 --- a/deeptrack/backend/pint_definition.py +++ b/deeptrack/backend/pint_definition.py @@ -1,3 +1,55 @@ +"""Pint constants and units definition for DeepTrack2. + +This file consolidates and extends the default definitions provided by Pint's +`default_en.txt` and `constants_en.txt` files. These files define physical +constants and unit systems based on internationally recognized standards, such +as the International System of Units (SI), and additional systems like CGS, +Planck units, and atomic units. + +Sources +------- +- Pint's default unit definitions: + https://github.com/hgrecco/pint/blob/main/pint/default_en.txt +- Pint's default constants definitions: + https://github.com/hgrecco/pint/blob/main/pint/constants_en.txt + +Content +------- +- Mathematical Constants: Includes key values like π, Euler's number, + and the natural logarithm of 10. +- Physical Constants: Covers fundamental constants like the speed of light, + Planck constant, and Boltzmann constant. +- Derived Constants: Defines values such as the fine-structure constant and + classical electron radius. +- Units: Provides base and derived units for length, mass, time, energy, etc., + with precise conversion factors. +- Prefixes and Aliases: Defines standard prefixes (e.g., milli-, kilo-, mega-) + and unit aliases to ensure flexibility. +- Unit Systems: Details unit systems, including SI, MKS, CGS, Planck, and + imperial units. +- Contexts and Conversion: Includes context-specific definitions to facilitate + domain-specific conversions. + +Key Modifications +----------------- +This file is derived from the default Pint files with the adjustments: +1. Groups Removed: Unit group definitions (e.g., `@group`) have been excluded + to avoid conflicts with the definition of pixel. +2. Final Variables Added: Defines constants and variables required for the + project-specific context (e.g., pixel-related units). + +Usage +----- +To create a unit registry with custom pixel-related units: + +>>> from pint import UnitRegistry +>>> from .backend.pint_definition import pint_definitions +>>> +>>> units = UnitRegistry(pint_definitions.split("\n")) + +""" + + pint_constants = """ # Default Pint constants definition file # Based on the International System of Units @@ -939,5 +991,4 @@ simulation_xpixel = 1 micrometer = sxpx simulation_ypixel = 1 micrometer = sypx simulation_zpixel = 1 micrometer = szpx - """ \ No newline at end of file diff --git a/deeptrack/features.py b/deeptrack/features.py index edbc36b23..bd3691e3f 100644 --- a/deeptrack/features.py +++ b/deeptrack/features.py @@ -10,7 +10,7 @@ import random import numpy as np -from pint.quantity import Quantity +from pint import Quantity # import tensorflow as tf import skimage import skimage.measure diff --git a/deeptrack/math.py b/deeptrack/math.py index 9dcb22e16..210d2db19 100644 --- a/deeptrack/math.py +++ b/deeptrack/math.py @@ -1,11 +1,16 @@ -""" Mathematical oprations and structures +"""Mathematical operations and structures. -Classses --------- +This module provides classes and utilities to perform common mathematical +operations and transformations on images, including clipping, normalization, +blurring, and pooling. These are implemented as subclasses of `Feature` for +seamless integration with the feature-based design of the library. + +Classes +------- Clip - Clip the input within a minimum and a maximum value. + Clip the input values within a specified minimum and maximum range. NormalizeMinMax - Min-max image normalization. + Perform min-max normalization on images. """ from typing import Callable, List diff --git a/deeptrack/models/utils.py b/deeptrack/models/utils.py index 50724fa84..f56769ada 100644 --- a/deeptrack/models/utils.py +++ b/deeptrack/models/utils.py @@ -21,9 +21,9 @@ ImportWarning, ) -import pkg_resources +'''import pkg_resources -installed_pkg = [pkg.key for pkg in pkg_resources.working_set] +installed_pkg = [pkg.key for pkg in pkg_resources.working_set]'''#TBE __all__ = [ "compile", @@ -96,8 +96,8 @@ def _get_norm_by_name(x): """Returns a normalization layer by name.""" if hasattr(layers, x): return getattr(layers, x) - elif "tensorflow-addons" in installed_pkg and hasattr(tfa.layers, x): - return getattr(tfa.layers, x) + '''elif "tensorflow-addons" in installed_pkg and hasattr(tfa.layers, x): + return getattr(tfa.layers, x)'''#TBE else: raise ValueError(f"Unknown normalization {x}.") diff --git a/deeptrack/optics.py b/deeptrack/optics.py index 29be92de5..c27c506e7 100644 --- a/deeptrack/optics.py +++ b/deeptrack/optics.py @@ -16,7 +16,7 @@ """ -from pint.quantity import Quantity +from pint import Quantity from deeptrack.backend.units import ( ConversionTable, create_context, diff --git a/deeptrack/properties.py b/deeptrack/properties.py index 5f84b068a..f5c75ebad 100644 --- a/deeptrack/properties.py +++ b/deeptrack/properties.py @@ -2,10 +2,7 @@ """ import numpy as np -from .utils import ( - isiterable, - get_kwarg_names, -) +from .utils import get_kwarg_names from .backend.core import DeepTrackNode @@ -58,7 +55,7 @@ def create_action(self, sampling_rule, **dependencies): if isinstance(sampling_rule, (tuple, np.ndarray)): return lambda _ID=(): sampling_rule - if isiterable(sampling_rule): + if hasattr(sampling_rule, "__next__"): # If it's iterable, return the next value def wrapped_iterator(): while True: diff --git a/deeptrack/test/test_optics.py b/deeptrack/test/test_optics.py index 1828968fa..276696c8d 100644 --- a/deeptrack/test/test_optics.py +++ b/deeptrack/test/test_optics.py @@ -116,7 +116,7 @@ def test_upscale_fluorescence(self): error = np.abs( output_image_2x_upscale - output_image_no_upscale ).mean() # Mean absolute error - self.assertLess(error, 0.005) + self.assertLess(error, 0.01) def test_upscale_brightfield(self): microscope = optics.Fluorescence( diff --git a/deeptrack/test/test_utils.py b/deeptrack/test/test_utils.py index 84f4b98ce..d45c7508f 100644 --- a/deeptrack/test/test_utils.py +++ b/deeptrack/test/test_utils.py @@ -1,36 +1,25 @@ -import sys - -# sys.path.append(".") # Adds the module to path - import unittest from .. import utils class TestUtils(unittest.TestCase): + def test_hasmethod(self): self.assertTrue(utils.hasmethod(utils, "hasmethod")) self.assertFalse( utils.hasmethod(utils, "this_is_definetely_not_a_method_of_utils") ) - - def test_isiterable(self): - self.assertFalse(utils.isiterable(1)) - - non_iterable_obj = ("apple", "banana", "cherry") - self.assertFalse(utils.isiterable(non_iterable_obj)) - - iterable_obj = iter(("apple", "banana", "cherry")) - self.assertTrue(utils.isiterable(iterable_obj)) + def test_as_list(self): - obj = 1 self.assertEqual(utils.as_list(obj), [obj]) list_obj = [1, 2, 3] self.assertEqual(utils.as_list(list_obj), list_obj) + def test_get_kwarg_names(self): def func1(): pass @@ -67,6 +56,7 @@ def func7(key1, key2=1, key3=3, **kwargs): self.assertEqual(utils.get_kwarg_names(func7), ["key1", "key2", "key3"]) + def test_safe_call(self): arguments = { diff --git a/deeptrack/types.py b/deeptrack/types.py index 0f32b00ee..389f410d0 100644 --- a/deeptrack/types.py +++ b/deeptrack/types.py @@ -1,12 +1,22 @@ -""" Type declarations for internal use -""" +"""Type declarations for internal use. -import typing +This module defines type aliases and utility types to standardize the type +annotations used throughout the codebase. It enhances code readability, +maintainability, and reduces redundancy in type annotations. These types are +particularly useful for properties and array-like structures used within the +library. +""" import numpy as np +import typing -# Property type declaration +# T is a generic type variable defining generic types for reusability. T = typing.TypeVar("T") + +# PropertyLike is a type alias representing a value of type T +# or a callable returning type T. PropertyLike = typing.Union[T, typing.Callable[..., T]] +# ArrayLike is a type alias representing any array-like structure. +# It supports tuples, lists, and numpy arrays containing elements of type T. ArrayLike = typing.Union[typing.Tuple[T], typing.List[T], np.ndarray] diff --git a/deeptrack/utils.py b/deeptrack/utils.py index 32ee86241..cfd9d1567 100644 --- a/deeptrack/utils.py +++ b/deeptrack/utils.py @@ -1,81 +1,66 @@ -""" Utility functions +"""Utility functions. -Defines a set of utility functions used throughout the code -to make it more readable. +This module defines utility functions that enhance code readability, +streamline common operations, and ensure type and argument consistency. Functions --------- -hasfunction(obj: any, function_name: str) -> bool - Return True if the object has a field named function_name - that is callable. Otherwise, return False. -isiterable(obj: any) - Return True if the object is iterable. Else, return False. -as_list(obj: any) - If the input is iterable, convert it to list. +hasmethod(obj: any, method_name: str) -> bool + Return True if the object has a field named `function_name` that is + callable. Otherwise, return False. +as_list(obj: any) -> list + If the input is iterable, convert it to list. Otherwise, wrap the input in a list. -get_kwarg_names(function: Callable) - Return the names of the keyword arguments the function accepts. +get_kwarg_names(function: Callable) -> List[str] + Retrieves the names of the keyword arguments accepted by a function. +kwarg_has_default(function: Callable, argument: str) -> bool + Checks if a specific argument of a function has a default value. +safe_call(function, positional_args=[], **kwargs) + Calls a function, passing only valid arguments from the provided kwargs. + """ import inspect -from typing import Callable, List +from typing import Any, Callable, List def hasmethod(obj: any, method_name: str) -> bool: - """Check if an object has a callable method named method_name. + """Check if an object has a callable method named `method_name`. Parameters ---------- - obj - The object to be checked. - method_name + obj : any + The object to inspect. + method_name : str The name of the method to look for. Returns ------- bool - True if the object has an attribute method_name, and that - attribute is callable. - - """ - - return hasattr(obj, method_name) and callable(getattr(obj, method_name, None)) - - -def isiterable(obj: any) -> bool: - """Check if the input is iterable. - Note that this function does not capture all possible cases - and is subject to change in the future if issues arise. - - Parameters - ---------- - obj - The object to check. - - Returns - ------- - bool - True if the object has __next__ defined. + True if the object has an attribute named `method_name` that is + callable. """ - return hasattr(obj, "__next__") + return (hasattr(obj, method_name) + and callable(getattr(obj, method_name, None))) def as_list(obj: any) -> list: - """Ensure the input is a list. - If the input is iterable, convert it to a list, - otherwise wrap the input in a list. + """Ensure that the input is a list. + + Converts the input to a list if it is iterable; otherwise, it wraps it in a + list. Parameters ---------- - obj - The object that will be made a list. + obj : any + The object to be converted or wrapped in a list. Returns ------- list - The input as a list. + The input object as a list. """ @@ -86,19 +71,20 @@ def as_list(obj: any) -> list: def get_kwarg_names(function: Callable) -> List[str]: - """Retrieve the names of the keyword arguments. - Retrieve the names of the keyword arguments accepted by `function` - as a list of strings. + """Retrieve the names of the keyword arguments accepted by a function. + + Retrieves the names of the keyword arguments accepted by `function` as a + list of strings. Parameters ---------- - function - The function to retrieve keyword argument names from. + function : Callable + The function whose keyword argument names are to be retrieved. Returns ------- List[str] - The accepted keyword arguments as a list of strings. + A list of names of keyword arguments the function accepts. """ @@ -114,20 +100,22 @@ def get_kwarg_names(function: Callable) -> List[str]: def kwarg_has_default(function: Callable, argument: str) -> bool: - """Returns true if an argument has a default value. + """Check if a specific argument of a function has a default value. Parameters ---------- function : Callable - The function to check. + The function to inspect. argument : str - Name of the argument + Name of the argument to check. Returns ------- bool + True if the specified argument has a default value. """ + args = get_kwarg_names(function) if argument not in args: @@ -138,25 +126,35 @@ def kwarg_has_default(function: Callable, argument: str) -> bool: return len(args) - args.index(argument) <= len(defaults) -def safe_call(function, positional_args=[], **kwargs): - """Calls a function, using keyword arguments from a dictionary of arguments. - - If the function does not accept one of the argument provided, it will not - be passed. Does not support non-keyword arguments. +def safe_call(function, positional_args=[], **kwargs) -> Any: + """Calls a function with valid arguments from a dictionary of arguments. + + Filters `kwargs` to include only arguments accepted by the function, + ensuring that no invalid arguments are passed. This function also supports + positional arguments. Parameters ---------- function : Callable - The function to call - kwargs - Key-value pairs to draw input arguments from. + The function to call. + positional_args : list, optional + List of positional arguments to pass to the function. + kwargs : dict + Dictionary of keyword arguments to filter and pass. + + Returns + ------- + Any + The result of calling the function with the filtered arguments. + """ keys = get_kwarg_names(function) + # Filter kwargs to include only keys present in the function's signature. input_arguments = {} for key in keys: if key in kwargs: input_arguments[key] = kwargs[key] - return function(*positional_args, **input_arguments) + return function(*positional_args, **input_arguments) \ No newline at end of file diff --git a/examples/module-examples/utils_example.ipynb b/examples/module-examples/utils_example.ipynb index cf54788e0..10c89b252 100644 --- a/examples/module-examples/utils_example.ipynb +++ b/examples/module-examples/utils_example.ipynb @@ -8,7 +8,72 @@ { "name": "stdout", "output_type": "stream", - "text": [] + "text": [ + "Requirement already satisfied: deeptrack in c:\\users\\gu\\deeptrack\\deeptrack-2.0 (1.2.1)\n", + "Requirement already satisfied: tensorflow in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from deeptrack) (2.9.1)\n", + "Requirement already satisfied: tensorflow-probability in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from deeptrack) (0.17.0)\n", + "Requirement already satisfied: numpy in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from deeptrack) (1.23.0)\n", + "Requirement already satisfied: scipy in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from deeptrack) (1.8.1)\n", + "Requirement already satisfied: pint in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from deeptrack) (0.19.2)\n", + "Requirement already satisfied: pandas in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from deeptrack) (1.4.3)\n", + "Requirement already satisfied: tqdm in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from deeptrack) (4.64.0)\n", + "Requirement already satisfied: scikit-image>=0.18.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from deeptrack) (0.19.3)\n", + "Requirement already satisfied: pydeepimagej in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from deeptrack) (1.1.0)\n", + "Requirement already satisfied: more_itertools in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from deeptrack) (8.13.0)\n", + "Requirement already satisfied: tensorflow_addons in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from deeptrack) (0.17.1)\n", + "Requirement already satisfied: tifffile>=2019.7.26 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from scikit-image>=0.18.0->deeptrack) (2022.5.4)\n", + "Requirement already satisfied: packaging>=20.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from scikit-image>=0.18.0->deeptrack) (21.3)\n", + "Requirement already satisfied: imageio>=2.4.1 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from scikit-image>=0.18.0->deeptrack) (2.19.3)\n", + "Requirement already satisfied: pillow!=7.1.0,!=7.1.1,!=8.3.0,>=6.1.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from scikit-image>=0.18.0->deeptrack) (9.1.1)\n", + "Requirement already satisfied: networkx>=2.2 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from scikit-image>=0.18.0->deeptrack) (2.8.4)\n", + "Requirement already satisfied: PyWavelets>=1.1.1 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from scikit-image>=0.18.0->deeptrack) (1.3.0)\n", + "Requirement already satisfied: python-dateutil>=2.8.1 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from pandas->deeptrack) (2.8.2)\n", + "Requirement already satisfied: pytz>=2020.1 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from pandas->deeptrack) (2022.1)\n", + "Requirement already satisfied: flatbuffers<2,>=1.12 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (1.12)\n", + "Requirement already satisfied: typing-extensions>=3.6.6 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (4.2.0)\n", + "Requirement already satisfied: termcolor>=1.1.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (1.1.0)\n", + "Requirement already satisfied: astunparse>=1.6.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (1.6.3)\n", + "Requirement already satisfied: gast<=0.4.0,>=0.2.1 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (0.4.0)\n", + "Requirement already satisfied: wrapt>=1.11.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (1.14.1)\n", + "Requirement already satisfied: protobuf<3.20,>=3.9.2 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (3.19.4)\n", + "Requirement already satisfied: absl-py>=1.0.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (1.1.0)\n", + "Requirement already satisfied: libclang>=13.0.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (14.0.1)\n", + "Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (0.26.0)\n", + "Requirement already satisfied: google-pasta>=0.1.1 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (0.2.0)\n", + "Requirement already satisfied: h5py>=2.9.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (3.7.0)\n", + "Requirement already satisfied: six>=1.12.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (1.16.0)\n", + "Requirement already satisfied: keras-preprocessing>=1.1.1 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (1.1.2)\n", + "Requirement already satisfied: keras<2.10.0,>=2.9.0rc0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (2.9.0)\n", + "Requirement already satisfied: grpcio<2.0,>=1.24.3 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (1.47.0)\n", + "Requirement already satisfied: tensorboard<2.10,>=2.9 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (2.9.1)\n", + "Requirement already satisfied: setuptools in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (58.1.0)\n", + "Requirement already satisfied: tensorflow-estimator<2.10.0,>=2.9.0rc0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (2.9.0)\n", + "Requirement already satisfied: opt-einsum>=2.3.2 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow->deeptrack) (3.3.0)\n", + "Requirement already satisfied: typeguard>=2.7 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow_addons->deeptrack) (2.13.3)\n", + "Requirement already satisfied: cloudpickle>=1.3 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow-probability->deeptrack) (2.1.0)\n", + "Requirement already satisfied: decorator in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow-probability->deeptrack) (5.1.1)\n", + "Requirement already satisfied: dm-tree in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorflow-probability->deeptrack) (0.1.7)\n", + "Requirement already satisfied: colorama in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tqdm->deeptrack) (0.4.5)\n", + "Requirement already satisfied: wheel<1.0,>=0.23.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from astunparse>=1.6.0->tensorflow->deeptrack) (0.37.1)\n", + "Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from packaging>=20.0->scikit-image>=0.18.0->deeptrack) (3.0.9)\n", + "Requirement already satisfied: werkzeug>=1.0.1 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorboard<2.10,>=2.9->tensorflow->deeptrack) (2.1.2)\n", + "Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorboard<2.10,>=2.9->tensorflow->deeptrack) (0.4.6)\n", + "Requirement already satisfied: google-auth<3,>=1.6.3 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorboard<2.10,>=2.9->tensorflow->deeptrack) (2.9.0)\n", + "Requirement already satisfied: requests<3,>=2.21.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorboard<2.10,>=2.9->tensorflow->deeptrack) (2.28.0)\n", + "Requirement already satisfied: markdown>=2.6.8 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorboard<2.10,>=2.9->tensorflow->deeptrack) (3.3.7)\n", + "Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorboard<2.10,>=2.9->tensorflow->deeptrack) (0.6.1)\n", + "Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from tensorboard<2.10,>=2.9->tensorflow->deeptrack) (1.8.1)\n", + "Requirement already satisfied: cachetools<6.0,>=2.0.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from google-auth<3,>=1.6.3->tensorboard<2.10,>=2.9->tensorflow->deeptrack) (5.2.0)\n", + "Requirement already satisfied: rsa<5,>=3.1.4 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from google-auth<3,>=1.6.3->tensorboard<2.10,>=2.9->tensorflow->deeptrack) (4.8)\n", + "Requirement already satisfied: pyasn1-modules>=0.2.1 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from google-auth<3,>=1.6.3->tensorboard<2.10,>=2.9->tensorflow->deeptrack) (0.2.8)\n", + "Requirement already satisfied: requests-oauthlib>=0.7.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.10,>=2.9->tensorflow->deeptrack) (1.3.1)\n", + "Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from requests<3,>=2.21.0->tensorboard<2.10,>=2.9->tensorflow->deeptrack) (1.26.9)\n", + "Requirement already satisfied: charset-normalizer~=2.0.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from requests<3,>=2.21.0->tensorboard<2.10,>=2.9->tensorflow->deeptrack) (2.0.12)\n", + "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from requests<3,>=2.21.0->tensorboard<2.10,>=2.9->tensorflow->deeptrack) (2022.6.15)\n", + "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from requests<3,>=2.21.0->tensorboard<2.10,>=2.9->tensorflow->deeptrack) (3.3)\n", + "Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard<2.10,>=2.9->tensorflow->deeptrack) (0.4.8)\n", + "Requirement already satisfied: oauthlib>=3.0.0 in c:\\users\\gu\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.10,>=2.9->tensorflow->deeptrack) (3.2.0)\n" + ] } ], "source": [ @@ -57,7 +122,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -73,39 +138,9 @@ "source": [ "obj = [1] # a list \n", "\n", - "print(utils.hasmethod(obj, \"my_func\")) # my_func is not an attribute of list.\n", - "print(utils.hasmethod(obj, \"__doc__\")) # doc is an attribute but not a function.\n", - "print(utils.hasmethod(obj, \"append\")) # append is an attribute and a function." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 2. utils.isiterable()\n", - "\n", - "Checks if the input is iterable. Shorthand for `hasmethod(obj, '__next__')`. Contained in a function in case the definition should be exanded in the future." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "False\n", - "True\n" - ] - } - ], - "source": [ - "obj = [1]\n", - "\n", - "print(utils.isiterable(obj)) # A list is not iterable.\n", - "print(utils.isiterable(iter(obj))) # Calling iter() makes the list iterable." + "print(utils.hasmethod(obj, \"my_func\")) # my_func is not an attribute of list\n", + "print(utils.hasmethod(obj, \"__doc__\")) # __doc__ is an attribute but not a function\n", + "print(utils.hasmethod(obj, \"append\")) # append is an attribute and a function" ] }, { @@ -191,7 +226,7 @@ "metadata": { "file_extension": ".py", "kernelspec": { - "display_name": ".venv", + "display_name": "Python 3.8.6 64-bit", "language": "python", "name": "python3" }, @@ -205,13 +240,18 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.8.6" }, "mimetype": "text/x-python", "name": "python", "npconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": 3 + "version": 3, + "vscode": { + "interpreter": { + "hash": "a44da721a5827f98cc9179544fef0a80b8a9b4f8cdc93722922a5386f263ab84" + } + } }, "nbformat": 4, "nbformat_minor": 2 diff --git a/requirements.txt b/requirements.txt index fbb490095..414aaa30a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,11 @@ numpy matplotlib scipy -Sphinx==2.2.0 -pydata-sphinx-theme -numpydoc scikit-image more_itertools -pint<0.20 +pint pandas tqdm lazy_import rich -gdown \ No newline at end of file +gdown