1
1
mirror of https://github.com/OpenVoiceOS/OpenVoiceOS synced 2025-06-05 22:19:21 +02:00

Add pre-installed python packages within rootfs overlay

TODO: This is just a quick fix and need to be changed to
buildroot packages in the upcoming days/weeks/months.
This commit is contained in:
j1nx
2022-12-08 21:02:30 +01:00
parent ce2443f753
commit 37d97e1551
36609 changed files with 7287696 additions and 0 deletions

View File

@ -0,0 +1,49 @@
#ifndef PYTHONIC_RANDOM_CHOICE_HPP
#define PYTHONIC_RANDOM_CHOICE_HPP
#include "pythonic/include/random/choice.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/random/random.hpp"
#include "pythonic/types/traits.hpp"
PYTHONIC_NS_BEGIN
namespace random
{
namespace details
{
template <class Seq>
typename std::enable_if<types::has_size<Seq>::value,
typename Seq::value_type>::type
choice(Seq const &seq)
{
auto tmp = seq.begin();
// std::advance not usable because it requires operator--
for (long n = random() * seq.size(); n; --n)
++tmp;
return *tmp;
}
template <class Seq>
typename std::enable_if<!types::has_size<Seq>::value,
typename Seq::value_type>::type
choice(Seq const &seq)
{
std::vector<typename std::decay<typename Seq::value_type>::type> tmp(
seq.begin(), seq.end());
return tmp[long(random() * tmp.size())];
}
}
template <class Seq>
typename Seq::value_type choice(Seq const &seq)
{
return details::choice(seq);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,20 @@
#ifndef PYTHONIC_RANDOM_EXPOVARIATE_HPP
#define PYTHONIC_RANDOM_EXPOVARIATE_HPP
#include "pythonic/include/random/expovariate.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/random/random.hpp"
PYTHONIC_NS_BEGIN
namespace random
{
double expovariate(double l)
{
return std::exponential_distribution<>(l)(__random_generator);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,21 @@
#ifndef PYTHONIC_RANDOM_GAUSS_HPP
#define PYTHONIC_RANDOM_GAUSS_HPP
#include "pythonic/include/random/gauss.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/random/random.hpp"
PYTHONIC_NS_BEGIN
namespace random
{
double gauss(double mu, double sigma)
{
return std::normal_distribution<>(mu, sigma)(__random_generator);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,22 @@
#ifndef PYTHONIC_RANDOM_RANDINT_HPP
#define PYTHONIC_RANDOM_RANDINT_HPP
#include "pythonic/include/random/randint.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/random/randrange.hpp"
PYTHONIC_NS_BEGIN
namespace random
{
long randint(long a, long b)
{
// TODO: It should be implemented with an uniform_int_distribution
return randrange(a, b + 1);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,22 @@
#ifndef PYTHONIC_RANDOM_RANDOM_HPP
#define PYTHONIC_RANDOM_RANDOM_HPP
#include "pythonic/include/random/random.hpp"
#include "pythonic/utils/functor.hpp"
#include <random>
PYTHONIC_NS_BEGIN
namespace random
{
double random()
{
static std::uniform_real_distribution<> uniform_distrib(0.0, 1.0);
return uniform_distrib(__random_generator);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,32 @@
#ifndef PYTHONIC_RANDOM_RANDRANGE_HPP
#define PYTHONIC_RANDOM_RANDRANGE_HPP
#include "pythonic/include/random/randrange.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/random/random.hpp"
#include <cmath>
PYTHONIC_NS_BEGIN
namespace random
{
long randrange(long stop)
{
return long(random() * stop);
}
long randrange(long start, long stop)
{
return start + long(random() * (stop - start));
}
long randrange(long start, long stop, long step)
{
return start + step * long((random() * (stop - start)) / std::abs(step));
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,36 @@
#ifndef PYTHONIC_RANDOM_SAMPLE_HPP
#define PYTHONIC_RANDOM_SAMPLE_HPP
#include "pythonic/include/random/sample.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/random/random.hpp"
#include "pythonic/types/list.hpp"
PYTHONIC_NS_BEGIN
namespace random
{
template <class Iterable>
types::list<typename std::iterator_traits<
typename std::remove_cv<typename std::remove_reference<Iterable>::type>::
type::iterator>::value_type>
sample(Iterable &&s, size_t k)
{
using value_type = typename std::iterator_traits<typename std::remove_cv<
typename std::remove_reference<Iterable>::type>::type::iterator>::
value_type;
types::list<value_type> tmp(s.begin(), s.end());
std::vector<size_t> indices(tmp.size());
std::iota(indices.begin(), indices.end(), 0);
std::random_shuffle(indices.begin(), indices.end());
types::list<value_type> out(k);
for (size_t i = 0; i < k; i++)
out[i] = tmp[indices[i]];
return out;
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,30 @@
#ifndef PYTHONIC_RANDOM_SEED_HPP
#define PYTHONIC_RANDOM_SEED_HPP
#include "pythonic/include/random/seed.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/builtins/None.hpp"
#include "pythonic/random/random.hpp"
#include <ctime>
PYTHONIC_NS_BEGIN
namespace random
{
types::none_type seed(long s)
{
__random_generator.seed(s);
return builtins::None;
}
types::none_type seed()
{
__random_generator.seed(time(nullptr));
return builtins::None;
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,63 @@
#ifndef PYTHONIC_RANDOM_SHUFFLE_HPP
#define PYTHONIC_RANDOM_SHUFFLE_HPP
#include "pythonic/include/random/shuffle.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/builtins/None.hpp"
#include "pythonic/random/random.hpp"
#include <limits>
PYTHONIC_NS_BEGIN
namespace random
{
template <class T>
types::none_type shuffle(T &seq)
{
std::shuffle(seq.begin(), seq.end(), __random_generator);
return builtins::None;
}
namespace details
{
template <class function>
struct URG {
URG(function &&f) : randf(f)
{
}
typedef unsigned result_type;
static constexpr result_type min()
{
return 0;
}
/* -1 because of the floor() operation performed by the float->unsigned
* conversion */
static constexpr result_type max()
{
return std::numeric_limits<result_type>::max() - 1;
}
result_type operator()()
{
return randf() * std::numeric_limits<result_type>::max();
}
function randf;
};
}
template <class T, class function>
types::none_type shuffle(T &seq, function &&randf)
{
std::shuffle(seq.begin(), seq.end(),
details::URG<function>(std::forward<function>(randf)));
return builtins::None;
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,20 @@
#ifndef PYTHONIC_RANDOM_UNIFORM_HPP
#define PYTHONIC_RANDOM_UNIFORM_HPP
#include "pythonic/include/random/uniform.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/random/random.hpp"
PYTHONIC_NS_BEGIN
namespace random
{
double uniform(double a, double b)
{
return a + (b - a) * random();
}
}
PYTHONIC_NS_END
#endif