refrax 0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- refrax/__init__.py +10 -0
- refrax/custom_types.py +5 -0
- refrax/lens.py +178 -0
- refrax/mixin.py +10 -0
- refrax/traversal.py +130 -0
- refrax-0.0.2.dist-info/METADATA +75 -0
- refrax-0.0.2.dist-info/RECORD +10 -0
- refrax-0.0.2.dist-info/WHEEL +5 -0
- refrax-0.0.2.dist-info/licenses/LICENSE +201 -0
- refrax-0.0.2.dist-info/top_level.txt +1 -0
refrax/__init__.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from importlib.metadata import version as _version, PackageNotFoundError
|
|
2
|
+
|
|
3
|
+
try:
|
|
4
|
+
__version__ = _version(__name__)
|
|
5
|
+
except PackageNotFoundError:
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
from refrax.lens import Lens as Lens
|
|
9
|
+
from refrax.traversal import Traversal as Traversal
|
|
10
|
+
from refrax.mixin import OpticsMixin as OpticsMixin
|
refrax/custom_types.py
ADDED
refrax/lens.py
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
from typing import Any, Callable, Generic, cast
|
|
2
|
+
|
|
3
|
+
import equinox as eqx
|
|
4
|
+
|
|
5
|
+
from refrax.custom_types import TRoot, PathOp, PathStep
|
|
6
|
+
from refrax.traversal import Traversal
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Lens(Generic[TRoot]):
|
|
10
|
+
"""A fluent interface for mutating immutable Equinox PyTrees.
|
|
11
|
+
|
|
12
|
+
Uses `eqx.tree_at` under the hood to functionally swap leaves in the PyTree,
|
|
13
|
+
making it completely safe for use inside JAX JIT/vmap boundaries.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
tree (TRoot): The root immutable object to be mutated.
|
|
17
|
+
path (list[PathStep] | None): The current traversal path from the root, by default None.
|
|
18
|
+
"""
|
|
19
|
+
_tree: TRoot
|
|
20
|
+
_path: list[PathStep]
|
|
21
|
+
|
|
22
|
+
def __init__(self, tree: TRoot, path: list[PathStep] | None = None) -> None:
|
|
23
|
+
self._tree = tree
|
|
24
|
+
self._path = path if path is not None else []
|
|
25
|
+
|
|
26
|
+
def __getattr__(self, name: str) -> "Lens[TRoot]":
|
|
27
|
+
"""Focuses the lens on a named attribute.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
name (str): The name of the attribute.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
Lens[TRoot]: A new Lens focused on the specified attribute.
|
|
34
|
+
"""
|
|
35
|
+
if name.startswith('__') and name.endswith('__'):
|
|
36
|
+
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
|
|
37
|
+
return Lens(self._tree, self._path + [("attr", name)])
|
|
38
|
+
|
|
39
|
+
def __getitem__(self, key: Any) -> "Lens[TRoot]":
|
|
40
|
+
"""Focuses the lens on a collection item, dictionary key, or attribute.
|
|
41
|
+
|
|
42
|
+
If the key is a string, it is treated as an attribute access
|
|
43
|
+
(equivalent to `getattr`). Otherwise, it is treated as an item access.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
key (Any): The index, key, or attribute name.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
Lens[TRoot]: A new Lens focused on the specified item or attribute.
|
|
50
|
+
"""
|
|
51
|
+
op: PathOp = "attr" if isinstance(key, str) else "item"
|
|
52
|
+
return Lens(self._tree, self._path + [(op, key)])
|
|
53
|
+
|
|
54
|
+
# --- The Bridge to Traversal ---
|
|
55
|
+
|
|
56
|
+
def select(self, *names: str) -> Traversal[TRoot]:
|
|
57
|
+
"""Branches the Lens into a Traversal targeting multiple attributes.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
*names (str): A variable number of attribute names to target.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
Traversal[TRoot]: A Traversal object focused on the specified attributes.
|
|
64
|
+
|
|
65
|
+
Examples:
|
|
66
|
+
>>> new_model = model.at.select('source_a', 'source_b').set(new_val)
|
|
67
|
+
"""
|
|
68
|
+
sub_paths: list[list[PathStep]] = [[("attr", name)] for name in names]
|
|
69
|
+
return Traversal(self._tree, self._path, sub_paths)
|
|
70
|
+
|
|
71
|
+
def each(self) -> Traversal[TRoot]:
|
|
72
|
+
"""Transforms a focus on a collection into a Traversal of its elements.
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
Traversal[TRoot]: A Traversal object focused on every item in the target collection.
|
|
76
|
+
|
|
77
|
+
Raises:
|
|
78
|
+
TypeError: If the current focus is not a dictionary, list, or tuple.
|
|
79
|
+
|
|
80
|
+
Examples:
|
|
81
|
+
>>> new_model = model.at.sources.each().apply(lambda x: x * 2)
|
|
82
|
+
"""
|
|
83
|
+
target = self.get()
|
|
84
|
+
sub_paths: list[list[PathStep]] = []
|
|
85
|
+
|
|
86
|
+
if isinstance(target, dict):
|
|
87
|
+
sub_paths = [[("item", key)] for key in target.keys()]
|
|
88
|
+
elif isinstance(target, (list, tuple)):
|
|
89
|
+
sub_paths = [[("item", i)] for i in range(len(target))]
|
|
90
|
+
else:
|
|
91
|
+
raise TypeError(f"Cannot iterate over {type(target).__name__} with .each()")
|
|
92
|
+
|
|
93
|
+
return Traversal(self._tree, self._path, sub_paths)
|
|
94
|
+
|
|
95
|
+
def filter(self, predicate: Callable[[Any], bool]) -> Traversal[TRoot]:
|
|
96
|
+
"""Traverses all attributes of the current focus that match a condition.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
predicate (Callable[[Any], bool]): A function that takes an attribute value
|
|
100
|
+
and returns True if it should be included in the Traversal.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
Traversal[TRoot]: A Traversal object focused on all matching attributes.
|
|
104
|
+
|
|
105
|
+
Examples:
|
|
106
|
+
>>> is_active = lambda s: getattr(s, 'is_active', False)
|
|
107
|
+
>>> new_model = model.at.filter(is_active).apply(freeze)
|
|
108
|
+
"""
|
|
109
|
+
target = self.get()
|
|
110
|
+
sub_paths: list[list[PathStep]] = []
|
|
111
|
+
|
|
112
|
+
for attr_name in dir(target):
|
|
113
|
+
if not attr_name.startswith('_'):
|
|
114
|
+
try:
|
|
115
|
+
val = getattr(target, attr_name)
|
|
116
|
+
if predicate(val):
|
|
117
|
+
sub_paths.append([("attr", attr_name)])
|
|
118
|
+
except Exception:
|
|
119
|
+
pass # Skip properties that error on read
|
|
120
|
+
|
|
121
|
+
return Traversal(self._tree, self._path, sub_paths)
|
|
122
|
+
|
|
123
|
+
# --- Core Retrieval & eqx.tree_at Logic ---
|
|
124
|
+
|
|
125
|
+
def _get_target_from(self, tree: Any) -> Any:
|
|
126
|
+
"""Traverses the recorded path from a specified tree to return the target node.
|
|
127
|
+
|
|
128
|
+
This is designed to be passed cleanly into `eqx.tree_at`.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
tree (Any): The tree to traverse.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
Any: The resolved target node.
|
|
135
|
+
"""
|
|
136
|
+
curr: Any = tree
|
|
137
|
+
for op_type, val in self._path:
|
|
138
|
+
if op_type == "attr":
|
|
139
|
+
curr = getattr(curr, cast(str, val))
|
|
140
|
+
elif op_type == "item":
|
|
141
|
+
curr = curr[val]
|
|
142
|
+
return curr
|
|
143
|
+
|
|
144
|
+
def get(self) -> Any:
|
|
145
|
+
"""Extracts the currently focused value.
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
Any: The value at the end of the Lens path.
|
|
149
|
+
"""
|
|
150
|
+
return self._get_target_from(self._tree)
|
|
151
|
+
|
|
152
|
+
def set(self, value: Any) -> TRoot:
|
|
153
|
+
"""Sets the focused target to a specific value.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
value (Any): The new value to assign.
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
TRoot: A new instance of the root tree with the updated value.
|
|
160
|
+
"""
|
|
161
|
+
if not self._path:
|
|
162
|
+
return cast(TRoot, value)
|
|
163
|
+
|
|
164
|
+
return eqx.tree_at(self._get_target_from, self._tree, replace=value)
|
|
165
|
+
|
|
166
|
+
def apply(self, func: Callable[[Any], Any]) -> TRoot:
|
|
167
|
+
"""Applies a transformation function to the focused target.
|
|
168
|
+
|
|
169
|
+
Args:
|
|
170
|
+
func (Callable[[Any], Any]): The function to transform the current value.
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
TRoot: A new instance of the root tree with the updated value.
|
|
174
|
+
"""
|
|
175
|
+
if not self._path:
|
|
176
|
+
return cast(TRoot, func(self._tree))
|
|
177
|
+
|
|
178
|
+
return eqx.tree_at(self._get_target_from, self._tree, replace_fn=func)
|
refrax/mixin.py
ADDED
refrax/traversal.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
from typing import Generic, Any, Callable, cast
|
|
2
|
+
|
|
3
|
+
import equinox as eqx
|
|
4
|
+
|
|
5
|
+
from refrax.custom_types import TRoot, PathStep, PathOp
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Traversal(Generic[TRoot]):
|
|
9
|
+
"""Represents a multi-target focus within an immutable PyTree.
|
|
10
|
+
|
|
11
|
+
Applies mutations across all targets simultaneously using `eqx.tree_at`,
|
|
12
|
+
making it fully compatible with JAX JIT compilation and tracing.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
tree (TRoot): The root immutable object (e.g., Equinox module or dataclass).
|
|
16
|
+
base_path (list[PathStep]): The shared path from the root to the divergence point.
|
|
17
|
+
sub_paths (list[list[PathStep]]): A list of diverging paths, one for each targeted element.
|
|
18
|
+
"""
|
|
19
|
+
def __init__(self, tree: TRoot, base_path: list[PathStep], sub_paths: list[list[PathStep]]) -> None:
|
|
20
|
+
self._tree = tree
|
|
21
|
+
self._base_path = base_path
|
|
22
|
+
self._sub_paths = sub_paths
|
|
23
|
+
|
|
24
|
+
def __getattr__(self, name: str) -> "Traversal[TRoot]":
|
|
25
|
+
"""Broadens the traversal by appending an attribute access to every currently focused target.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
name (str): The name of the attribute to access on all targets.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
Traversal[TRoot]: A new Traversal focused one level deeper.
|
|
32
|
+
"""
|
|
33
|
+
new_sub_paths = [path + [("attr", name)] for path in self._sub_paths]
|
|
34
|
+
return Traversal(self._tree, self._base_path, new_sub_paths)
|
|
35
|
+
|
|
36
|
+
def __getitem__(self, key: Any) -> "Traversal[TRoot]":
|
|
37
|
+
"""Broadens the traversal by appending an item/index access to every currently focused target.
|
|
38
|
+
|
|
39
|
+
Strings are treated as attributes.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
key (Any): The index, dictionary key, or attribute string to access.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
Traversal[TRoot]: A new Traversal focused one level deeper.
|
|
46
|
+
"""
|
|
47
|
+
op: PathOp = "attr" if isinstance(key, str) else "item"
|
|
48
|
+
new_sub_paths = [path + [(op, key)] for path in self._sub_paths]
|
|
49
|
+
return Traversal(self._tree, self._base_path, new_sub_paths)
|
|
50
|
+
|
|
51
|
+
def _get_targets_from(self, tree: Any) -> tuple[Any, ...]:
|
|
52
|
+
"""Internal generator for eqx.tree_at.
|
|
53
|
+
|
|
54
|
+
Dynamically walks the paths to return all target nodes from a given root tree
|
|
55
|
+
(or Equinox tracer).
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
tree (Any): The root tree or Equinox tracer to walk.
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
tuple[Any, ...]: A tuple of all resolved target nodes.
|
|
62
|
+
"""
|
|
63
|
+
targets = []
|
|
64
|
+
for path in self._sub_paths:
|
|
65
|
+
curr = tree
|
|
66
|
+
for op, val in self._base_path + path:
|
|
67
|
+
if op == "attr":
|
|
68
|
+
curr = getattr(curr, cast(str, val))
|
|
69
|
+
elif op == "item":
|
|
70
|
+
curr = curr[val]
|
|
71
|
+
targets.append(curr)
|
|
72
|
+
return tuple(targets)
|
|
73
|
+
|
|
74
|
+
def apply(self, func: Callable[[Any], Any]) -> TRoot:
|
|
75
|
+
"""Applies a function to all selected targets simultaneously.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
func (Callable[[Any], Any]): The transformation function to apply to each target.
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
TRoot: A new instance of the root tree with all targets updated.
|
|
82
|
+
"""
|
|
83
|
+
if not self._sub_paths:
|
|
84
|
+
return self._tree
|
|
85
|
+
|
|
86
|
+
return eqx.tree_at(self._get_targets_from, self._tree, replace_fn=func)
|
|
87
|
+
|
|
88
|
+
def set(self, value: Any) -> TRoot:
|
|
89
|
+
"""Sets all selected targets to a specific value.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
value (Any): The new value to assign to all targets.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
TRoot: A new instance of the root tree with the updated values.
|
|
96
|
+
"""
|
|
97
|
+
if not self._sub_paths:
|
|
98
|
+
return self._tree
|
|
99
|
+
|
|
100
|
+
# eqx.tree_at requires the replacements tuple to match the length of the targets tuple
|
|
101
|
+
replacements = tuple(value for _ in self._sub_paths)
|
|
102
|
+
return eqx.tree_at(self._get_targets_from, self._tree, replace=replacements)
|
|
103
|
+
|
|
104
|
+
def get(self) -> list[Any]:
|
|
105
|
+
"""Extracts all focused values.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
list[Any]: A list containing the values of all currently focused targets.
|
|
109
|
+
"""
|
|
110
|
+
return list(self._get_targets_from(self._tree))
|
|
111
|
+
|
|
112
|
+
def filter(self, predicate: Callable[[Any], bool]) -> "Traversal[TRoot]":
|
|
113
|
+
"""Filters the currently focused targets, keeping only those that match the condition.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
predicate (Callable[[Any], bool]): A function that returns True to keep a target,
|
|
117
|
+
or False to drop it.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
Traversal[TRoot]: A new Traversal focused only on the targets that passed the filter.
|
|
121
|
+
"""
|
|
122
|
+
from refrax.lens import Lens
|
|
123
|
+
|
|
124
|
+
filtered_paths = []
|
|
125
|
+
for path in self._sub_paths:
|
|
126
|
+
target_val = Lens(self._tree, self._base_path + path).get()
|
|
127
|
+
if predicate(target_val):
|
|
128
|
+
filtered_paths.append(path)
|
|
129
|
+
|
|
130
|
+
return Traversal(self._tree, self._base_path, filtered_paths)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: refrax
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Chainable optics for JAX PyTrees
|
|
5
|
+
Author-email: Gary Allen <gvcallen@gmail.com>
|
|
6
|
+
Project-URL: homepage, https://github.com/gvcallen/refrax
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: equinox
|
|
10
|
+
Provides-Extra: docs
|
|
11
|
+
Requires-Dist: mkdocs; extra == "docs"
|
|
12
|
+
Requires-Dist: mkdocs-material; extra == "docs"
|
|
13
|
+
Requires-Dist: mkdocs-macros-plugin; extra == "docs"
|
|
14
|
+
Requires-Dist: mkdocs-include-markdown-plugin; extra == "docs"
|
|
15
|
+
Requires-Dist: mkdocstrings[python]; extra == "docs"
|
|
16
|
+
Provides-Extra: test
|
|
17
|
+
Requires-Dist: pytest; extra == "test"
|
|
18
|
+
Requires-Dist: pytest-codeblocks; extra == "test"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# Refrax
|
|
22
|
+
|
|
23
|
+
**Refrax** is a tiny library implementing the *optics* functional pattern for [JAX](https://github.com/jax-ml/jax) PyTrees.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
Refrax can be installed using pip:
|
|
28
|
+
|
|
29
|
+
``
|
|
30
|
+
pip install refrax
|
|
31
|
+
``
|
|
32
|
+
|
|
33
|
+
## Quick example
|
|
34
|
+
|
|
35
|
+
This example demonstrates the Mixin approach on an [Equinox](https://github.com/patrick-kidger/equinox) module, which adds `.at` to your class and simply returns `refrax.Lens(self)`.
|
|
36
|
+
|
|
37
|
+
We define a dummy model with the mixin:
|
|
38
|
+
```python
|
|
39
|
+
from refrax import OpticsMixin
|
|
40
|
+
|
|
41
|
+
import equinox as eqx
|
|
42
|
+
import jax
|
|
43
|
+
|
|
44
|
+
class Model(eqx.Module, OpticsMixin):
|
|
45
|
+
core: eqx.nn.Linear
|
|
46
|
+
head: eqx.nn.Linear
|
|
47
|
+
dropout: float
|
|
48
|
+
|
|
49
|
+
key1, key2 = jax.random.split(jax.random.key(0))
|
|
50
|
+
model = Model(
|
|
51
|
+
core=eqx.nn.Linear(in_features=5, out_features=5, key=key1),
|
|
52
|
+
head=eqx.nn.Linear(in_features=5, out_features=2, key=key2),
|
|
53
|
+
dropout=0.5
|
|
54
|
+
)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Then we can do updates using `.at`:
|
|
58
|
+
```python
|
|
59
|
+
new_model = model.at.dropout.set(0.1)
|
|
60
|
+
new_model = model.at.select("core", "head").bias.apply(lambda b: b + 1.0)
|
|
61
|
+
|
|
62
|
+
new_model.core.bias
|
|
63
|
+
# [1. 1. 1. 1. 1.]
|
|
64
|
+
|
|
65
|
+
new_model.head.bias
|
|
66
|
+
# [1. 1.]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Documentation
|
|
70
|
+
|
|
71
|
+
Documentation is available [here](https://gvcallen.github.io/refrax/).
|
|
72
|
+
|
|
73
|
+
## Related
|
|
74
|
+
|
|
75
|
+
The library uses [Equinox](https://github.com/patrick-kidger/equinox) (specifically `eqx.tree_at`) under the hood.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
refrax/__init__.py,sha256=kkcKR6a1AkJplb2lr1IrZLu1v58ioH3HljLG8TqkOJo,295
|
|
2
|
+
refrax/custom_types.py,sha256=w9TUKV1m-bM2hnR1gaU5DD1ZZTWK7sc4nKddTLa11Qs,129
|
|
3
|
+
refrax/lens.py,sha256=yyo7KhzqbLY5HxfsV7YdSb6RL-58uWb9G0yhG0utL5I,6319
|
|
4
|
+
refrax/mixin.py,sha256=3_LSCZBbhpqVCxKhU5hwa7Z5cz8JcWknGqGhdsjxNMw,240
|
|
5
|
+
refrax/traversal.py,sha256=-fvUeVMYwIrdToq8bYtBpOr9NJ07qr2fEOSdZz01h10,4929
|
|
6
|
+
refrax-0.0.2.dist-info/licenses/LICENSE,sha256=VcF2hrF5o8OMDSCLUt0ti6_R2WOe7XgQOjwgTllOq6c,11415
|
|
7
|
+
refrax-0.0.2.dist-info/METADATA,sha256=tc_srZQYamzesRRdor_-splACdb8rwsY2SeGG8lKdNc,1997
|
|
8
|
+
refrax-0.0.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
9
|
+
refrax-0.0.2.dist-info/top_level.txt,sha256=iOeuLHuy1zcRfX6hqksEI9qxQrMPMQ5emr79tylxuhE,7
|
|
10
|
+
refrax-0.0.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
[http://www.apache.org/licenses/](http://www.apache.org/licenses/)
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright Gary Allen
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
refrax
|