<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import nix
import numpy as np
import matplotlib.pylab as plt


def create_data(duration, interval):
    times = np.around(np.cumsum(np.random.poisson(interval*1000, 1.5*duration/interval))/1000., 3)
    times = times[times <= duration]
    x = np.arange(0, times[-1] * 2 * np.pi, 0.001)
    y = np.sin(5 * x)
    return times, y[np.asarray(times / 0.001 *2 * np.pi, dtype=int)]


def plot_data(data_array):
    x_axis = data_array.dimensions[0]
    x = list(x_axis.ticks)
    y = data_array.data
    plt.plot(x, y, marker='o', color='dodgerblue')
    plt.xlabel(x_axis.label + " [" + x_axis.unit + "]")
    plt.ylabel(data_array.label + " [" + data_array.unit + "]")
    plt.title(data_array.name)
    plt.xlim([0, times[-1]])
    plt.ylim(np.min(y)*1.1, np.max(y)*1.1)
    plt.show()

<commit_msg>[tutorial] add copyright info to irregular data example<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
 Copyright © 2014 German Neuroinformatics Node (G-Node)

 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted under the terms of the BSD License. See
 LICENSE file in the root of the Project.

 Author: <NAME> <<EMAIL>>

 This tutorial shows how irregulary sampled data is stored in nix-files.
 See https://github.com/G-node/nix/wiki for more information.
"""
import nix
import numpy as np
import matplotlib.pylab as plt


def create_data(duration, interval):
    times = np.around(np.cumsum(np.random.poisson(interval*1000, 1.5*duration/interval))/1000., 3)
    times = times[times <= duration]
    x = np.arange(0, times[-1] * 2 * np.pi, 0.001)
    y = np.sin(5 * x)
    return times, y[np.asarray(times / 0.001 *2 * np.pi, dtype=int)]


def plot_data(data_array):
    x_axis = data_array.dimensions[0]
    x = list(x_axis.ticks)
    y = data_array.data
    plt.plot(x, y, marker='o', color='dodgerblue')
    plt.xlabel(x_axis.label + " [" + x_axis.unit + "]")
    plt.ylabel(data_array.label + " [" + data_array.unit + "]")
    plt.title(data_array.name)
    plt.xlim([0, times[-1]])
    plt.ylim(np.min(y)*1.1, np.max(y)*1.1)
    plt.show()


{'fraction_non_alphanumeric': 0.16195255474452555, 'fraction_numerical': 0.03102189781021898, 'mean_word_length': 3.3947895791583167, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 1, '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': '125698', 'n_tokens_mistral': 868, 'n_tokens_neox': 816, 'n_words': 190}