semvec/pypi-packages huggingface dataset:
onshape-variables 0.1.0
A python class to easily interact with Onshape's Variables API
License: MIT
Requires Python: >=3.9,<4.0

# Onshape's Variables API Helper

A python class to easily interact with Onshape's Variables API 

## Prerequisites

#### Create API Keys
- Head over to the onshape [developer portal](https://dev-portal.onshape.com/keys) 

- Click on "Create new API key"

![new_keys](./assets/new_key.png)

- Check the blue boxes and click on "Create API key"

![create_keys](./assets/create_key.png)

- copy and save both keys in a file (I recommend you save it in a [.env file](./examples/.env.example). What is a .env? See this [article](https://www.atatus.com/blog/python-environment-variables/#what-are-environment-variables)!)

![save_keys](./assets/save_keys.png)

## Installation

You can install onshape-variables via pip:

```bash
pip install onshape-variables
```

## Usage

```python
from onshape_variables.variables import Variables

# create variables object
my_vs = Variables(api_keys, did, wid)

# create a varaible studio 
my_vs.create_varaible_studio(name="My Varaible Studio")
```

[Check out the example notebook](./examples/example.ipynb)

Also see [Onshape's documentation](https://onshape-public.github.io/docs/) and [API explorer](https://cad.onshape.com/glassworks/explorer/#/)


## Contributing

Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change :)


<!-- ## License

[MIT](https://choosealicense.com/licenses/mit/) -->
tabulate-2 0.1.0
A lightweight library for tabulating dictionaries
License: MIT
Requires Python: >=3.9,<4.0

# unpact

A lightweight library for tabulating dictionaries.

## Usage

A basic example:

```python
from unpact import unwind, ColumnDef

columns: List[ColumnDef] = [
    'calendar.year',
    'calendar.date',
    'locations.location',
    'locations.x',
    'locations.y'
]

 # columns of the same child and the same length are considered 'adjacent'
 # adjacent columns are zipped together.
 # here, 'x' and 'y' are considered 'adjacent'
data = {
    'calendar': {'year': 2022, 'date': 'Aug 14'},
    'locations': [
        {'location': 'Loc1', 'x': [1,2,3,4], 'y': [1,2,3,4]},
        {'location': 'Loc2', 'x': [11,22,33,44], 'y': [11,22,33,44]},
        {'location': 'Loc2', 'x': [11], 'y': [11]},
    ],
    'ignored': "This isn't in the ColumDefs so won't be included"
}

table = unwind(data, columns)
print(pl.from_dicts(table))
```

A more complex example using ColumnSpecs:

```python
import polars as pl
from unpact import unwind, ColumnDef

# You can pass in a pass in a 'ColumnSpec' to change the behavior of a column
# current values are 'formatter' which accepts a callable and 'name', a string which will rename the column
columns: List[ColumnDef] = [
    'calendar.year',
    'calendar.date',
    ('locations.location', {'name': 'loc'}),
    ('locations.coords', {'formatter': lambda coords: {'x': coords[0], 'y': coords[1]}})
]

data = {
    'calendar': {'year': 2022, 'date': 'Aug 14'},
    'locations': [
        {'location': 'Loc1', 'coords': [[1,1], [2,2], [3,3]]},
        {'location': 'Loc2', 'coords': [[1,1], [2,2], [3,3]]},
        {'location': 'Loc2', 'coords': [[1,1], [2,2], [3,3]]},
    ],
    'ignored': "This isn't in the ColumDefs so won't be included"
}

table = unwind(data, columns)
print(pl.from_dicts(table))

```

A demonstration showing 'adjacency' at multiple levels of nesting:

```python

columns: List[ColumnDef] = [
    'calendar.year',
    'calendar.date',
    ('locations_1.location', {'name': 'loc'}),
    ('locations_1.coords', {'formatter': lambda coords: {'x': coords[0], 'y': coords[1]}}),
    ('locations_2.location', {'name': 'loc'}),
    ('locations_2.coords', {'formatter': lambda coords: {'x': coords[0], 'y': coords[1]}})
]

data = {
    'calendar': {'year': 2022, 'date': 'Aug 14'},
    'locations_1': [
        {'location': 'Loc1', 'coords': [[1,1], [2,2], [3,3]]},
        {'location': 'Loc2', 'coords': [[1,1], [2,2], [3,3]]},
    ],
    'locations_2': [
        {'location': 'Loc1', 'coords': [[1,1], [2,2], [3,3]]},
        {'location': 'Loc2', 'coords': [[1,1], [2,2], [3,3]]},
    ],
    'ignored': "This isn't in the ColumDefs so won't be included"
}

table = unwind(data, columns)
assert len(table) == 12 # 3 rows per record, 4 records
print(pl.from_dicts(table))

```