semvec/pypi-packages huggingface dataset:
addmeta-test9 0.post0.dev1
Add meta data to netCDF files.
Requires Python: >=3.9
Keywords: ACCESS-NRI, netcdf, metadata

[![Build Status](https://travis-ci.org/coecms/addmeta.svg?branch=master)](https://travis-ci.org/coecms/addmeta)
[![codecov.io](https://codecov.io/github/coecms/addmeta/coverage.svg?branch=master)](https://codecov.io/github/coecms/addmeta?branch=master)

# addmeta

Add meta data to netCDF files.

## Metadata

The metadata is stored in attribute files in [YAML](https://yaml.org) format. 
The metadata is in key-value pairs and is a global attribute if defined in a 
`global` section, or applied to a specific named variable in the `variables` 
section. 

If an attribute is listed with a missing value that attribute is deleted from the file.

For example the following is an example of an attribute file:
```yaml
global:
    # Mandatory since it gives a key to all the other attributes
    Conventions: "CF-1.7, ACDD-1.3"
    # The url of the license applied to the data
    license: "http://creativecommons.org/licenses/by-nc-sa/4.0/"
variables:
    yt_ocean:
        _FillValue:
        long_name: "latitude in rotated pole grid"
        units: "degrees"
    geolat_t:
        long_name: "latitude coordinate"
        units: "degrees_north"
        standard_name: "latitude"
```
It will create (or replace) two global attributes: `Conventions` and `license`.
It will also create (or replace) attributes for two variables, `yt_ocean` and
`geolat_t`, and delete the `_FillValue` attribute of `yt_ocean`.

The information is read into a `python` dict. Multiple attribute files can be
specified. If the same attribute is defined more than once, the last attribute
file specified takes precedence. Like cascading style sheets this means default
values can be given and overridden when necessary. 


## Invocation

`addmeta` is a command line program. Invoking with the `-h` flag prints
a summay of how to invoke the program correctly.

    $ addmeta -h
    usage: addmeta [-h] [-m METAFILES] [-l METALIST] [-v] files [files ...]

    Add meta data to one or more netCDF files

    positional arguments:
    files                 netCDF files

    optional arguments:
    -h, --help            show this help message and exit
    -m METAFILES, --metafiles METAFILES
                            One or more meta-data files in YAML format
    -l METALIST, --metalist METALIST
                            File containing a list of meta-data files
    -v, --verbose         Verbose output

Multiple attribute files can be specified by passing more than one file with
the `-m` option. For a large number of files this can be tedious. In that case
use the `-l` option and pass it a text file with the names of attribute files,
one per line.

Multiple meta list files and meta files can be specified on one command line.
freeassoc 0.1.0
Lightweight utilities for free-association processing: cleaning, embedding, projection, clustering, and label inference.
Requires Python: >=3.10


# freeassoc

Lightweight utilities for processing free-association responses.

Features
- Clean short text responses
- Average and manage embeddings
- Grouping / hierarchical clustering
- Projections (classical MDS, UMAP, PaCMAP)
- Label-frequency matrices and a small cross-validated OLS report

Quick start
1. Create and activate a virtual environment.

2. Install requirements:

```bash
pip install freeassoc
```

Development & tests
- The project uses a `src/` layout. When running tests from the repo root, make the package importable with PYTHONPATH:

```bash
PYTHONPATH=src python -m pytest -q
```

Examples
- See `examples/simple_df_example.py` for a quick runnable demonstration of embedding, caching, and label inference.
 
Status
- Work in progress. Use at your own risk;

Compatibility
- Tested with Python 3.10.

Attribution
- This repository is a Python adaptation of the R project `associatoR` (https://github.com/samuelae/associatoR) originally created by Dirk Wulff.

Author
- Ali Alhosseini
try-or 1.0.1
A Python micro-library that returns try value or default.
Requires Python: >=3.10
Keywords: default, except, or, try

# try-or

A Python micro-library that returns the first successful value (non-None) or a default.

## What it does

- Evaluate one or more supplier functions left-to-right.
- Return the first value that:
  - does not raise a listed exception (exc), and
  - is not None.
- If all suppliers either raise a listed exception or return None, return the default value.
- Exceptions not listed in exc are propagated.

## Examples

Fall back to default on `Exception`:

```python
from try_or import try_or

# Return the successful value when no exception is raised
try_or(lambda: int("123"), default=0)
# -> 123

# Fall back to the default when an exception occurs
try_or(lambda: int("not-an-int"), default=0)
# -> 0
```

Replace `None` with default:

```python
import os
from try_or import try_or

# Return the default when the result is None
try_or(lambda: os.environ.get("not-exist"), default="1")
# -> "1"
```

Narrow which exceptions are caught:

```python
from try_or import try_or

# Only fall back on ValueError
try_or(lambda: int("x"), default=0, exc=(ValueError,))
# -> 0

# TypeError will be propagated
try_or(lambda: (1 + "a"), default=0, exc=(ValueError,))
# -> raises TypeError

# Fall back on ValueError or TypeError
try_or(lambda: (1 + "a"), default=0, exc=(ValueError, TypeError))
# -> 0
```

Multiple suppliers (short-circuiting, lazy evaluation):

```python
import json
import os
from pathlib import Path
from try_or import try_or

config = try_or(
    # 1) Prefer env JSON
    lambda: json.loads(os.environ["APP_CONFIG_JSON"]),
    # 2) Then user config
    lambda: json.loads(Path("~/.myapp/config.json").expanduser().read_text(encoding="utf-8")),
    # 3) Then system config
    lambda: json.loads(Path("/etc/myapp/config.json").read_text(encoding="utf-8")),
    # Default if all above fail or return None
    default={"host": "localhost", "port": 8080},
)
# -> First successful non-None is returned. Later suppliers are not evaluated.
```

Empty suppliers:

```python
from try_or import try_or

try_or(default="fallback")
# -> "fallback"
```

## The code itself

```python
def try_or(
    *args: Callable[[], T | None],
    default: T,
    exc: type[BaseException] | tuple[type[BaseException], ...]=(Exception,)
) -> T:
    for f in args:
        try:
            value = f()
            if value is not None:
                return value
        except exc:
            pass
    return default
```

## License

[MIT License](./LICENSE)