semvec/pypi-packages huggingface dataset:
ratransformers 1.3.2
RATransformer - make a transformer model learn implicit relations passed in the input
License: MIT

<div align="center">

# RATransformers 🐭

![PyPI - Latest Package Version](https://img.shields.io/pypi/v/ratransformers?logo=pypi&style=flat&color=orange) ![GitHub - License](https://img.shields.io/github/license/JoaoLages/ratransformers?logo=github&style=flat&color=green)

**RATransformers**, short for Relation-Aware Transformers, is a package built on top of [transformers 🤗](https://github.com/huggingface/transformers)
that enables the training/fine-tuning of models with extra relation-aware input features.
</div>

### Example - Encoding a table in TableQA (Question Answering on Tabular Data)
![](assets/tableQA.gif)

[[Notebook Link](https://github.com/JoaoLages/RATransformers/blob/main/notebooks/TableQA_tabfact_example.ipynb)]

In this example we can see that passing the table as text with no additional information to the model is a poor representation.

With RATransformers 🐭 you are able to encode the table in a more structured way by passing specific relations within the input.
RATransformers 🐭 also allows you to pass further features related with each input word/token.

Check more examples in [[here](https://github.com/JoaoLages/RATransformers/blob/main/notebooks/)].

## Installation

Install directly from PyPI:

    pip install ratransformers

## Usage

```python
from ratransformers import RATransformer
from transformers import AutoModelForSequenceClassification


ratransformer = RATransformer(
    "nielsr/tapex-large-finetuned-tabfact", # define the 🤗 model you want to load
    relation_kinds=['is_value_of_column', 'is_from_same_row'], # define the relations that you want to model in the input
    model_cls=AutoModelForSequenceClassification, # define the model class
    pretrained_tokenizer_name_or_path='facebook/bart-large' # define the tokenizer you want to load (in case it is not the same as the model)
)
model = ratransformer.model
tokenizer = ratransformer.tokenizer
```

With only these steps your RATransformer 🐭 is ready to be trained. 

More implementation details in [the examples here](https://github.com/JoaoLages/RATransformers/blob/main/notebooks/).

## How does it work?
We modify the self-attention layers of the transformer model as explained in the section 3 of [the RAT-SQL paper](https://arxiv.org/pdf/1911.04942.pdf).

## Supported Models
Currently we support a limited number of transformer models:
- [BART](https://huggingface.co/docs/transformers/model_doc/bart)
- [BERT](https://huggingface.co/docs/transformers/model_doc/bert)
- [GPT-2](https://huggingface.co/docs/transformers/model_doc/gpt2)
- [RoBERTa](https://huggingface.co/docs/transformers/model_doc/roberta)
- [T5](https://huggingface.co/docs/transformers/model_doc/t5)
- [LongT5](https://huggingface.co/docs/transformers/model_doc/longt5)

Want another model? Feel free to open an [Issue](https://github.com/JoaoLages/RATransformers/issues) or create a [Pull Request](https://github.com/JoaoLages/RATransformers/pulls) and let's get started 🚀
streamjson 1.0.2
Send objects or arrays to a JSON file using a stream. Read objects from a JSON file using a stream.
License: MIT
Requires Python: >=3
Keywords: json,stream,write,file,read,objects,arrays

StreamJSON
=================
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/streamjson?color=blue)](https://pypi.python.org/pypi/streamjson)
[![PyPI](https://img.shields.io/pypi/v/streamjson?color=blue)](https://pypi.python.org/pypi/streamjson)
[![PyPI - Status](https://img.shields.io/pypi/status/streamjson)](https://pypi.python.org/pypi/streamjson)
[![PyPI - License](https://img.shields.io/pypi/l/streamjson)](https://pypi.python.org/pypi/streamjson)

Write objects or arrays to a JSON file using a stream. Useful for when you don't want to read large amounts of data in
memory, for example when you need to save large amounts of data from a database to a single JSON file.

Read objects from a JSON file using a stream. Does not require loading the whole JSON file in memory.

## Install

To install:

```console
pip install streamjson
```

To upgrade:

```console
pip install streamjson --upgrade
```

## How to write to JSON file

Fetch data from a database or anywhere else and send to a JSON file. The send function takes in a dictionary or a list.
A new file with the given name will be created, the root of the JSON file is an array by default.

```Python
from streamjson import StreamJSONWriter

persons = [{'id': '0001', 'first_name': 'John', 'last_name': 'Doe'},
           {'id': '0002', 'first_name': 'Jane', 'last_name': 'Doe'}]

with StreamJSONWriter('persons.json', indent=2) as writer:
    for person in persons:
        writer.send(person)
```

persons.json:

```JSON
[
  {
    "id": "0001",
    "first_name": "John",
    "last_name": "Doe"
  },
  {
    "id": "0002",
    "first_name": "Jane",
    "last_name": "Doe"
  }
]
```

## How to read from JSON file

The reader will stream each object from the JSON file.

```Python
from streamjson import StreamJSONReader

with StreamJSONReader('persons.json') as reader:
    for obj in reader.find():
        print(obj)
```
bspice 0.0.3
Working with SPICE kernels
License: MIT
Requires Python: >=3.6

**Author:** [Behrouz Safari](https://astrodatascience.net/)<br/>
**License:** [MIT](https://opensource.org/licenses/MIT)<br/>

# bspice
*Working with SPICE kernels*


## Installation

You can install the latest version of *bspice* from [PyPI](https://pypi.org/project/bspice/):

    pip install bspice

The requirements are *numpy*, *requests* and *spiceypy*.


## Download Kernels

```python
import bspice as bs

bs.download_kernels(overwrite=False, solsys=True, jupiter=True)
```

## Apparent position of Saturn

```python
import bspice as bs
from datetime import datetime

t = datetime.utcnow()
obs_loc = (7.744083817548831, 48.58313582900411, 140)

adr = 'C:/Moi/_py/Astronomy/Solar System/kernels/'

kernels = [adr+i for i in bs.main_kernels]
kernels = kernels + [adr+'de440_2030.bsp']

r, az, alt = bs.get_apparent(6, t, obs_loc, kernels)
print(az, alt)
```

## Apparent position of Jupiter Moons

```python
import bspice as bs
from datetime import datetime
import matplotlib.pyplot as plt

t = datetime.utcnow()
obs_loc = (7.744083817548831, 48.58313582900411, 140)

adr = 'C:/Moi/_py/Astronomy/Solar System/kernels/'

kernels = [adr+i for i in bs.main_kernels]
kernels = kernels + [adr+'jup4_2030.bsp']

bodies = [599, 501, 502, 503, 504]
r_az_alt = bs.get_apparent_bodies(bodies, t, obs_loc, kernels, abcorr='LT+S')
print(r_az_alt)

fig, ax = plt.subplots()
ax.scatter(r_az_alt[0,1], r_az_alt[0,2])
ax.scatter(r_az_alt[1:,1], r_az_alt[1:,2])
plt.show()
```

## Apparent position of the Sun during 24 hours

```python
import bspice as bs
from datetime import datetime

obs_loc = (7.744083817548831, 48.58313582900411, 140)

adr = 'C:/Moi/_py/Astronomy/Solar System/kernels/'

kernels = [adr+i for i in bs.main_kernels]
kernels = kernels + [adr+'de440_2030_earth_sun_moon.bsp']

t1 = datetime(2022, 9, 10)
t2 = datetime(2022, 9, 11)

r_az_alt = bs.get_apparent_window(10, t1, t2, 24, obs_loc, kernels, abcorr='LT+S')

for i in r_az_alt:
    print(f'Az:{i[1]} ||| Alt:{i[2]}')
```

## Local and absolute minimum angular positions of Sun and Moon

```python
import bspice as bs

t1 = '2022-01-01'
t2 = '2023-01-01'

adr = 'C:/Users/H21/Desktop/Desktop/Behrouz/Astronomy/kernels/'

kernels = [
    adr + 'naif0012.tls',
    adr + 'pck00010.tpc',
    adr + 'de440s.bsp',
    ]

print('Local:')
times = bs.conjunction(t1=t1, t2=t2, targ1='sun', targ2='moon', kernels=kernels)

for i in times:
    print(i)

print('Absolute:')
times = bs.conjunction(t1=t1, t2=t2, targ1='sun', targ2='moon', kernels=kernels, relate='ABSMIN')

for i in times:
    print(i)
```

```
Local:
2022-01-02 18:08:14
2022-02-01 05:32:21
2022-03-02 17:49:18
2022-04-01 06:53:57
2022-04-30 20:41:32
2022-05-30 11:11:34
2022-06-29 02:19:09
2022-07-28 17:40:45
2022-08-27 08:34:53
2022-09-25 22:24:24
2022-10-25 11:00:06
2022-11-23 22:40:53
2022-12-23 09:52:10
Absolute:
2022-10-25 11:00:06
```