Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ enabled = true

[[analyzers]]
name = "shell"
enabled = true
enabled = true
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ coverage.xml
*.toml

!README.md

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ assignees: ''
**Please use MONAI's Discussions tab**
For questions relating to MONAI usage, please do not create an issue.

Instead, use [MONAI's GitHub Discussions tab](https://github.com/Project-MONAI/MONAI/discussions). This can be found next to Issues and Pull Requests along the top of our repository.
Instead, use [MONAI's GitHub Discussions tab](https://github.com/Project-MONAI/MONAI/discussions). This can be found next to Issues and Pull Requests along the top of our repository.
1 change: 0 additions & 1 deletion .github/workflows/weekly-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ jobs:
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

63 changes: 63 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
default_language_version:
python: python3.8

ci:
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
autoupdate_schedule: quarterly
# submodules: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-yaml
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-toml
- id: check-case-conflict
- id: check-added-large-files
args: ['--maxkb=1024']
- id: detect-private-key

#- repo: https://github.com/asottile/pyupgrade
# rev: v2.23.2
# hooks:
# - id: pyupgrade
# args: [--py36-plus]
# name: Upgrade code

#- repo: https://github.com/asottile/yesqa
# rev: v1.2.3
# hooks:
# - id: yesqa
# name: Unused noqa

#- repo: https://github.com/PyCQA/isort
# rev: 5.9.3
# hooks:
# - id: isort
# name: Format imports

- repo: https://github.com/psf/black
rev: 21.7b0
hooks:
- id: black
name: Format code

#- repo: https://github.com/executablebooks/mdformat
# rev: 0.7.8
# hooks:
# - id: mdformat
# additional_dependencies:
# - mdformat-gfm
# - mdformat_frontmatter
# exclude: CHANGELOG.md

- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
name: Check PEP8
2 changes: 1 addition & 1 deletion docs/source/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ Metrics
`Peak signal to noise ratio`
----------------------------
.. autoclass:: PSNRMetric
:members:
:members:
88 changes: 37 additions & 51 deletions monai/config/type_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,69 +14,55 @@
import numpy as np
import torch

# Commonly used concepts
# This module provides naming and type specifications for commonly used concepts
# within the MONAI package. The intent is to explicitly identify information
# that should be used consistently throughout the entire MONAI package.
#
# A type would be named as type_definitions.KeysCollection
# which includes a meaningful name for the consent in the name itself. The
# definitions in this file map context meaningful names to the underlying
# object properties that define the expected API.
#
# A conceptual type is represented by a new type name but is also one which
# can be different depending on an environment (i.e. differences for python 3.6 vs 3.9
# may be implemented). Consistent use of the concept and recorded documentation of
# the rationale and convention behind it lowers the learning curve for new
# developers. For readability, short names are preferred.
__all__ = ["KeysCollection", "IndexSelection", "DtypeLike", "NdarrayTensor", "NdarrayOrTensor", "TensorOrList"]

"""Commonly used concepts
This module provides naming and type specifications for commonly used concepts
within the MONAI package. The intent is to explicitly identify information
that should be used consistently throughout the entire MONAI package.

A type would be named as type_definitions.KeysCollection
which includes a meaningful name for the consent in the name itself. The
definitions in this file map context meaningful names to the underlying
object properties that define the expected API.

A conceptual type is represented by a new type name but is also one which
can be different depending on an environment (i.e. differences for python 3.6 vs 3.9
may be implemented). Consistent use of the concept and recorded documentation of
the rationale and convention behind it lowers the learning curve for new
developers. For readability, short names are preferred.
"""

#: KeysCollection
#
# The KeyCollection type is used to for defining variables
# that store a subset of keys to select items from a dictionary.
# The container of keys must contain hashable elements.
# NOTE: `Hashable` is not a collection, but is provided as a
# convenience to end-users. All supplied values will be
# internally converted to a tuple of `Hashable`'s before
# use
KeysCollection = Union[Collection[Hashable], Hashable]
"""KeysCollection

The KeyCollection type is used to for defining variables
that store a subset of keys to select items from a dictionary.
The container of keys must contain hashable elements.
NOTE: `Hashable` is not a collection, but is provided as a
convenience to end-users. All supplied values will be
internally converted to a tuple of `Hashable`'s before
use
"""


#: IndexSelection
#
# The IndexSelection type is used to for defining variables
# that store a subset of indices to select items from a List or Array like objects.
# The indices must be integers, and if a container of indices is specified, the
# container must be iterable.
IndexSelection = Union[Iterable[int], int]
"""IndexSelection

The IndexSelection type is used to for defining variables
that store a subset of indices to select items from a List or Array like objects.
The indices must be integers, and if a container of indices is specified, the
container must be iterable.
"""


#: Type of datatypes: Adapted from https://github.com/numpy/numpy/blob/master/numpy/typing/_dtype_like.py
DtypeLike = Union[np.dtype, type, None]
"""Type of datatypes

Adapted from https://github.com/numpy/numpy/blob/master/numpy/typing/_dtype_like.py
"""

#: NdarrayTensor
#
# Generic type which can represent either a numpy.ndarray or a torch.Tensor
# Unlike Union can create a dependence between parameter(s) / return(s)
NdarrayTensor = TypeVar("NdarrayTensor", np.ndarray, torch.Tensor)
"""NdarrayTensor

Generic type which can represent either a numpy.ndarray or a torch.Tensor
Unlike Union can create a dependence between parameter(s) / return(s)
"""

#: NdarrayOrTensor: Union of numpy.ndarray and torch.Tensor to be used for typing
NdarrayOrTensor = Union[np.ndarray, torch.Tensor]
"""NdarrayOrTensor

Union of numpy.ndarray and torch.Tensor to be used for typing
"""

#: TensorOrList: The TensorOrList type is used for defining `batch-first Tensor` or `list of channel-first Tensor`.
TensorOrList = Union[torch.Tensor, Sequence[torch.Tensor]]
"""TensorOrList

The TensorOrList type is used for defining `batch-first Tensor` or `list of channel-first Tensor`.
"""
2 changes: 1 addition & 1 deletion monai/csrc/filtering/bilateral/bilateralfilter_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,4 @@ torch::Tensor BilateralFilterCpu(torch::Tensor inputTensor, float spatialSigma,
}));

return outputTensor;
}
}
2 changes: 1 addition & 1 deletion monai/csrc/filtering/filtering.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ limitations under the License.
#pragma once

#include "bilateral/bilateral.h"
#include "permutohedral/permutohedral.h"
#include "permutohedral/permutohedral.h"
2 changes: 1 addition & 1 deletion monai/csrc/filtering/permutohedral/hash_table.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,4 @@ __device__ static int hashTableRetrieve(signed short* key) {
if (h == table_capacity * 2)
h = 0;
}
}
}
2 changes: 1 addition & 1 deletion monai/csrc/filtering/permutohedral/permutohedral.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ template <typename scalar_t, int dc, int fc>
void PermutohedralCuda(scalar_t* data, scalar_t* features, int elementCount, bool accurate);
#endif

torch::Tensor PermutohedralFilter(torch::Tensor input, torch::Tensor features);
torch::Tensor PermutohedralFilter(torch::Tensor input, torch::Tensor features);
2 changes: 1 addition & 1 deletion monai/csrc/filtering/permutohedral/permutohedral_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,4 +499,4 @@ void PermutohedralCPU(scalar_t* data, scalar_t* features, int dataChannels, int
}

template void PermutohedralCPU(float* data, float* features, int dataChannels, int featureChannels, int elementCount);
template void PermutohedralCPU(double* data, double* features, int dataChannels, int featureChannels, int elementCount);
template void PermutohedralCPU(double* data, double* features, int dataChannels, int featureChannels, int elementCount);