Skip to content

Commit

Permalink
Update dev docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Nov 3, 2023
1 parent 5755365 commit 46f1986
Show file tree
Hide file tree
Showing 25 changed files with 330 additions and 935 deletions.
73 changes: 20 additions & 53 deletions docs/monty.collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,14 @@ to the traditional way obj[‘foo’]”
>>> assert d.bar == "hello"
```


* **Parameters**

* **args** – Passthrough arguments for standard dict.


* **kwargs** – Passthrough keyword arguments for standard dict.
* **args** – Passthrough arguments for standard dict.
* **kwargs** – Passthrough keyword arguments for standard dict.

### copy()


* **Returns**
Copy of AttrDict
Copy of AttrDict

## *class* monty.collections.FrozenAttrDict(\*args, \*\*kwargs)

Expand All @@ -52,13 +47,9 @@ A dictionary that:
to the traditional way obj[‘foo’]
```


* **Parameters**

* **args** – Passthrough arguments for standard dict.


* **kwargs** – Passthrough keyword arguments for standard dict.
* **args** – Passthrough arguments for standard dict.
* **kwargs** – Passthrough keyword arguments for standard dict.

## *class* monty.collections.MongoDict(\*args, \*\*kwargs)

Expand All @@ -83,37 +74,25 @@ database).
dict.keys and dict.items will pollute the namespace.
e.g MongoDict({“keys”: 1}).keys would be the ABC dict method.


* **Parameters**

* **args** – Passthrough arguments for standard dict.


* **kwargs** – Passthrough keyword arguments for standard dict.
* **args** – Passthrough arguments for standard dict.
* **kwargs** – Passthrough keyword arguments for standard dict.

## *class* monty.collections.Namespace(\*args, \*\*kwargs)

Bases: `dict`

A dictionary that does not permit to redefine its keys.


* **Parameters**

* **args** – Passthrough arguments for standard dict.


* **kwargs** – Passthrough keyword arguments for standard dict.
* **args** – Passthrough arguments for standard dict.
* **kwargs** – Passthrough keyword arguments for standard dict.

### update(\*args, \*\*kwargs)


* **Parameters**

* **args** – Passthrough arguments for standard dict.


* **kwargs** – Passthrough keyword arguments for standard dict.
* **args** – Passthrough arguments for standard dict.
* **kwargs** – Passthrough keyword arguments for standard dict.

## monty.collections.dict2namedtuple(\*args, \*\*kwargs)

Expand All @@ -133,15 +112,12 @@ Helper function to create a `namedtuple` from a dictionary.

**WARNING**:


* The order of the items in the namedtuple is not deterministic if
kwargs are used.
namedtuples, however, should always be accessed by attribute hence
this behaviour should not represent a serious problem.


kwargs are used.
namedtuples, however, should always be accessed by attribute hence
this behaviour should not represent a serious problem.
* Don’t use this function in code in which memory and performance are
crucial since a dict is needed to instantiate the tuple!
crucial since a dict is needed to instantiate the tuple!

## *class* monty.collections.frozendict(\*args, \*\*kwargs)

Expand All @@ -150,23 +126,15 @@ Bases: `dict`
A dictionary that does not permit changes. The naming
violates PEP8 to be consistent with standard Python’s “frozenset” naming.


* **Parameters**

* **args** – Passthrough arguments for standard dict.


* **kwargs** – Passthrough keyword arguments for standard dict.
* **args** – Passthrough arguments for standard dict.
* **kwargs** – Passthrough keyword arguments for standard dict.

### update(\*args, \*\*kwargs)


* **Parameters**

* **args** – Passthrough arguments for standard dict.


* **kwargs** – Passthrough keyword arguments for standard dict.
* **args** – Passthrough arguments for standard dict.
* **kwargs** – Passthrough keyword arguments for standard dict.

## monty.collections.tree()

Expand All @@ -180,6 +148,5 @@ x = tree()
x[‘a’][‘b’][‘c’] = 1
```


* **Returns**
A tree.
A tree.
45 changes: 14 additions & 31 deletions docs/monty.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,17 @@ particularly useful for developers. E.g., deprecating methods / classes, etc.
Decorator to mark classes or functions as deprecated,
with a possible replacement.


* **Parameters**

* **replacement** (*callable*) – A replacement class or method.


* **message** (*str*) – A warning message to be displayed.


* **category** (*Warning*) – Choose the category of the warning to issue. Defaults
to FutureWarning. Another choice can be DeprecationWarning. NOte that
FutureWarning is meant for end users and is always shown unless silenced.
DeprecationWarning is meant for developers and is never shown unless
python is run in developmental mode or the filter is changed. Make
the choice accordingly.


* **replacement** (*callable*) – A replacement class or method.
* **message** (*str*) – A warning message to be displayed.
* **category** (*Warning*) – Choose the category of the warning to issue. Defaults
to FutureWarning. Another choice can be DeprecationWarning. NOte that
FutureWarning is meant for end users and is always shown unless silenced.
DeprecationWarning is meant for developers and is never shown unless
python is run in developmental mode or the filter is changed. Make
the choice accordingly.
* **Returns**
Original function, but with a warning to use the updated class.
Original function, but with a warning to use the updated class.

## monty.dev.get_ncpus()

Expand All @@ -55,9 +47,8 @@ verbose for Ka-Ping Yee’s “cgitb.py” version kwargs are the keyword
arguments passed to the constructor. See IPython.core.ultratb.py for more
info.


* **Returns**
0 if hook is installed successfully.
0 if hook is installed successfully.

## *class* monty.dev.requires(condition, message)

Expand All @@ -80,16 +71,8 @@ def use_scipy():
print(scipy.majver)
```


* **Parameters**

* **condition** – Condition necessary to use the class or function.


* **message** – A message to be displayed if the condition is not True.


* **condition** – A expression returning a bool.


* **message** – Message to display if condition is False.
* **condition** – Condition necessary to use the class or function.
* **message** – A message to be displayed if the condition is not True.
* **condition** – A expression returning a bool.
* **message** – Message to display if condition is False.
10 changes: 3 additions & 7 deletions docs/monty.fnmatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@ shell patterns (fnmatch).

Initializes a WildCard.


* **Parameters**

* **wildcard** (*str*) – String of tokens separated by sep. Each token
represents a pattern.


* **sep** (*str*) – Separator for shell patterns.
* **wildcard** (*str*) – String of tokens separated by sep. Each token
represents a pattern.
* **sep** (*str*) – Separator for shell patterns.

### filter(names)

Expand Down
26 changes: 7 additions & 19 deletions docs/monty.fractions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,27 @@ Math functions.

Returns the greatest common divisor for a sequence of numbers.


* **Parameters**
**\*numbers** – Sequence of numbers.


**\*numbers** – Sequence of numbers.
* **Returns**
(int) Greatest common divisor of numbers.
(int) Greatest common divisor of numbers.

## monty.fractions.gcd_float(numbers, tol=1e-08)

Returns the greatest common divisor for a sequence of numbers.
Uses a numerical tolerance, so can be used on floats


* **Parameters**

* **numbers** – Sequence of numbers.


* **tol** – Numerical tolerance


* **numbers** – Sequence of numbers.
* **tol** – Numerical tolerance
* **Returns**
(int) Greatest common divisor of numbers.
(int) Greatest common divisor of numbers.

## monty.fractions.lcm(\*numbers)

Return lowest common multiple of a sequence of numbers.


* **Parameters**
**\*numbers** – Sequence of numbers.


**\*numbers** – Sequence of numbers.
* **Returns**
(int) Lowest common multiple of numbers.
(int) Lowest common multiple of numbers.
25 changes: 6 additions & 19 deletions docs/monty.functools.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ Bases: `Exception`

Exception class for timeouts.


* **Parameters**
**message** – Error message
**message** – Error message

## *class* monty.functools.lazy_property(func)

Expand All @@ -27,9 +26,8 @@ lazy_property descriptor
Used as a decorator to create lazy attributes. Lazy attributes
are evaluated on first use.


* **Parameters**
**func** – Function to decorate.
**func** – Function to decorate.

### *classmethod* invalidate(inst, name)

Expand Down Expand Up @@ -75,13 +73,10 @@ becomes
The decorated main accepts two new arguments:

> prof_file: Name of the output file with profiling data
> ```none
> If not given, a temporary file is created.
> ```
> sortby: Profiling data are sorted according to this value.
> ```none
> default is “time”. See sort_stats.
> ```
Expand Down Expand Up @@ -141,20 +136,12 @@ except TimeoutError:
do_something_else()
```


* **Parameters**

* **seconds** (*int*) – Allowed time for function in seconds.


* **error_message** (*str*) – An error message.
* **seconds** (*int*) – Allowed time for function in seconds.
* **error_message** (*str*) – An error message.

### handle_timeout(signum, frame)


* **Parameters**

* **signum** – Return signal from call.


* **frame**
* **signum** – Return signal from call.
* **frame**

0 comments on commit 46f1986

Please sign in to comment.