-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from bjorn-martinsson/simplify_init
Simplify imports
- Loading branch information
Showing
33 changed files
with
82 additions
and
398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,6 @@ | ||
from .algebra import * | ||
from .combinatorics import * | ||
from .data_structures import * | ||
from .geometry import * | ||
from .graphs import * | ||
from .linear_algebra import * | ||
from .numerical import * | ||
from .strings import * | ||
from .version import version | ||
from .version import version as __version__ | ||
|
||
__version__ = version | ||
|
||
__all__ = (algebra.__all__ + combinatorics.__all__ + data_structures.__all__ + geometry.__all__ + graphs.__all__ + | ||
linear_algebra.__all__ + numerical.__all__ + strings.__all__) | ||
import os as _os | ||
for _s in ('algebra', 'combinatorics', 'data_structures', 'geometry', | ||
'graphs', 'linear_algebra', 'numerical', 'strings', 'misc', 'tools'): | ||
__path__.append(_os.path.join(_os.path.dirname(__file__), _s)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +0,0 @@ | ||
from . import ntt | ||
from .chinese_remainder import chinese_remainder, composite_crt | ||
from .discrete_log import discrete_log | ||
from .factors import all_factors, distinct_factors, pollard_rho, prime_factors | ||
from .fft import fft, fft_conv | ||
from .fst import fst, fst_conv | ||
from .gcd import extended_gcd, gcd, gcdm, lcm, lcmm | ||
from .is_prime import is_prime | ||
from .mod_sqrt import mod_sqrt | ||
from .modinv import modinv | ||
from .phi import phi | ||
from .primitive_root import ilog, primitive_root | ||
from .sieve import prime_list, prime_sieve | ||
|
||
__all__ = [ | ||
"ntt", | ||
"chinese_remainder", | ||
"composite_crt", | ||
"discrete_log", | ||
"all_factors", | ||
"distinct_factors", | ||
"pollard_rho", | ||
"prime_factors", | ||
"fft", | ||
"fft_conv", | ||
"fst", | ||
"fst_conv", | ||
"extended_gcd", | ||
"gcd", | ||
"gcdm", | ||
"lcm", | ||
"lcmm", | ||
"is_prime", | ||
"mod_sqrt", | ||
"modinv", | ||
"phi", | ||
"ilog", | ||
"primitive_root", | ||
"prime_list", | ||
"prime_sieve", | ||
] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +0,0 @@ | ||
from .combinatorics import (bell, catalan, catalan_recursive, derangements, euler, euler_recursive, multinomial, nCr, | ||
stirling_1_recursive, stirling_2, stirling_2_recursive) | ||
from .nCr_mod import make_nCr_mod | ||
from .partitions import partition | ||
|
||
__all__ = [ | ||
"bell", | ||
"catalan", | ||
"catalan_recursive", | ||
"derangements", | ||
"euler", | ||
"euler_recursive", | ||
"multinomial", | ||
"nCr", | ||
"stirling_1_recursive", | ||
"stirling_2", | ||
"stirling_2_recursive", | ||
"make_nCr_mod", | ||
"partition", | ||
] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +0,0 @@ | ||
from .BitArray import BitArray | ||
from .CFraction import CFrac2Frac, CFraction | ||
from .convex_hull_trick import convex_hull_trick, max_query | ||
from .DisjointSetUnion import DisjointSetUnion, UnionFind | ||
from .FenwickTree import FenwickTree | ||
from .Fraction import Fraction, limit_denominator | ||
from .Heap import Heap, OrderHeap, RemovalHeap, XHeap | ||
from .LazySegmentTree import LazySegmentTree | ||
from .LinkedList import LinkedList | ||
from .Node import Node | ||
from .PersistentSegTree import create, minimum, setter | ||
from .RangeQuery import RangeQuery | ||
from .SegmentTree import SegmentTree | ||
from .SortedList import SortedList | ||
from .Treap import (TreapHashMap, TreapHashSet, TreapMultiSet, TreapSet, treap_builder, treap_ceiling, | ||
treap_create_node, treap_erase, treap_floor, treap_higher, treap_insert, treap_insert_unique, | ||
treap_keys, treap_lower, treap_max, treap_merge, treap_min, treap_prior, treap_split) | ||
from .tree_repr import tree_repr | ||
from .Trie import Trie | ||
from .TwoSat import TwoSat | ||
|
||
__all__ = [ | ||
"BitArray", | ||
"CFrac2Frac", | ||
"CFraction", | ||
"convex_hull_trick", | ||
"DisjointSetUnion", | ||
"UnionFind", | ||
"FenwickTree", | ||
"Fraction", | ||
"limit_denominator", | ||
"Heap", | ||
"OrderHeap", | ||
"RemovalHeap", | ||
"XHeap", | ||
"LazySegmentTree", | ||
"LinkedList", | ||
"Node", | ||
"create", | ||
"max_query", | ||
"minimum", | ||
"setter", | ||
"RangeQuery", | ||
"SegmentTree", | ||
"SortedList", | ||
"TreapHashMap", | ||
"TreapHashSet", | ||
"TreapMultiSet", | ||
"TreapSet", | ||
"treap_builder", | ||
"treap_ceiling", | ||
"treap_create_node", | ||
"treap_erase", | ||
"treap_floor", | ||
"treap_higher", | ||
"treap_insert", | ||
"treap_insert_unique", | ||
"treap_keys", | ||
"treap_lower", | ||
"treap_max", | ||
"treap_merge", | ||
"treap_min", | ||
"treap_prior", | ||
"treap_split", | ||
"tree_repr", | ||
"Trie", | ||
"TwoSat", | ||
] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +0,0 @@ | ||
from .convex_hull import convex_hull | ||
from .lines import collinear, dist, get_2dline, intersect, is_parallel, is_same, rotate | ||
from .vectors import angle, closest_point, cross2d, cross3d, dot, norm_sq, scale, to_vec, translate | ||
|
||
__all__ = [ | ||
"convex_hull", | ||
"collinear", | ||
"dist", | ||
"get_2dline", | ||
"intersect", | ||
"is_parallel", | ||
"is_same", | ||
"rotate", | ||
"angle", | ||
"closest_point", | ||
"cross2d", | ||
"cross3d", | ||
"dot", | ||
"norm_sq", | ||
"scale", | ||
"to_vec", | ||
"translate", | ||
] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +0,0 @@ | ||
from .bellman_ford import bellman_ford | ||
from .bfs import bfs, layers | ||
from .components import connected_components | ||
from .cycle_finding import cycle_finding | ||
from .dfs import dfs | ||
from .dijkstra import dijkstra | ||
from .dinic import Dinic | ||
from .euler_walk import euler_walk | ||
from .find_path import find_path | ||
from .floyd_warshall import floyd_warshall | ||
from .is_bipartite import is_bipartite | ||
from .kruskal import kruskal | ||
from .lca import LCA | ||
from .maximum_matching import maximum_matching | ||
from .prim import prim | ||
from .scc import scc | ||
from .toposort import kahn, toposort | ||
|
||
__all__ = [ | ||
"bellman_ford", | ||
"bfs", | ||
"layers", | ||
"connected_components", | ||
"cycle_finding", | ||
"dfs", | ||
"dijkstra", | ||
"Dinic", | ||
"euler_walk", | ||
"find_path", | ||
"floyd_warshall", | ||
"is_bipartite", | ||
"maximum_matching", | ||
"kruskal", | ||
"LCA", | ||
"prim", | ||
"scc", | ||
"kahn", | ||
"toposort", | ||
] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +0,0 @@ | ||
from .matrix import eye, mat_add, mat_inv, mat_mul, mat_pow, mat_sub, minor, transpose, vec_mul | ||
from .multivariable_crt import is_sol, mcrt, pivot | ||
|
||
__all__ = [ | ||
"eye", | ||
"mat_add", | ||
"mat_inv", | ||
"mat_mul", | ||
"mat_pow", | ||
"mat_sub", | ||
"minor", | ||
"transpose", | ||
"vec_mul", | ||
"is_sol", | ||
"mcrt", | ||
"pivot", | ||
] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +0,0 @@ | ||
from .alphabeta import AlphaBetaNode, alphabeta | ||
from .as_integer_ratio import as_integer_ratio | ||
from .bit_hacks import least_bit, next_mask, subset_masks, sum_of_subsets | ||
from .bootstrap import bootstrap | ||
from .cumsum2d import cumsum2d | ||
from .FastIO import FastIO, IOWrapper, input | ||
from .lis import lis | ||
from .memoize import memodict, memoize | ||
from .ordersort import ordersort, long_ordersort, multikey_ordersort | ||
from .order_statistic import order_statistic | ||
from .ostream import cout, endl, ostream | ||
from .readnumbers import readnumbers | ||
from .split import split | ||
|
||
__all__ = [ | ||
"AlphaBetaNode", | ||
"alphabeta", | ||
"as_integer_ratio", | ||
"least_bit", | ||
"next_mask", | ||
"subset_masks", | ||
"sum_of_subsets", | ||
"bootstrap", | ||
"cumsum2d", | ||
"FastIO", | ||
"IOWrapper", | ||
"input", | ||
"lis", | ||
"memodict", | ||
"memoize", | ||
"order_statistic", | ||
"ordersort", | ||
"cout", | ||
"endl", | ||
"ostream", | ||
"readnumbers", | ||
"split", | ||
"long_ordersort", | ||
"multikey_ordersort", | ||
] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +0,0 @@ | ||
from . import berlekamp_massey | ||
from .hill_climbing import hill_climbing | ||
from .integrate import fast_quad, quad, rec, simpson | ||
from .interpolate import interpolate | ||
from .iroot import iroot | ||
from .polynomial import diff, divroot, poly | ||
from .search import (binary_search, discrete_binary_search, discrete_ternary_search, fractional_binary_search, | ||
golden_section_search, ternary_search) | ||
|
||
__all__ = [ | ||
"berlekamp_massey", | ||
"hill_climbing", | ||
"fast_quad", | ||
"quad", | ||
"rec", | ||
"simpson", | ||
"interpolate", | ||
"iroot", | ||
"diff", | ||
"divroot", | ||
"poly", | ||
"binary_search", | ||
"discrete_binary_search", | ||
"discrete_ternary_search", | ||
"fractional_binary_search", | ||
"golden_section_search", | ||
"ternary_search", | ||
] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +0,0 @@ | ||
from .hashing import Hashing | ||
from .kmp import match, partial, string_find | ||
from .lcs import lcs | ||
from .LCSubstr import LCSubstr | ||
from .LPSubstr import LPSubstr | ||
from .min_rotation import least_rotation | ||
|
||
__all__ = ["Hashing", "match", "partial", "string_find", "lcs", "LCSubstr", "LPSubstr", "least_rotation"] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
from .stress_tester import cmd2func, func2judge, stress_tester | ||
|
||
__all__ = ["cmd2func", "func2judge", "stress_tester"] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
import random | ||
|
||
import pyrival.algebra | ||
|
||
from pyrival.chinese_remainder import * | ||
|
||
def test_chinese_remainder(primes): | ||
for _ in range(1000): | ||
l = random.randint(2, 100) | ||
p = random.sample(primes, l) | ||
a = [random.randint(0, p[i] - 1) for i in range(l)] | ||
x = pyrival.algebra.chinese_remainder(a, p) | ||
x = chinese_remainder(a, p) | ||
assert [x % i for i in p] == a | ||
|
||
|
||
def test_composite_crt(): | ||
for _ in range(1000): | ||
l = random.randint(2, 100) | ||
s = random.randint(0, 10000) | ||
m = [random.randint(2, 10000) for _ in range(l)] | ||
a = [s % m[i] for i in range(l)] | ||
x = pyrival.algebra.composite_crt(a, m) | ||
x = composite_crt(a, m) | ||
assert [x % i for i in m] == a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.