Skip to content

Commit

Permalink
Update README.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
breimanntools committed Sep 25, 2023
1 parent bfb2f7b commit 8ee1dea
Show file tree
Hide file tree
Showing 98 changed files with 854 additions and 94 deletions.
157 changes: 157 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,160 @@ To generate the documentation locally:
make html
- Open `_build/html/index.html` in a browser.

Use ChatGPT!
============
Leverage the power of ChatGPT to optimize various facets of your software development process,
including code checking, interface optimization, and effective testing.

Simply use the templates provided below and fill in the blank spaces between
``START OF CODE`` and ``END OF CODE`` with the specifics of your task.

Due to the token limit of ChatGPT, the answers might not be complete. Use this prompt to continue the answer of ChatGPT:

.. code-block:: none
"Continue from where you left off."
Code checking
-------------
For reviewing your code's logic, ensuring conciseness, and promoting clarity, try the following prompt:

.. code-block:: none
"
Analyze and evaluate the provided TARGET CODE to ensure it adheres to best coding practices and is free from logical errors.
Inputs:
TARGET CODE:
- START OF CODE
-------------------------------------
your code
-------------------------------------
- END OF CODE
**Key Directive**: Identify vulnerabilities, inefficiencies, and areas of improvement. This is crucial.
Requirements:
1. Syntax and Formatting:
- Ensure consistent indentation and formatting throughout.
- Use meaningful variable and function names.
- Avoid hard-coded values; suggest constants or configuration inputs if necessary.
2. Logic and Flow:
- Confirm that the logic flows correctly and efficiently.
- Identify any potential issues like infinite loops, off-by-one errors, or misused conditions.
3. Error Handling:
- Suggest robust error handling mechanisms.
- Highlight potential areas where exceptions might arise and are not currently handled.
4. General Guidelines:
- Suggest improvements for readability and maintainability.
- Do not leave any placeholders like "TODO", "Fix this", "Add ..." without suggestions.
- Offer potential refactorings if they simplify the code without losing clarity.
Output Expectations:
- Detailed feedback on the TARGET CODE with line references.
- Suggestions for improvements and potential refactorings.
- Highlighted vulnerabilities and their proposed resolutions.
"
Interface optimization
----------------------
To enhance the public interface or signature of your functions and classes, employ the following prompt:

.. code-block:: none
"
Review and suggest improvements for the interface of the given TARGET FUNCTION to enhance its usability, clarity, and integration capabilities.
Inputs:
TARGET FUNCTION:
- START OF CODE
-------------------------------------
your code
-------------------------------------
- END OF CODE
**Key Directive**: The interface should be intuitive, versatile, and easy for other developers to integrate and use.
Requirements:
1. Signature Clarity:
- Ensure function/method names are descriptive and concise.
- Parameters should have clear names and, if possible, default values that make sense.
2. Documentation:
- Suggest comprehensive docstrings for the function.
- Propose comments for complex code blocks to aid understanding.
3. Return Values and Types:
- Advise on consistent return types, considering scenarios like error or null conditions.
- Recommend clear naming for returned objects, especially if using data structures like dictionaries or tuples.
4. General Guidelines:
- Avoid overloading the interface with too many parameters; suggest alternatives if needed.
- Consider common use cases and ensure they are easily achievable with the proposed interface.
- The interface should promote good coding practices and be resistant to misuse.
Output Expectations:
- Feedback and suggestions on function/method signatures.
- Proposed docstrings and comments.
- Recommendations for ensuring a consistent and intuitive interface.
"
Testing
-------
For generating efficient tests with extensive coverage and considering edge cases, utilize the prompt template below:

.. code-block:: none
"
Generate test functions for a given TARGET FUNCTION using the style of the provided TESTING TEMPLATE.
Inputs:
TARGET FUNCTION:
- START OF CODE
-------------------------------------
your code
-------------------------------------
- END OF CODE
TESTING TEMPLATE:
- START OF CODE
-------------------------------------
your code
-------------------------------------
- END OF CODE
**Key Directive**: For the Normal Cases Test Class, EACH function MUST test ONLY ONE individual parameter of the TARGET FUNCTION using Hypothesis for property-based testing. This is crucial.
Requirements:
1. Normal Cases Test Class:
- Name: 'Test[TARGET FUNCTION NAME]'.
- Objective: Test EACH parameter *INDIVIDUALLY*.
- Tests: For EACH parameter, at least 10 positive and 10 negative tests.
2. Complex Cases Test Class:
- Name: 'Test[TARGET FUNCTION NAME]Complex'.
- Objective: Test combinations of the TARGET FUNCTION parameters.
- Tests: At least 5 positive and 5 negative that intricately challenge the TARGET FUNCTION.
3. General Guidelines:
- Use Hypothesis for property-based testing, but test parameters individually for the Normal Cases Test Class .
- Tests should be clear, concise, and non-redundant.
- Do not leave any placeholders like "TODO", "Fill this", "Add ..." incomplete.
- Expose potential issues in the TARGET FUNCTION.
Output Expectations:
- Two test classes: one for normal cases (individual parameters) and one for complex cases (combinations).
- In Normal Cases, one function = one parameter tested.
- Total: at least 30 unique tests, 150+ lines of code.
Reminder: In Normal Cases, it's crucial to test parameters individually.
"
11 changes: 6 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ providing the following algorithms:
Moreover, AAanalysis provides functions for loading protein benchmark datasets (**load_data**),
amino acid scale sets (**load_scales**), and their in-depth two-level classification (**AAontology**).

If you are only looking for making publication-ready plots easily, see our `Plotting Prelude <https://https://aaanalysis.readthedocs.io/en/latest/generated/plotting_prelude.htmll>`.

Install
=======
**AAanalysis** can be installed either from `PyPi <https://pypi.org/project/aaanalysis>`_ or
Expand All @@ -61,14 +63,13 @@ Install
Contributions
=============

We welcome bug reports, feature requests, or updates on documentations and code. For details, refer to our
`CONTRIBUTING.rst <https://github.com/breimanntools/aaanalysis/blob/master/CONTRIBUTING.rst>`_.
Please email stephanbreimann@gmail.com for further questions or suggestions?
We appreciate bug reports, feature requests, or updates on documentation and code. For details, please refer to our
`CONTRIBUTING.rst <https://github.com/breimanntools/aaanalysis/blob/master/CONTRIBUTING.rst>`_. This guide includes
not only specifics related to `AAanalysis`, but also general software development hacks such as handy ChatGPT prompts.
For further questions or suggestions, please email stephanbreimann@gmail.com.

Citations
=========

If you use 'AAanalysis' in your work, please cite the respective publication as follows:

**AAclust**:
Expand Down
Binary file modified aaanalysis/__pycache__/utils.cpython-39.pyc
Binary file not shown.
5 changes: 0 additions & 5 deletions aaanalysis/explainer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
from aaanalysis.data_loader import load_dataset, load_scales
from aaanalysis.aaclust import AAclust
from aaanalysis.cpp import CPP, CPPPlot, SequenceFeature, SplitRange
from aaanalysis.dpulearn import dPULearn
from aaanalysis.plotting import plot_settings, plot_set_legend, plot_gcfs, plot_get_cmap, plot_get_cdict
4 changes: 2 additions & 2 deletions aaanalysis/explainer/tree_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# COL_FEAT_IMPACT = "feat_impact"

# II Main Functions
class Tree:
class TreeModel:
"""A wrapper for Tree based prediction models and Tree explainer from SHAP package to
explain prediction (typically binary classification) results at global and individual level"""
def __init__(self, model=None):
Expand All @@ -32,7 +32,7 @@ def add_feat_import(self, df_feat=None):
""""""


class TreeSHAP:
class ShapModel:
"""A wrapper for Tree explainer from SHAP package"""
def __init__(self, model=None):
""""""
Expand Down
Binary file modified aaanalysis/plotting/__pycache__/plotting_functions.cpython-39.pyc
Binary file not shown.
38 changes: 17 additions & 21 deletions aaanalysis/plotting/plotting_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,14 @@
from typing import List, Union, Tuple
import warnings

STR_CMAP_CPP = "CPP"
STR_CMAP_SHAP = "SHAP"
STR_CMAP_TAB = "TAB"
STR_DICT_COLOR = "DICT_COLOR"
STR_DICT_CAT = "DICT_CAT"

LIST_FONTS = ['Arial', 'Avant Garde',
'Bitstream Vera Sans', 'Computer Modern Sans Serif',
'DejaVu Sans', 'Geneva',
'Helvetica', 'Lucid',
'Lucida Grande', 'Verdana']


# Helper functions
# I Helper functions
# Check plot_settings
def check_font(font="Arial"):
""""""
Expand Down Expand Up @@ -132,9 +126,10 @@ def _get_cmap_with_gap(n_colors=100, pct_gap=10, pct_center=None,
return cmap


# Default plotting function
# II Main functions
# Plotting colors
def plot_get_cmap(name: str = "CPP",
n_colors: int = 100,
n_colors: int = 101,
facecolor_dark: bool = False
) -> Union[List[Tuple[float, float, float]], List[str]]:
"""
Expand All @@ -147,17 +142,17 @@ def plot_get_cmap(name: str = "CPP",
- ``CPP``: Continuous color map for CPP plots.
- ``SHAP``: Continuous color map for CPP-SHP plots.
- ``TAB``: List of Tableau (tab) colors for appealing visualization of categories.
- ``CAT``: Color list for appealing visualization of categories.
n_colors
Number of colors in the color map. Must be >=2 for 'CPP' and 'SHAP' and 2-9 for 'TAB'.
Number of colors in the color map. Must be >=2 for 'CPP' and 'SHAP' and 2-9 for 'CAT'.
facecolor_dark
Whether central color in 'CPP' and 'SHAP' is black (if ``True``) or white.
Returns
-------
list
List with colors given as RGB tuples (for 'CPP' and 'SHAP') or matplotlib color names (for 'TAB').
List with colors given as RGB tuples (for 'CPP' and 'SHAP') or matplotlib color names (for 'CAT').
Examples
--------
Expand All @@ -167,7 +162,7 @@ def plot_get_cmap(name: str = "CPP",
>>> import matplotlib.pyplot as plt
>>> import seaborn as sns
>>> import aaanalysis as aa
>>> colors = aa.plot_get_cmap(name="TAB", n_colors=4)
>>> colors = aa.plot_get_cmap(name="CAT", n_colors=4)
>>> data = {'Classes': ['Class A', 'Class B', 'Class C', "Class D"], 'Values': [23, 27, 43, 38]}
>>> aa.plot_settings(no_ticks_x=True, font_scale=1.2)
>>> sns.barplot(x='Classes', y='Values', data=data, palette=colors)
Expand All @@ -181,19 +176,19 @@ def plot_get_cmap(name: str = "CPP",
* `Matplotlib color names <https://matplotlib.org/stable/gallery/color/named_colors.html>`_
"""
# Check input
list_names = [STR_CMAP_CPP, STR_CMAP_SHAP, STR_CMAP_TAB]
list_names = [ut.STR_CMAP_CPP, ut.STR_CMAP_SHAP, ut.STR_CMAP_CAT]
if name not in list_names:
raise ValueError(f"'name' must be one of following: {list_names}")
ut.check_bool(name="facecolor_dark", val=facecolor_dark)

# Get color maps
if name == STR_CMAP_SHAP:
if name == ut.STR_CMAP_SHAP:
ut.check_non_negative_number(name="n_colors", val=n_colors, min_val=3, just_int=True)
return _get_shap_cmap(n_colors=n_colors, facecolor_dark=facecolor_dark)
elif name == STR_CMAP_CPP:
elif name == ut.STR_CMAP_CPP:
ut.check_non_negative_number(name="n_colors", val=n_colors, min_val=3, just_int=True)
return _get_cpp_cmap(n_colors=n_colors, facecolor_dark=facecolor_dark)
elif name == STR_CMAP_TAB:
elif name == ut.STR_CMAP_CAT:
ut.check_non_negative_number(name="n_colors", val=n_colors, min_val=2, max_val=9, just_int=True)
return _get_tab_color(n_colors=n_colors)

Expand Down Expand Up @@ -221,15 +216,16 @@ def plot_get_cdict(name: str = "DICT_COLOR") -> dict:
>>> dict_color = aa.plot_get_cdict(name="DICT_COLOR")
"""
list_names = [STR_DICT_COLOR, STR_DICT_CAT]
list_names = [ut.STR_DICT_COLOR, ut.STR_DICT_CAT]
if name not in list_names:
raise ValueError(f"'name' must be one of following: {list_names}")
if name == STR_DICT_COLOR:
if name == ut.STR_DICT_COLOR:
return ut.DICT_COLOR
else:
return ut.DICT_COLOR_CAT

# TODO test

# Plotting adjuster
def plot_settings(font_scale: float = 1,
font: str = "Arial",
fig_format: str = "pdf",
Expand Down Expand Up @@ -310,7 +306,7 @@ def plot_settings(font_scale: float = 1,
>>> import seaborn as sns
>>> import aaanalysis as aa
>>> data = {'Classes': ['Class A', 'Class B', 'Class C'], 'Values': [23, 27, 43]}
>>> colors = aa.plot_get_cmap(name="TAB", n_colors=3)
>>> colors = aa.plot_get_cmap(name="CAT", n_colors=3)
>>> aa.plot_settings()
>>> sns.barplot(x='Classes', y='Values', data=data, palette=colors)
>>> sns.despine()
Expand Down
7 changes: 7 additions & 0 deletions aaanalysis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ def _folder_path(super_folder, folder_name):
"Shape": "tab:cyan",
"Structure-Activity": "tab:brown"}

# Parameter options for cmaps and color dicts
STR_CMAP_CPP = "CPP"
STR_CMAP_SHAP = "SHAP"
STR_CMAP_CAT = "CAT"
STR_DICT_COLOR = "DICT_COLOR"
STR_DICT_CAT = "DICT_CAT"


# II MAIN FUNCTIONS
# Main Helper functions
Expand Down
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/generated/aaanalysis.plot_gcfs.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/generated/aaanalysis.plot_get_cdict.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/generated/aaanalysis.plot_get_cmap.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/generated/aaanalysis.plot_set_legend.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/generated/aaanalysis.plot_settings.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/index/CONTRIBUTING_COPY.doctree
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import seaborn as sns
import aaanalysis as aa
data = {'Classes': ['Class A', 'Class B', 'Class C'], 'Values': [23, 27, 43]}
colors = aa.plot_get_cmap(name="TAB", n_colors=3)
colors = aa.plot_get_cmap(name="CAT", n_colors=3)
aa.plot_settings()
sns.barplot(x='Classes', y='Values', data=data, palette=colors)
sns.despine()
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import matplotlib.pyplot as plt
import seaborn as sns
import aaanalysis as aa
colors = aa.plot_get_cmap(name="TAB", n_colors=4)
colors = aa.plot_get_cmap(name="CAT", n_colors=4)
data = {'Classes': ['Class A', 'Class B', 'Class C', "Class D"], 'Values': [23, 27, 43, 38]}
aa.plot_settings(no_ticks_x=True, font_scale=1.2)
sns.barplot(x='Classes', y='Values', data=data, palette=colors)
Expand Down
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8ee1dea

Please sign in to comment.