Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update docs #63

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ target/

#Ipython Notebook
.ipynb_checkpoints

.DS_Store
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ If you just want `reach`:
pip install reach
```

If you also want [`AutoReach`](#autoreach):

```
pip install reach[auto]
```

## Example

```python
Expand Down
8 changes: 4 additions & 4 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = reach
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

Expand Down
109 changes: 16 additions & 93 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,114 +1,37 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys

sys.path.insert(0, os.path.abspath("../"))
sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath(".."))
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "reach"
copyright = "2023, Stéphan Tulkens"
copyright = "2024, Stéphan Tulkens"
author = "Stéphan Tulkens"

# The short X.Y version
version = "4.1.0"
# The full version, including alpha/beta/rc tags
release = "4.1.0"

release = "5.0.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
]

# Add any paths that contain templates here, relative to this directory.
napoleon_google_docstring = False
napoleon_use_param = False
napoleon_use_ivar = True
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"

# The master toctree document.
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = "en"

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

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
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
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = "reachdoc"

# -- Extension configuration -------------------------------------------------

# Napoleon settings
# napoleon_include_init_with_doc = True

# autodoc
autodoc_member_order = "bysource"
html_theme = "alabaster"
html_static_path = ["_static"]
14 changes: 5 additions & 9 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.. reach documentation master file, created by
sphinx-quickstart on Sun Jul 14 20:50:46 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
`reach <https://github.com/stephantul/reach>`_ documentation
===================================================================

Expand Down Expand Up @@ -26,15 +31,6 @@ If you just want reach:
$ pip install reach



If you also want AutoReach:


::

$ pip install reach[auto]


Contents
--------

Expand Down
4 changes: 0 additions & 4 deletions docs/requirements.txt

This file was deleted.

8 changes: 0 additions & 8 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,3 @@ Reach
.. autoclass:: reach.Reach
:members:
:undoc-members:


AutoReach
-------------------------

.. autoclass:: reach.AutoReach
:members:
:undoc-members:
8 changes: 1 addition & 7 deletions reach/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,5 @@

from reach.reach import Reach, normalize

try:
from reach.autoreach import AutoReach # noqa

__all__ = ["Reach", "normalize", "AutoReach"]
except ImportError:
__all__ = ["Reach", "normalize"]

__all__ = ["Reach", "normalize"]
__version__ = "4.1.1"
14 changes: 7 additions & 7 deletions reach/reach.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(
vectors: Matrix,
items: list[str],
name: str = "",
metadata: dict[str, Any] | None = None,
) -> None:
"""Initialize a Reach instance with an array and list of items."""
if len(items) != len(vectors):
Expand All @@ -75,6 +76,7 @@ def __init__(
self.name = name
self._unk_token: str | None = None
self._unk_index: int | None = None
self.metadata = metadata or {}

@property
def unk_token(self) -> str | None:
Expand Down Expand Up @@ -972,7 +974,6 @@ def save_fast_format(
self,
path: PathLike,
overwrite: bool = False,
additional_metadata: dict[str, str] | None = None,
) -> None:
"""
Save a reach instance in a fast format.
Expand Down Expand Up @@ -1007,8 +1008,7 @@ def save_fast_format(
"unk_token": self.unk_token,
"name": self.name,
}
if additional_metadata is not None:
metadata.update(additional_metadata)
metadata.update(self.metadata)

items = self.sorted_items
items_dict = {
Expand Down Expand Up @@ -1045,9 +1045,9 @@ def load_fast_format(
data: dict[str, Any] = json.load(file_handle)
items: list[str] = data["items"]

metadata: dict[str, Any] = data.get("metadata", {})
unk_token = metadata.get("unk_token")
name = metadata.get("name", "")
metadata: dict[str, Any] = data["metadata"]
unk_token = metadata.pop("unk_token")
name = metadata.pop("name")
numpy_path = filename_path.parent / Path(data["vectors_path"])

if not numpy_path.exists():
Expand All @@ -1056,7 +1056,7 @@ def load_fast_format(
with open(numpy_path, "rb") as file_handle:
vectors: npt.NDArray = np.load(file_handle)
vectors = vectors.astype(desired_dtype)
instance = cls(vectors, items, name=name)
instance = cls(vectors, items, name=name, metadata=metadata)
instance.unk_token = unk_token

return instance
Expand Down
Loading