From 92ab1227edd28cf3da366e792a626c6f5c9a1d85 Mon Sep 17 00:00:00 2001 From: Emmanuelle Vargas-Gonzalez Date: Fri, 16 Oct 2020 17:12:52 -0400 Subject: [PATCH] docstrings, changes to equivalence.ipynb --- docs/guide/equivalence.ipynb | 18 ++++++++++-------- stix2/environment.py | 6 +++--- stix2/equivalence/graph/__init__.py | 5 +++-- stix2/equivalence/object/__init__.py | 5 +++-- stix2/equivalence/pattern/__init__.py | 2 +- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/docs/guide/equivalence.ipynb b/docs/guide/equivalence.ipynb index c0b9331..8393495 100644 --- a/docs/guide/equivalence.ipynb +++ b/docs/guide/equivalence.ipynb @@ -2165,15 +2165,17 @@ "The weights dictionary should contain both the weight and the comparison function for each property. You may use the default weights and functions, or provide your own.\n", "\n", "##### Existing comparison functions\n", - "For reference, here is a list of the comparison functions already built in the codebase (found in [stix2/environment.py](../api/stix2.environment.rst#stix2.environment.Environment)):\n", + "For reference, here is a list of the comparison functions already built in the codebase (found in [stix2/equivalence/object](../api/equivalence/stix2.equivalence.object.rst#module-stix2.equivalence.object)):\n", "\n", - " - [custom_pattern_based](../api/stix2.environment.rst#stix2.environment.custom_pattern_based)\n", - " - [exact_match](../api/stix2.environment.rst#stix2.environment.exact_match)\n", - " - [partial_external_reference_based](../api/stix2.environment.rst#stix2.environment.partial_external_reference_based)\n", - " - [partial_list_based](../api/stix2.environment.rst#stix2.environment.partial_list_based)\n", - " - [partial_location_distance](../api/stix2.environment.rst#stix2.environment.partial_location_distance)\n", - " - [partial_string_based](../api/stix2.environment.rst#stix2.environment.partial_string_based)\n", - " - [partial_timestamp_based](../api/stix2.environment.rst#stix2.environment.partial_timestamp_based)\n", + " - [custom_pattern_based](../api/equivalence/stix2.equivalence.object.rst#stix2.equivalence.object.custom_pattern_based)\n", + " - [exact_match](../api/equivalence/stix2.equivalence.object.rst#stix2.equivalence.object.exact_match)\n", + " - [list_reference_check](../api/equivalence/stix2.equivalence.object.rst#stix2.equivalence.object.list_reference_check)\n", + " - [partial_external_reference_based](../api/equivalence/stix2.equivalence.object.rst#stix2.equivalence.object.partial_external_reference_based)\n", + " - [partial_list_based](../api/equivalence/stix2.equivalence.object.rst#stix2.equivalence.object.partial_list_based)\n", + " - [partial_location_distance](../api/equivalence/stix2.equivalence.object.rst#stix2.equivalence.object.partial_location_distance)\n", + " - [partial_string_based](../api/equivalence/stix2.equivalence.object.rst#stix2.equivalence.object.partial_string_based)\n", + " - [partial_timestamp_based](../api/equivalence/stix2.equivalence.object.rst#stix2.equivalence.object.partial_timestamp_based)\n", + " - [reference_check](../api/equivalence/stix2.equivalence.object.rst#stix2.equivalence.object.reference_check)\n", "\n", "For instance, if we wanted to compare two of the `ThreatActor`s from before, but use our own weights, then we could do the following:" ] diff --git a/stix2/environment.py b/stix2/environment.py index ea93a83..f31762c 100644 --- a/stix2/environment.py +++ b/stix2/environment.py @@ -4,7 +4,7 @@ import copy from .datastore import CompositeDataSource, DataStoreMixin from .equivalence.graph import graphically_equivalent from .equivalence.object import ( # noqa: F401 - check_property_present, custom_pattern_based, exact_match, + WEIGHTS, check_property_present, custom_pattern_based, exact_match, list_reference_check, partial_external_reference_based, partial_list_based, partial_location_distance, partial_string_based, partial_timestamp_based, reference_check, semantically_equivalent, @@ -222,7 +222,7 @@ class Environment(DataStoreMixin): Note: Default weights_dict: - .. include:: ../default_sem_eq_weights.rst + .. include:: ../object_default_sem_eq_weights.rst Note: This implementation follows the Semantic Equivalence Committee Note. @@ -260,7 +260,7 @@ class Environment(DataStoreMixin): Note: Default weights_dict: - .. include:: ../default_sem_eq_weights.rst + .. include:: ../graph_default_sem_eq_weights.rst Note: This implementation follows the Semantic Equivalence Committee Note. diff --git a/stix2/equivalence/graph/__init__.py b/stix2/equivalence/graph/__init__.py index 3c8730a..680f42f 100644 --- a/stix2/equivalence/graph/__init__.py +++ b/stix2/equivalence/graph/__init__.py @@ -1,3 +1,4 @@ +"""Python APIs for STIX 2 Graph-based Semantic Equivalence.""" import logging from ..object import ( @@ -36,7 +37,7 @@ def graphically_equivalent(ds1, ds2, prop_scores={}, **weight_dict): Note: Default weights_dict: - .. include:: ../default_sem_eq_weights.rst + .. include:: ../../graph_default_sem_eq_weights.rst Note: This implementation follows the Semantic Equivalence Committee Note. @@ -133,4 +134,4 @@ GRAPH_WEIGHTS.update({ "ds2": None, "max_depth": 1, }, -}) #: :autodoc-skip: +}) # :autodoc-skip: diff --git a/stix2/equivalence/object/__init__.py b/stix2/equivalence/object/__init__.py index c24fa3c..8333ceb 100644 --- a/stix2/equivalence/object/__init__.py +++ b/stix2/equivalence/object/__init__.py @@ -1,3 +1,4 @@ +"""Python APIs for STIX 2 Object-based Semantic Equivalence.""" import logging import time @@ -32,7 +33,7 @@ def semantically_equivalent(obj1, obj2, prop_scores={}, **weight_dict): Note: Default weights_dict: - .. include:: ../default_sem_eq_weights.rst + .. include:: ../../object_default_sem_eq_weights.rst Note: This implementation follows the Semantic Equivalence Committee Note. @@ -448,4 +449,4 @@ WEIGHTS = { "_internal": { "ignore_spec_version": False, }, -} #: :autodoc-skip: +} # :autodoc-skip: diff --git a/stix2/equivalence/pattern/__init__.py b/stix2/equivalence/pattern/__init__.py index 10494f7..b2e5421 100644 --- a/stix2/equivalence/pattern/__init__.py +++ b/stix2/equivalence/pattern/__init__.py @@ -1,7 +1,7 @@ """Python APIs for STIX 2 Pattern Semantic Equivalence. .. autosummary:: - :toctree: patterns + :toctree: pattern compare transform