Skip to content

Commit

Permalink
Declare public interfaces explicitly
Browse files Browse the repository at this point in the history
As suggested by pep8:

https://www.python.org/dev/peps/pep-0008/#public-and-internal-interfaces

Not doing so trips up flake8's F401, since the imports are not used.
Imports are an implementation detail and should not directly be relied
upon to declare the public API.

Two exceptions to this are csrank/__init__.py and
csrank/dataset_reader/__init__.py, where the API is too big. This will
likely change in the future. See #105.
  • Loading branch information
timokau committed Apr 1, 2020
1 parent f21d84b commit 346010f
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 24 deletions.
17 changes: 10 additions & 7 deletions csrank/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
__version__ = "1.1.0"

from .choicefunction import *
from .core import *
from .dataset_reader import *
from .discretechoice import *
from .objectranking import *
from .tunable import Tunable
from .tuning import ParameterOptimizer
# We should re-evaluate if we really want to re-export everything here and then
# use __all__ properly.

from .choicefunction import * # noqa: F401
from .core import * # noqa: F401
from .dataset_reader import * # noqa: F401
from .discretechoice import * # noqa: F401
from .objectranking import * # noqa: F401
from .tunable import Tunable # noqa: F401
from .tuning import ParameterOptimizer # noqa: F401
12 changes: 12 additions & 0 deletions csrank/choicefunction/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@
from .generalized_linear_model import GeneralizedLinearModel
from .pairwise_choice import PairwiseSVMChoiceFunction
from .ranknet_choice import RankNetChoiceFunction

__all__ = [
"AllPositive",
"CmpNetChoiceFunction",
"FATEChoiceFunction",
"FATELinearChoiceFunction",
"FETAChoiceFunction",
"FETALinearChoiceFunction",
"GeneralizedLinearModel",
"PairwiseSVMChoiceFunction",
"RankNetChoiceFunction",
]
11 changes: 11 additions & 0 deletions csrank/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,14 @@
from .feta_network import FETANetwork
from .pairwise_svm import PairwiseSVM
from .ranknet_core import RankNetCore

__all__ = [
"CmpNetCore",
"FATELinearCore",
"FATENetwork",
"FATENetworkCore",
"FETALinearCore",
"FETANetwork",
"PairwiseSVM",
"RankNetCore",
]
17 changes: 10 additions & 7 deletions csrank/dataset_reader/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from .choicefunctions import *
from .discretechoice import *
from .dyadranking import *
from .expedia_dataset_reader import ExpediaDatasetReader
from .labelranking import *
from .objectranking import *
from .synthetic_dataset_generator import SyntheticIterator
# We should re-evaluate if we really want to re-export everything here and then
# use __all__ properly.

from csrank.dataset_reader.choicefunctions import * # noqa: F401
from csrank.dataset_reader.discretechoice import * # noqa: F401
from csrank.dataset_reader.dyadranking import * # noqa: F401
from csrank.dataset_reader.expedia_dataset_reader import ExpediaDatasetReader # noqa: F401
from csrank.dataset_reader.labelranking import * # noqa: F401
from csrank.dataset_reader.objectranking import * # noqa: F401
from csrank.dataset_reader.synthetic_dataset_generator import SyntheticIterator # noqa: F401
7 changes: 7 additions & 0 deletions csrank/dataset_reader/choicefunctions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
from .expedia_choice_dataset_reader import ExpediaChoiceDatasetReader
from .letor_ranking_choice_dataset_reader import LetorRankingChoiceDatasetReader
from .mnist_choice_dataset_reader import MNISTChoiceDatasetReader

__all__ = [
"ChoiceDatasetGenerator",
"ExpediaChoiceDatasetReader",
"LetorRankingChoiceDatasetReader",
"MNISTChoiceDatasetReader",
]
10 changes: 10 additions & 0 deletions csrank/dataset_reader/discretechoice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@
from .tag_genome_discrete_choice_dataset_reader import (
TagGenomeDiscreteChoiceDatasetReader,
)

__all__ = [
"DiscreteChoiceDatasetGenerator",
"ExpediaDiscreteChoiceDatasetReader",
"LetorListwiseDiscreteChoiceDatasetReader",
"LetorRankingDiscreteChoiceDatasetReader",
"MNISTDiscreteChoiceDatasetReader",
"SushiDiscreteChoiceDatasetReader",
"TagGenomeDiscreteChoiceDatasetReader",
]
4 changes: 4 additions & 0 deletions csrank/dataset_reader/dyadranking/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
from .sushi_dyad_ranking_dataset_reader import SushiDyadRankingDatasetReader

__all__ = [
"SushiDyadRankingDatasetReader",
]
5 changes: 5 additions & 0 deletions csrank/dataset_reader/labelranking/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
from .intelligent_system_group_dataset_reader import IntelligentSystemGroupDatasetReader
from .survey_dataset_reader import SurveyDatasetReader

__all__ = [
"IntelligentSystemGroupDatasetReader",
"SurveyDatasetReader",
]
11 changes: 11 additions & 0 deletions csrank/dataset_reader/objectranking/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@
from .tag_genome_object_ranking_dataset_reader import (
TagGenomeObjectRankingDatasetReader,
)

__all__ = [
"DepthDatasetReader",
"ImageDatasetReader",
"LetorListwiseObjectRankingDatasetReader",
"SentenceOrderingDatasetReader",
"ObjectRankingDatasetGenerator",
"RCVDatasetReader",
"SushiObjectRankingDatasetReader",
"TagGenomeObjectRankingDatasetReader",
]
17 changes: 17 additions & 0 deletions csrank/discretechoice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,20 @@
from .paired_combinatorial_logit import PairedCombinatorialLogit
from .pairwise_discrete_choice import PairwiseSVMDiscreteChoiceFunction
from .ranknet_discrete_choice import RankNetDiscreteChoiceFunction

__all__ = [
"RandomBaselineDC",
"CmpNetDiscreteChoiceFunction",
"FATEDiscreteChoiceFunction",
"FATELinearDiscreteChoiceFunction",
"FETADiscreteChoiceFunction",
"FETALinearDiscreteChoiceFunction",
"GeneralizedNestedLogitModel",
"MixedLogitModel",
"ModelSelector",
"MultinomialLogitModel",
"NestedLogitModel",
"PairedCombinatorialLogit",
"PairwiseSVMDiscreteChoiceFunction",
"RankNetDiscreteChoiceFunction",
]
33 changes: 23 additions & 10 deletions csrank/objectranking/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
from .cmp_net import CmpNet
from .expected_rank_regression import ExpectedRankRegression
from .fate_object_ranker import FATEObjectRanker
from .fatelinear_object_ranker import FATELinearObjectRanker
from .feta_object_ranker import FETAObjectRanker
from .fetalinear_object_ranker import FETALinearObjectRanker
from .list_net import ListNet
from .rank_net import RankNet
from .rank_svm import RankSVM
from .baseline import RandomBaselineRanker
from .cmp_net import CmpNet
from .expected_rank_regression import ExpectedRankRegression
from .fate_object_ranker import FATEObjectRanker
from .fatelinear_object_ranker import FATELinearObjectRanker
from .feta_object_ranker import FETAObjectRanker
from .fetalinear_object_ranker import FETALinearObjectRanker
from .list_net import ListNet
from .rank_net import RankNet
from .rank_svm import RankSVM
from .baseline import RandomBaselineRanker

__all__ = [
"CmpNet",
"ExpectedRankRegression",
"FATEObjectRanker",
"FATELinearObjectRanker",
"FETAObjectRanker",
"FETALinearObjectRanker",
"ListNet",
"RankNet",
"RankSVM",
"RandomBaselineRanker",
]

0 comments on commit 346010f

Please sign in to comment.