Skip to content

Commit

Permalink
bump version to 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cwmeijer committed Jun 6, 2023
1 parent 6075edb commit 70c5aeb
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.9.0
current_version = 1.0.0

[comment]
comment = The contents of this file cannot be merged with that of setup.cfg until https://github.com/c4urself/bump2version/issues/185 is resolved
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ authors:
orcid: "https://orcid.org/0000-0002-5413-9038"

doi: 10.5281/zenodo.5801485
version: "0.9.0"
version: "1.0.0"
repository-code: "https://github.com/dianna-ai/dianna"
keywords:
- XAI
Expand Down
61 changes: 34 additions & 27 deletions dianna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@

logging.getLogger(__name__).addHandler(logging.NullHandler())

__author__ = "DIANNA Team"
__email__ = "dianna-ai@esciencecenter.nl"
__version__ = "0.9.0"
__author__ = 'DIANNA Team'
__email__ = 'dianna-ai@esciencecenter.nl'
__version__ = '1.0.0'


def explain_timeseries(model_or_function, timeseries_data, method, labels, **kwargs):
def explain_timeseries(model_or_function, timeseries_data, method, labels,
**kwargs):
"""Explain timeseries data given a model and a chosen method.
Args:
Expand All @@ -46,11 +47,10 @@ def explain_timeseries(model_or_function, timeseries_data, method, labels, **kwa
One heatmap per class.
"""
explainer = _get_explainer(method, kwargs, modality="Timeseries")
explain_timeseries_kwargs = utils.get_kwargs_applicable_to_function(explainer.explain, kwargs)
return explainer.explain(model_or_function,
timeseries_data,
labels,
explainer = _get_explainer(method, kwargs, modality='Timeseries')
explain_timeseries_kwargs = utils.get_kwargs_applicable_to_function(
explainer.explain, kwargs)
return explainer.explain(model_or_function, timeseries_data, labels,
**explain_timeseries_kwargs)


Expand All @@ -69,15 +69,18 @@ def explain_image(model_or_function, input_data, method, labels, **kwargs):
One heatmap (2D array) per class.
"""
if method.upper() == "KERNELSHAP":
if method.upper() == 'KERNELSHAP':
# To avoid Access Violation on Windows with SHAP:
from onnx_tf.backend import prepare # noqa: F401
explainer = _get_explainer(method, kwargs, modality="Image")
explain_image_kwargs = utils.get_kwargs_applicable_to_function(explainer.explain, kwargs)
return explainer.explain(model_or_function, input_data, labels, **explain_image_kwargs)
explainer = _get_explainer(method, kwargs, modality='Image')
explain_image_kwargs = utils.get_kwargs_applicable_to_function(
explainer.explain, kwargs)
return explainer.explain(model_or_function, input_data, labels,
**explain_image_kwargs)


def explain_text(model_or_function, input_text, tokenizer, method, labels, **kwargs):
def explain_text(model_or_function, input_text, tokenizer, method, labels,
**kwargs):
"""Explain text (input_text) given a model and a chosen method.
Args:
Expand All @@ -93,24 +96,28 @@ def explain_text(model_or_function, input_text, tokenizer, method, labels, **kwa
List of (word, index of word in raw text, importance for target class) tuples.
"""
explainer = _get_explainer(method, kwargs, modality="Text")
explain_text_kwargs = utils.get_kwargs_applicable_to_function(explainer.explain, kwargs)
return explainer.explain(
model_or_function=model_or_function,
input_text=input_text,
labels=labels,
tokenizer=tokenizer,
**explain_text_kwargs)
explainer = _get_explainer(method, kwargs, modality='Text')
explain_text_kwargs = utils.get_kwargs_applicable_to_function(
explainer.explain, kwargs)
return explainer.explain(model_or_function=model_or_function,
input_text=input_text,
labels=labels,
tokenizer=tokenizer,
**explain_text_kwargs)


def _get_explainer(method, kwargs, modality):
try:
method_submodule = importlib.import_module(f'dianna.methods.{method.lower()}')
method_submodule = importlib.import_module(
f'dianna.methods.{method.lower()}')
except ImportError as err:
raise ValueError(f"Method {method} does not exist") from err
raise ValueError(f'Method {method} does not exist') from err
try:
method_class = getattr(method_submodule, f"{method.upper()}{modality}")
method_class = getattr(method_submodule, f'{method.upper()}{modality}')
except AttributeError as err:
raise ValueError(f"Data modality {modality} is not available for method {method.upper()}") from err
method_kwargs = utils.get_kwargs_applicable_to_function(method_class.__init__, kwargs)
raise ValueError(
f'Data modality {modality} is not available for method {method.upper()}'
) from err
method_kwargs = utils.get_kwargs_applicable_to_function(
method_class.__init__, kwargs)
return method_class(**method_kwargs)
47 changes: 20 additions & 27 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

# -- Project information -----------------------------------------------------

project = u"dianna"
copyright = u"2022, Netherlands eScience Center"
author = u"DIANNA Team"
project = u'dianna'
copyright = u'2022, Netherlands eScience Center'
author = u'DIANNA Team'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "0.9.0"
version = '1.0.0'
# The full version, including alpha/beta/rc tags.
release = version

Expand All @@ -36,27 +36,19 @@
# extensions coming with Sphinx (named "sphinx.ext.*") or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"autoapi.extension",
"nbsphinx",
"nbsphinx_link",
"myst_parser"
'sphinx.ext.autodoc', 'sphinx.ext.coverage', 'sphinx.ext.doctest',
'sphinx.ext.intersphinx', 'sphinx.ext.mathjax', 'sphinx.ext.napoleon',
'sphinx.ext.todo', 'sphinx.ext.viewcode', 'autoapi.extension', 'nbsphinx',
'nbsphinx_link', 'myst_parser'
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -70,7 +62,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
html_theme = 'sphinx_rtd_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -80,11 +72,12 @@

# -- Options for Intersphinx

intersphinx_mapping = {'python': ('https://docs.python.org/3', None),
# Commonly used libraries, uncomment when used in package
# 'numpy': ('http://docs.scipy.org/doc/numpy/', None),
# 'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None),
# 'scikit-learn': ('https://scikit-learn.org/stable/', None),
# 'matplotlib': ('https://matplotlib.org/stable/', None),
# 'pandas': ('http://pandas.pydata.org/docs/', None),
}
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
# Commonly used libraries, uncomment when used in package
# 'numpy': ('http://docs.scipy.org/doc/numpy/', None),
# 'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None),
# 'scikit-learn': ('https://scikit-learn.org/stable/', None),
# 'matplotlib': ('https://matplotlib.org/stable/', None),
# 'pandas': ('http://pandas.pydata.org/docs/', None),
}
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ name = dianna
project_urls =
Bug Tracker = https://github.com/dianna-ai/dianna/issues
url = https://github.com/dianna-ai/dianna
version = 0.9.0
version = 1.0.0
license = Apache License 2.0

[options]
Expand Down

0 comments on commit 70c5aeb

Please sign in to comment.