Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
45dd279
Implement exponentiality tests environment and EP test
l-golofastov May 2, 2024
91933e8
Add KS test for exponentiality
l-golofastov May 4, 2024
1083ee9
Fix passing an argument
l-golofastov May 4, 2024
43007a4
Add more tests
l-golofastov May 4, 2024
4b1bd09
Make the cache shared in thread-safe mode
l-golofastov May 4, 2024
0eac2eb
Make cache work in new conditions
l-golofastov May 4, 2024
db64418
Add more exponentiality tests
l-golofastov May 4, 2024
8a16ef8
Renames and cosmetics
l-golofastov May 4, 2024
8996130
Add exponential tests powers calculation
l-golofastov May 25, 2024
3b845bc
Add time calculation service
l-golofastov May 25, 2024
c4f0327
Cosmetics
l-golofastov May 25, 2024
c3c131e
feat: update .gitignore
f1i3g3 Jul 29, 2024
3a5add4
feat: changed file structure
f1i3g3 Jul 29, 2024
ffa2305
feat: completely moved draft to this repository
f1i3g3 Jul 29, 2024
c61a5d3
feat: prepared repo for two-packages structure
f1i3g3 Jul 29, 2024
446d62c
fix: update instances
f1i3g3 Jul 29, 2024
0f6a51a
fix: time_cache updated
f1i3g3 Jul 31, 2024
fd81e4e
feat: criterion_checker removed due to project structure changes
f1i3g3 Jul 31, 2024
6dd410c
fix: update code() methods + fix warnings for normality tests
f1i3g3 Jul 31, 2024
4d5f8da
fix: improved GoF structure
f1i3g3 Jul 31, 2024
cc1aca8
fix: fix local cache.json name
f1i3g3 Jul 31, 2024
53f48d9
feat: some features:
f1i3g3 Jul 31, 2024
c1226e2
fix: added time_test.py
f1i3g3 Jul 31, 2024
eea622e
fix: removed prints
f1i3g3 Jul 31, 2024
13d17f2
fix: removed some TODOs
f1i3g3 Jul 31, 2024
af8e8ed
fix: updated usages
f1i3g3 Jul 31, 2024
42afe23
feat: pyproject.toml stub uploaded
f1i3g3 Jul 31, 2024
6a8e5c9
fix: added @override where needed
f1i3g3 Jul 31, 2024
086fd03
feat: some changes in project structure:
f1i3g3 Aug 2, 2024
df2240a
fix: quick generator fix
f1i3g3 Aug 2, 2024
7148b63
refactor: changed normality test structure
f1i3g3 Oct 22, 2024
d4554ae
fix: added abstract normality test case
f1i3g3 Oct 22, 2024
9e0a8a1
feat: added exponentiality tests stubs
f1i3g3 Nov 8, 2024
d7050e7
merge: merge branch 'architecture' into refactoring
f1i3g3 Nov 10, 2024
f2f387d
refactor: removed time_cache for redundancy
f1i3g3 Nov 16, 2024
ed6e1e5
refactor: deleted generator wrappers for redundancy
f1i3g3 Nov 16, 2024
2479154
refactor: synchronized with current architecture (added new files, mi…
f1i3g3 Nov 16, 2024
a50d5a3
refactor: synchronized with current architecture (moved extended pack…
f1i3g3 Nov 16, 2024
0ff2271
refactor: synchronized with current architecture (moved standard pack…
f1i3g3 Nov 16, 2024
e005d88
refactor: changes in statistics for current architecture (also weibul…
f1i3g3 Nov 16, 2024
4875001
refactor: changes in tests for current architecture (with weibull sup…
f1i3g3 Nov 16, 2024
eeaf3b1
refactor: added missed file
f1i3g3 Nov 16, 2024
b93d132
merge: merge pull request #2 from f1i3g3/refactoring
f1i3g3 Nov 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,11 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/
/data1/

# Local folders and files
execution_time/
test_distribution/
cache.json
local_tests.py
88 changes: 0 additions & 88 deletions example.py

This file was deleted.

2 changes: 1 addition & 1 deletion generators/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ def code(self):
return super()._convert_to_code(['beta', self.a, self.b])

def generate(self, size):
return generate_beta(size=size, a=self.a, b=self.b)
return generate_beta(size=size, a=self.a, b=self.b)
20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[project]
name = "stattest"
version = "0.0.1"
authors = [
{ name="Example Author", email="author@example.com" },
]
description = "Stattest Project"
readme = "README.md"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]

[project.urls]
Homepage = "https://github.com/alex98247/statistic-test"
Issues = "https://github.com/alex98247/statistic-test/issues"

# TODO: fill stub from official documentation
2 changes: 1 addition & 1 deletion stattest/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Config = dict[str, Any]

USERPATH_GENERATORS = "generators"
USERPATH_HYPOTHESIS = "hypothesis"
USERPATH_HYPOTHESIS = "hypothesis"
8 changes: 4 additions & 4 deletions stattest/core/distribution/expon.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from scipy.stats import expon


def generate_expon(size, l=1):
scale = 1 / l
def generate_expon(size, lam=1): # refactor structure with inheritance
scale = 1 / lam
return expon.rvs(size=size, scale=scale)


def cdf_expon(rvs, l=1):
scale = 1 / l
def cdf_expon(rvs, lam=1):
scale = 1 / lam
return expon.cdf(rvs, scale=scale)
8 changes: 4 additions & 4 deletions stattest/core/distribution/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import numpy as np


def moment(a, moment=1, center=None):
scipy_moment(a=a, moment=moment, center=center)
def moment(a, mom=1, center=None):
scipy_moment(a=a, moment=mom, center=center)


def central_moment(a, moment=1):
return scipy_moment(a=a, moment=moment, center=np.mean(a, axis=0))
def central_moment(a, mom=1):
return scipy_moment(a=a, moment=mom, center=np.mean(a, axis=0))
26 changes: 13 additions & 13 deletions stattest/core/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ def get(self, key: str):
"""
Get cached value if exists, else return None.

:param key: cache key
:param key: cache_services key
"""
raise NotImplementedError("Method is not implemented")

def put(self, key: str, value):
"""
Put object to cache.
Put object to cache_services.

:param key: cache key
:param value: cache value
:param key: cache_services key
:param value: cache_services value
"""
raise NotImplementedError("Method is not implemented")

Expand All @@ -44,7 +44,7 @@ def get(self, key: str):
"""
Get cached value if exists, else return None.

:param key: cache key
:param key: cache_services key
"""

if key not in self.cache.keys():
Expand All @@ -64,10 +64,10 @@ def get_with_level(self, keys: [str]):

def put(self, key: str, value):
"""
Put object to cache.
Put object to cache_services.

:param key: cache key
:param value: cache value
:param key: cache_services key
:param value: cache_services value
"""

self.cache[key] = value
Expand All @@ -90,7 +90,7 @@ def _create_key(self, keys: [str]):
class JsonStoreService(InMemoryStoreService):

def __init__(self, filename='cache.json', separator='.'):
super().__init__(separator)
super().__init__(separator=separator)
mem_cache = {}
if os.path.isfile(filename):
mem_cache = read_json(filename)
Expand All @@ -100,10 +100,10 @@ def __init__(self, filename='cache.json', separator='.'):

def put(self, key: str, value):
"""
Put object to cache.
Put object to cache_services.

:param key: cache key
:param value: cache value
:param key: cache_services key
:param value: cache_services value
"""
super().put(key, value)
write_json(self.filename, self.cache)
Expand Down Expand Up @@ -132,7 +132,7 @@ def flush(self):
class FastJsonStoreService(FastStoreService):

def __init__(self, filename='cache.json', separator='.'):
super().__init__(separator)
super().__init__(separator=separator)
mem_cache = {}
if os.path.isfile(filename):
mem_cache = read_json(filename)
Expand Down
3 changes: 2 additions & 1 deletion stattest/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class OperationalException(PySatlException):
Most of the time, this is caused by an invalid Configuration.
"""


class ConfigurationError(OperationalException):
"""
Configuration error. Usually caused by invalid configuration.
"""
"""
Empty file added stattest/execution/__init__.py
Empty file.
100 changes: 100 additions & 0 deletions stattest/execution/cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
from stattest.core.store import FastJsonStoreService, write_json


class CacheResultService(FastJsonStoreService):

def get_with_prefix(self, keys: [str]) -> {}:
"""
Get JSON value by prefix chain in 'keys' param.

:param keys: keys chain prefix param
"""

key_prefix = self._create_key(keys)
result = {}
for key in self.cache:
if key.startswith(key_prefix):
result[key] = self.get(key)
return result

def get_level_prefixes(self, keys: [str], level: int) -> set:
"""
Get JSON value by prefix chain in 'keys' param.

:param keys:
:param level:
"""

key_prefix = self._create_key(keys)
result = []
for key in self.cache:
split = key.split(self.separator)
if len(split) > level and key.startswith(key_prefix):
result.append(split[level])
return set(result)


class ThreadSafeCacheResultService(CacheResultService):
def __init__(self, filename='result.json', separator=':', cache=None, lock=None):
super().__init__(filename=filename, separator=separator)
self.filename = filename
self.separator = separator
self.cache = cache
self.lock = lock

def flush(self):
"""
Flush data to persisted store.
"""

with self.lock:
cache_dict = dict(self.cache)
write_json(self.filename, cache_dict)

def put(self, key: str, value):
"""
Put object to cache_services.

:param key: cache_services key
:param value: cache_services value
"""
with self.lock:
self.cache[key] = value

def put_with_level(self, keys: [str], value):
"""
Put JSON value by keys chain in 'keys' param.

:param value: value to put
:param keys: keys chain param
"""

key = self._create_key(keys)
with self.lock:
self.cache[key] = value

def set_filename(self, filename: str):
"""
Sets filename field.

Parameters
----------
filename : str
Filename.
"""

self.filename = filename

def set_separator(self, separator: str):
"""
Sets filename field.

Parameters
----------
separator : str
Filename.
"""

self.separator = separator

# TODO: move to stattest/execution??
2 changes: 1 addition & 1 deletion stattest/execution/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def generate_rvs_data(rvs_generator: AbstractRVSGenerator, size, count=1_000):
result = []
for i in range(count):
# df.loc[i] = list(rvs_generator.generate(size))
result.append(rvs_generator.generate(size))
result.append(rvs_generator._generate(size))
# return df
return result

Expand Down
Loading