Skip to content

Commit

Permalink
Introduce expanded default range for integer as validation steps in d…
Browse files Browse the repository at this point in the history
…atapoint editor now reduce the range of values previously supported by default

PiperOrigin-RevId: 575351072
  • Loading branch information
cpka145 authored and LIT team committed Oct 21, 2023
1 parent e63b674 commit d274508
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lit_nlp/api/testdata/count_examples.indexed.lit.jsonl.spec
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"value": {
"required": true,
"annotated": false,
"min_val": 0,
"max_val": 1,
"min_val": -32768,
"max_val": 32767,
"default": 0,
"step": 1,
"__class__": "LitType",
Expand Down
4 changes: 2 additions & 2 deletions lit_nlp/api/testdata/count_examples.lit.jsonl.spec
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"value": {
"required": true,
"annotated": false,
"min_val": 0,
"max_val": 1,
"min_val": -32768,
"max_val": 32767,
"default": 0,
"step": 1,
"__class__": "LitType",
Expand Down
2 changes: 2 additions & 0 deletions lit_nlp/api/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,8 @@ class MetricResult(LitType):
@attr.s(auto_attribs=True, frozen=True, kw_only=True)
class Integer(Scalar):
step: int = 1
min_val: int = -32768
max_val: int = 32767


@attr.s(auto_attribs=True, frozen=True, kw_only=True)
Expand Down
2 changes: 2 additions & 0 deletions lit_nlp/client/lib/lit_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ export class Scalar extends LitType {
*/
@registered
export class Integer extends Scalar {
override min_val = -32768;
override max_val = 32767;
override step = 1;
}

Expand Down
5 changes: 2 additions & 3 deletions website/sphinx_src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,7 @@ _See the [examples](https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples)

### Available types

The full set of `LitType`s is defined in
[types.py](https://github.com/PAIR-code/lit/blob/main/lit_nlp/api/types.py), and summarized
The full set of `LitType`s is defined in [types.py](https://github.com/PAIR-code/lit/blob/main/lit_nlp/api/types.py). Numeric types such as `Integer` and `Scalar` have predefined ranges that can be overridden using corresponding `min_val` and `max_val` attributes as seen [here](https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples/datasets/penguin_data.py;l=19-22;rcl=574999438). The different types available in LIT are summarized
in the table below.

Note: Bracket syntax, such as `<float>[num_tokens]`, refers to the shapes of
Expand All @@ -828,7 +827,7 @@ Name | Description
`TokenTopKPreds` | Predicted tokens and their scores, as from a language model or seq2seq model. | `list[list[tuple[str, float]]]`
`Boolean` | Boolean value. | `bool`
`Scalar` | Scalar numeric value. | `float`
`Integer` | Integer value. | `int`
`Integer` | Integer, with a default range from -32768 to +32767. value. | `int`
`ImageBytes` | Image, represented by a base64 encoded string. LIT also provides `JPEGBytes` and `PNGBytes` types for those specific encodings. | `str`
`RegressionScore` | Scalar value, treated as a regression target or prediction. | `float`
`ReferenceScores` | Scores for one or more reference texts. | `list[float]`
Expand Down

0 comments on commit d274508

Please sign in to comment.