Skip to content

Commit

Permalink
Fixes on advice of @orbeckst.
Browse files Browse the repository at this point in the history
  • Loading branch information
dotsdl committed Mar 23, 2016
1 parent c46aa01 commit 8641b24
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
28 changes: 15 additions & 13 deletions docs/bundles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ would work equally well.
Gathering Treants from the filesystem
=====================================
It can be tedious manually hunting for existing Treants throughout the
filesystem. For this reason the :func:`datreant.core.discover` function
filesystem. For this reason the :func:`~datreant.core.discover` function
can do this work for us::

>>> b = dtr.discover('.')
Expand All @@ -39,9 +39,10 @@ can do this work for us::

For this simple example all our Treants were in this directory, so it's not
quite as useful. But for a directory structure that is deep and convoluted
perhaps from a project spanning years, ``discover`` lets you get a Bundle of
all Treants in the tree with little effort. You can then filter on tags and
categories to get Bundles of the Treants you actually want to work with.
perhaps from a project spanning years, :func:`~datreant.core.discover` lets
you get a Bundle of all Treants in the tree with little effort. You can then
filter on tags and categories to get Bundles of the Treants you actually want
to work with.

See the :func:`datreant.core.discover` API reference for more details.

Expand Down Expand Up @@ -203,7 +204,7 @@ which we can use directly as an "or"-ing in a tag expression::
<Bundle([<Treant: 'oak'>, <Treant: 'elm'>])>

The threshold for fuzzy matching can be set with the ``threshold`` parameter.
See the API reference for :meth:`datreant.core.agglimbs.AggTags.fuzzy` for more
See the API reference for :meth:`~datreant.core.agglimbs.AggTags.fuzzy` for more
details on how to use this method.

Grouping with Treant categories
Expand Down Expand Up @@ -302,7 +303,8 @@ Grouping by value
-----------------
Since for a given key a Bundle may have members with a variety of values,
it can be useful to get subsets of the Bundle as a function of value for a
given key. We can do this using the ``groupby`` method::
given key. We can do this using the
:meth:`~datreant.core.agglimbs.AggCategories.groupby` method::

>>> b.categories.groupby('type')
{'deciduous': <Bundle([<Treant: 'maple'>, <Treant: 'oak'>, <Treant: 'elm'>])>,
Expand All @@ -327,7 +329,7 @@ Now the keys of the resulting dictionary are tuples of value combinations for
which there are members. The resulting Bundles don't include some members since
not every member has both the keys 'type' and 'health'.

See the API reference for :meth:`datreant.core.agglimbs.AggCategories.groupby`
See the API reference for :meth:`~datreant.core.agglimbs.AggCategories.groupby`
for more details on how to use this method.


Expand All @@ -348,11 +350,11 @@ This example isn't the most useful, but the point is that we can apply any
function across all members without much fanfare, with the results returned
in a list and in member order.

The ``map`` method also features a ``processes`` parameter, and setting this
to an integer greater than 1 will use the :mod:`multiprocessing` module
internally to map the function across all members using multiple processes.
For this to work, we have to give our function an actual name so it can
be serialized (pickled) by ``multiprocessing``::
The :meth:`~datreant.core.Bundle.map` method also features a ``processes``
parameter, and setting this to an integer greater than 1 will use the
:mod:`multiprocessing` module internally to map the function across all members
using multiple processes. For this to work, we have to give our function an
actual name so it can be serialized (pickled) by :mod:`multiprocessing`::

>>> def get_tags(treant):
... return (treant.name, set(treant.tags))
Expand All @@ -367,7 +369,7 @@ that the parallelism gave any advantage here. But functions that need to do
more complicated work with each Treant and the data stored within its tree can
gain much from process parallelism when applied to a Bundle of many Treants.

See the API reference for :meth:`datreant.core.Bundle.map` for more details on
See the API reference for :meth:`~datreant.core.Bundle.map` for more details on
how to use this method.

API Reference: Bundle
Expand Down
2 changes: 1 addition & 1 deletion docs/groups.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ members. It will first check the last known locations for each member, and
for those it has yet to find it will begin a downward search starting from its
own tree, then its parent tree, etc. It will continue this process until it
either finds all its members, hits the root of the filesystem, or its search
times out.
times out. If it fails to find a member it will raise an :exc:`IOError`.

If the Group you are using fails to find some of its members before timing out,
you can set the maximum search time to a longer timeout, in seconds::
Expand Down
7 changes: 4 additions & 3 deletions docs/tags-categories.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ of **Treant** it is working with using ::
'dark'

The keys for categories must be strings, but the values may be strings, numbers
(floats, ints), or booleans (``True``, ``False``). ``None`` may not be used since
this is used in aggregations (see :ref:`Bundles`) to indicate keys that are
absent.
(floats, ints), or booleans (``True``, ``False``).

.. note:: ``None`` may not be used as a category value since this is used in
aggregations (see :ref:`Bundles`) to indicate keys that are absent.

API Reference: Categories
-------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/datreant/core/treants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Treant(six.with_metaclass(_Treantmeta, Tree)):
A Tree object may also be used in the same way as a directory string.
If multiple Treant state files are in the given directory, a
``MultipleTreantsError`` will be raised; specify the full path to the
:exc:`MultipleTreantsError` will be raised; specify the full path to the
desired state file to regenerate the desired Treant in this case. It is
generally better to avoid having multiple state files in the same
directory.
Expand Down Expand Up @@ -351,7 +351,7 @@ class Group(Treant):
A Tree object may also be used in the same way as a directory string.
If multiple Treant/Group state files are in the given directory, a
``MultipleTreantsError`` will be raised; specify the full path to the
:exc:`MultipleTreantsError` will be raised; specify the full path to the
desired state file to regenerate the desired Group in this case. It is
generally better to avoid having multiple state files in the same
directory.
Expand Down

0 comments on commit 8641b24

Please sign in to comment.