This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pr comments, abstractmixin, define __all__
- Loading branch information
1 parent
989404c
commit d9caee1
Showing
22 changed files
with
118 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from ._version import get_versions | ||
__version__ = get_versions()['version'] | ||
del get_versions | ||
|
||
from rising.interface import AbstractMixin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class AbstractMixin(object): | ||
def __init__(self, *args, **kwargs): | ||
""" | ||
This class implements an interface which handles non processed arguments. | ||
Subclass all classes which mixin additional methods and attributes | ||
to existing classes with multiple inheritance from this class as backup | ||
for handling additional arguments. | ||
Parameters | ||
---------- | ||
kwargs: | ||
keyword arguments saved to object if it is the last class before object. | ||
Otherwise forwarded to next class. | ||
""" | ||
mro = type(self).mro() | ||
mro_idx = mro.index(AbstractMixin) | ||
# +2 because index starts at 0 and only one more class should be called | ||
if mro_idx + 2 == len(mro): | ||
# only object init is missing | ||
super().__init__() | ||
for key, item in kwargs.items(): | ||
setattr(self, key, item) | ||
else: | ||
# class is not last before object -> forward arguments | ||
super().__init__(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from rising.transforms.abstract import * | ||
from rising.transforms.channel import * | ||
from rising.transforms.compose import * | ||
from rising.transforms.crop import * | ||
from rising.transforms.format import * | ||
from rising.transforms.intensity import * | ||
from rising.transforms.kernel import * | ||
from rising.transforms.spatial import * | ||
from rising.transforms.utility import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__all__ = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import unittest | ||
from rising import AbstractMixin | ||
|
||
|
||
class Abstract(object): | ||
def __init__(self, **kwargs): | ||
super().__init__() | ||
self.abstract = True | ||
|
||
|
||
class AbstractForward(object): | ||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
self.abstract = True | ||
|
||
|
||
class PreMix(AbstractMixin, Abstract): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
|
||
class PostMix(AbstractForward, AbstractMixin): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
|
||
class MyTestCase(unittest.TestCase): | ||
def test_pre_mix(self): | ||
obj = PreMix(a=True) | ||
self.assertFalse(hasattr(obj, "a")) | ||
self.assertTrue(obj.abstract) | ||
|
||
def test_post_mix(self): | ||
obj = PostMix(a=True) | ||
self.assertTrue(obj.a) | ||
self.assertTrue(obj.abstract) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import unittest | ||
import torch | ||
import random | ||
|
||
from rising.transforms.functional.crop import * | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import unittest | ||
import torch | ||
from math import isclose | ||
|
||
from rising.transforms.functional.intensity import * | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters