Skip to content

Commit

Permalink
updated pytype & coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
tmbo committed Feb 13, 2020
1 parent e4926b0 commit 7d7178c
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ lint:
black --check rasa tests

types:
pytype --keep-going rasa
pytype --keep-going rasa -j 16

prepare-tests-macos: prepare-wget-macos prepare-tests-files
brew install graphviz || true
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/featurizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def action_as_one_hot(action: Text, domain: Domain) -> np.ndarray:
def create_encoded_all_actions(self, domain: Domain) -> np.ndarray:
"""Create matrix with all actions from domain encoded in rows."""

pass
raise NotImplementedError("Featurizer must implement encoding actions.")


class BinarySingleStateFeaturizer(SingleStateFeaturizer):
Expand Down
4 changes: 2 additions & 2 deletions rasa/core/policies/embedding_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ def _create_session_data(
label_ids = np.expand_dims(label_ids, -1)
else:
# prediction time
label_ids = None
Y = None
label_ids = np.asarray([])
Y = np.asarray([])

return {
"dialogue_features": [data_X],
Expand Down
4 changes: 3 additions & 1 deletion rasa/core/training/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def __init__(
def limit_training_data_to(self, max_samples: int) -> None:
self.X = self.X[:max_samples]
self.y = self.y[:max_samples]
self.true_length = self.true_length[:max_samples]
self.true_length = (
self.true_length[:max_samples] if self.true_length is not None else None
)

def is_empty(self) -> bool:
"""Check if the training matrix does contain training samples."""
Expand Down
4 changes: 2 additions & 2 deletions rasa/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def is_int(value: Any) -> bool:
return False


def one_hot(hot_idx: int, length: int, dtype: Optional[Text] = None) -> np.array:
def one_hot(hot_idx: int, length: int, dtype: Optional[Text] = None) -> np.ndarray:
if hot_idx >= length:
raise ValueError(
"Can't create one hot. Index '{}' is out "
Expand Down Expand Up @@ -176,7 +176,7 @@ def __eq__(self, other) -> bool:
def __hash__(self) -> int:
return self.__hash

def unwrap(self) -> np.array:
def unwrap(self) -> np.ndarray:
"""Returns the encapsulated ndarray.
If the wrapper is "tight", a copy of the encapsulated ndarray is
Expand Down
8 changes: 4 additions & 4 deletions rasa/nlu/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@


def plot_confusion_matrix(
cm: np.array,
classes: np.array,
cm: np.ndarray,
classes: np.ndarray,
normalize: bool = False,
title: Text = "Confusion matrix",
cmap=None,
Expand Down Expand Up @@ -535,7 +535,7 @@ def evaluate_intents(
def _plot_confusion_matrix(
output_directory: Optional[Text],
confmat_filename: Optional[Text],
cnf_matrix: np.array,
cnf_matrix: np.ndarray,
labels: Collection[Text],
) -> None:
if output_directory:
Expand Down Expand Up @@ -563,7 +563,7 @@ def _plot_histogram(

def merge_labels(
aligned_predictions: List[Dict], extractor: Optional[Text] = None
) -> np.array:
) -> np.ndarray:
"""Concatenates all labels of the aligned predictions.
Takes the aligned prediction labels which are grouped for each message
and concatenates them."""
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ mongomock==3.18.0
# lint/format/types
black==19.10b0
flake8==3.7.8
pytype==2019.7.11
pytype==2020.2.6

# other
google-cloud-storage==1.7.0
azure-storage-blob==1.0.0
coveralls==1.7.0
coveralls==1.11.0

# release tools
semantic_version==2.8.3
Expand Down
8 changes: 4 additions & 4 deletions tests/core/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ async def test_message_processor(
await default_processor.handle_message(
UserMessage('/greet{"name":"Core"}', default_channel)
)
assert {
assert default_channel.latest_output() == {
"recipient_id": "default",
"text": "hey there Core!",
} == default_channel.latest_output()
}


async def test_message_id_logging(default_processor: MessageProcessor):
Expand Down Expand Up @@ -565,10 +565,10 @@ async def test_handle_message_with_session_start(
UserMessage(f"/greet{json.dumps(slot_1)}", default_channel, sender_id)
)

assert {
assert default_channel.latest_output() == {
"recipient_id": sender_id,
"text": "hey there Core!",
} == default_channel.latest_output()
}

# patch processor so a session start is triggered
monkeypatch.setattr(default_processor, "_has_session_expired", lambda _: True)
Expand Down

0 comments on commit 7d7178c

Please sign in to comment.