<commit_before># npyio [![GoDoc](https://godoc.org/github.com/sbinet/npyio?status.svg)](https://godoc.org/github.com/sbinet/npyio)

`npyio` provides read/write access to [numpy data files](http://docs.scipy.org/doc/numpy/neps/npy-format.html).

## Installation

Is done via `go get`:

```sh
$> go get github.com/sbinet/npyio
```

## Documentation

Is available on [godoc](https://godoc.org/github.com/sbinet/npyio)

## Example

### Reading a .npz file

Consider a `.npz` file created with the following `python` code:

```python
>>> import numpy as np
>>> arr = np.arange(6).reshape(2,3)
>>> f = open("data.npz", "w")
>>> np.save(f, arr)
>>> f.close()
```

The (int64) data array can be loaded into a (float64) `mat64.Matrix` by the following code:

```go
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/sbinet/npyio"
)

func main() {
	f, err := os.Open("data.npz")
	if err != nil {
		log.Fatal(err)
	}

	r, err := npyio.NewReader(f)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("npz-header: %#v\n", r.Header)

	m, err := r.Read()
	if err != nil {
		log.Fatal(err)
	}

	nrows, ncols := m.Dims()
	for i := 0; i < nrows; i++ {
		for j := 0; j < ncols; j++ {
			fmt.Printf("data[%d][%d]= %v\n", i, j, m.At(i, j))
		}
	}
}```<commit_msg>doc: cosmetics<commit_after># npyio [![GoDoc](https://godoc.org/github.com/sbinet/npyio?status.svg)](https://godoc.org/github.com/sbinet/npyio)

`npyio` provides read/write access to [numpy data files](http://docs.scipy.org/doc/numpy/neps/npy-format.html).

## Installation

Is done via `go get`:

```sh
$> go get github.com/sbinet/npyio
```

## Documentation

Is available on [godoc](https://godoc.org/github.com/sbinet/npyio)

## Example

### Reading a .npz file

Consider a `.npz` file created with the following `python` code:

```python
>>> import numpy as np
>>> arr = np.arange(6).reshape(2,3)
>>> f = open("data.npz", "w")
>>> np.save(f, arr)
>>> f.close()
```

The (int64) data array can be loaded into a (float64) `mat64.Matrix` by the following code:

```go
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/sbinet/npyio"
)

func main() {
	f, err := os.Open("data.npz")
	if err != nil {
		log.Fatal(err)
	}

	r, err := npyio.NewReader(f)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("npz-header: %#v\n", r.Header)

	m, err := r.Read()
	if err != nil {
		log.Fatal(err)
	}

	nrows, ncols := m.Dims()
	for i := 0; i < nrows; i++ {
		for j := 0; j < ncols; j++ {
			fmt.Printf("data[%d][%d]= %v\n", i, j, m.At(i, j))
		}
	}
}
```
{'fraction_non_alphanumeric': 0.2143429487179487, 'fraction_numerical': 0.008814102564102564, 'mean_word_length': 3.531760435571688, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2665038', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1088, 'n_words': 249}