Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rtichoke 014 #19

Merged
merged 47 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9573f3c
minor change to test github actions
urigott Aug 31, 2023
03df150
Create requirements.txt
urigott Aug 31, 2023
0b38bf1
Update requirements.txt
urigott Aug 31, 2023
7da2a40
more corrections based on pylint suggestions
urigott Aug 31, 2023
1f3cbf4
Update requirements.txt
urigott Aug 31, 2023
1d7f359
Update test_calculate_performance_data.py
urigott Sep 3, 2023
17c4c42
Update test_vericiation_tests.py
urigott Sep 3, 2023
a0199a9
Update test_vericiation_tests.py
urigott Sep 3, 2023
c097b27
Update test_calculate_performance_data.py
urigott Sep 3, 2023
e2ccfe4
Create rtichoke.py
urigott Sep 3, 2023
0efc212
Update __init__.py
urigott Sep 3, 2023
8ed69a5
Update test_calculate_performance_data.py
urigott Sep 3, 2023
24f5d2d
Update test_vericiation_tests.py
urigott Sep 3, 2023
0bc0263
Update end_to_end_test.py
urigott Sep 3, 2023
58038fa
Update test_calculate_performance_data.py
urigott Sep 3, 2023
1c0d180
Update test_vericiation_tests.py
urigott Sep 3, 2023
e44e84d
Update __init__.py
urigott Sep 3, 2023
f183bb5
Update rtichoke.py
urigott Sep 3, 2023
88d0024
Update __init__.py
urigott Sep 3, 2023
29f34dc
Update __init__.py
urigott Sep 3, 2023
b677421
Update rtichoke.py
urigott Sep 3, 2023
b521ef2
Update rtichoke.py
urigott Sep 3, 2023
ac9d3d6
Update __init__.py
urigott Sep 3, 2023
2de4157
Update rtichoke.py
urigott Sep 3, 2023
234f8f0
Update test_calculate_performance_data.py
urigott Sep 3, 2023
92648eb
Update test_calculate_performance_data.py
urigott Sep 3, 2023
2531ba0
Update test_calculate_performance_data.py
urigott Sep 3, 2023
c2f1a71
Update test_vericiation_tests.py
urigott Sep 3, 2023
bf83ab9
Update rtichoke.py
urigott Sep 3, 2023
1e6da09
Update rtichoke.py
urigott Sep 3, 2023
517ca46
Update rtichoke.py
urigott Sep 3, 2023
0d93c84
Update test_calculate_performance_data.py
urigott Sep 3, 2023
a4c67f5
Update test_calculate_performance_data.py
urigott Sep 3, 2023
5b66461
Update __init__.py
urigott Sep 3, 2023
80e4c40
Rename end_to_end_test.py to end_to_end_test.py
urigott Sep 3, 2023
e731dfe
Update __init__.py
urigott Sep 3, 2023
ab2cf61
Update test_calculate_performance_data.py
urigott Sep 3, 2023
8fea275
Update test_calculate_performance_data.py
urigott Sep 3, 2023
88077c4
Update test_vericiation_tests.py
urigott Sep 3, 2023
5e53eb9
Update test_calculate_performance_data.py
urigott Sep 3, 2023
5a5d6cb
Update test_calculate_performance_data.py
urigott Sep 3, 2023
4ecf539
Update test_calculate_performance_data.py
urigott Sep 3, 2023
27b1145
Rename end_to_end_test.py to end_to_end_test.py
urigott Sep 3, 2023
157220c
change module stracture
urigott Sep 3, 2023
6280adc
Update test_calculate_performance_data.py
urigott Sep 3, 2023
a383571
Update test_calculate_performance_data.py
urigott Sep 3, 2023
9bd5d75
Update test_calculate_performance_data.py
urigott Sep 3, 2023
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
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""docs file"""
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand All @@ -7,7 +8,7 @@
# -- Project information -----------------------------------------------------

project = "rtichoke"
copyright = "2023, Uriah Finkel"
copyrights = "2023, Uriah Finkel"
author = "Uriah Finkel"

# -- General configuration ---------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
numpy==1.25.2
bokeh==3.2.2
scikit-learn==1.3.0
pandas==2.1.0
IPython==8.14.0
tqdm==4.66.1
7 changes: 7 additions & 0 deletions rtichoke/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""rtichoke is a package for interactive vizualization of performance metrics
"""
from importlib.metadata import version

# __version__ = version("rtichoke")

from .rtichoke import Rtichoke
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def check_probs_vs_reals(probs, reals):
raise ValueError(
f"Probs and reals shapes are inconsistent ({probs.shape} and {reals.shape})"
)
elif len(probs) < 2:
if len(probs) < 2:
raise ValueError("At least two entries should be included reals and probs")


Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ def plot_bokeh(self, generic_plot_dict, filename=None):
)

# add scatter
filtered_scatter = [
True if th == slider.value else False for th in df[stratification]
]
filtered_scatter = [th == slider.value for th in df[stratification]]
scatter_source = ColumnDataSource(data=df.loc[filtered_scatter])

for j, pop in enumerate(pops):
Expand All @@ -132,7 +130,7 @@ def plot_bokeh(self, generic_plot_dict, filename=None):
# Adding callback code
source = ColumnDataSource(data=df.set_index("Population"))
callback = CustomJS(
args=dict(source=source, scatter_source=scatter_source, val=slider),
args={"source": source, "scatter_source": scatter_source, "val": slider},
code=create_JS_code(x=x, y=y, stratification=stratification),
)

Expand Down
File renamed without changes.
10 changes: 1 addition & 9 deletions src/rtichoke/__init__.py → rtichoke/rtichoke.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
"""rtichoke is a package for interactive vizualization of performance metrics
"""

from importlib.metadata import version

# __version__ = version("rtichoke")

from .helpers.helper_functions import *

from .helpers.helper_functions import tprint

class Rtichoke:
"""Main Rtichoke class"""

# import methods
from .performance_data.prepare_performance_data import (
prepare_performance_data,
Expand All @@ -20,7 +13,6 @@ class Rtichoke:
prepare_calibration_data,
prepare_calibration_table,
)

from .helpers.validations import validate_inputs, validate_plot_inputs, check_by
from .helpers.helper_functions import (
select_data_table,
Expand Down
1 change: 1 addition & 0 deletions src/tests/__init__.py → rtichoke/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""
testing module

"""
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import numpy as np
import pandas as pd
from numpy.testing import assert_allclose
from rtichoke import Rtichoke

# UnitTests created with ChatGPT! :-)
import rtichoke


class TestPreparePerformanceTable(unittest.TestCase):
"""UnitTest class to test performance tables"""
"""UnitTest class to test performance tables
Tests were created with ChatGPT :-)
"""

def setUp(self):
"""Simulate an Rtichoke object"""
probs = {"pop1": np.array([0.7, 0.8, 0.9, 0.4, 0.2, 0.6, 0.5])}
reals = {"pop1": np.array([1, 1, 1, 0, 0, 1, 0])}
self.r = Rtichoke(probs=probs, reals=reals, by=0.1)
self.r = rtichoke.Rtichoke(probs=probs, reals=reals, by=0.1)

def test_performance_table_type_and_size(self):
"""Test performance table type and size"""
Expand Down Expand Up @@ -78,17 +78,17 @@ def test_performance_data_with_two_populations(self):
"pop1": np.array([1, 1, 1, 0, 0, 1, 0]),
"pop2": np.array([1, 1, 1, 0, 0, 1, 0]),
}
r = Rtichoke(probs=probs, reals=reals, by=0.1)
r = rtichoke.Rtichoke(probs=probs, reals=reals, by=0.1)

expected_pop_name = ["pop1", "pop2"]
pt_table_pop_name = r.performance_table_pt["Population"].unique()
ppcr_table_pop_name = r.performance_table_ppcr["Population"].unique()
expected_pop_name = {"pop1", "pop2"}
pt_table_pop_name = set(r.performance_table_pt["Population"].unique())
ppcr_table_pop_name = set(r.performance_table_ppcr["Population"].unique())

self.assertEqual(expected_pop_name, pt_table_pop_name)
self.assertEqual(expected_pop_name, ppcr_table_pop_name)

self.assertEqual(r.performance_table_pt.shape, (15, 22))
self.assertEqual(r.performance_table_ppcr.shape, (15, 22))
self.assertEqual(r.performance_table_pt.shape, (22, 15))
self.assertEqual(r.performance_table_ppcr.shape, (22, 15))


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import unittest
import numpy as np
from rtichoke.helpers.validations import check_probs, check_probs_vs_reals, check_reals
from rtichoke import Rtichoke
from rtichoke import rtichoke


class TestCheckProbs(unittest.TestCase):
Expand Down Expand Up @@ -95,13 +95,13 @@ class TestCheckBy(unittest.TestCase):

def test_valid_by_value(self):
"""Test check_by: valid value"""
Rtichoke(probs=np.array([0.1, 0.5, 0.9]), reals=np.array([0, 1, 0]), by=0.25)
rtichoke.Rtichoke(probs=np.array([0.1, 0.5, 0.9]), reals=np.array([0, 1, 0]), by=0.25)

def test_by_not_a_float(self):
"""Test check_by: `by` argument not a float"""
# Test that an exception is raised when the input is not a float
with self.assertRaises(ValueError) as e:
Rtichoke(
rtichoke.Rtichoke(
probs=np.array([0.1, 0.5, 0.9]), reals=np.array([0, 1, 0]), by="0.25"
)
self.assertEqual(
Expand All @@ -112,7 +112,7 @@ def test_by_out_of_range(self):
"""Test check_by: `by` argument out of range"""
# Test that an exception is raised when the input is out of range
with self.assertRaises(ValueError) as e:
Rtichoke(
rtichoke.Rtichoke(
probs=np.array([0.1, 0.5, 0.9]), reals=np.array([0, 1, 0]), by="0.6"
)
self.assertEqual(
Expand All @@ -125,7 +125,7 @@ class TestValidateInputs(unittest.TestCase):

def test_validate_inputs(self):
"""End-to-end test with valid inputs"""
r = Rtichoke(probs=np.array([0.1, 0.5, 0.9]), reals=np.array([0, 1, 0]), by=0.2)
r = rtichoke.Rtichoke(probs=np.array([0.1, 0.5, 0.9]), reals=np.array([0, 1, 0]), by=0.2)

# test for valid input
probs = np.array([0.1, 0.5, 0.9])
Expand Down
31 changes: 0 additions & 31 deletions src/end_to_end_test.py

This file was deleted.