Welcome to phuzzy’s documentation!

phuzzy

https://img.shields.io/pypi/v/phuzzy.svg Documentation Status https://travis-ci.org/lepy/phuzzy.svg?branch=master https://coveralls.io/repos/github/lepy/phuzzy/badge.svg Updates https://api.codacy.com/project/badge/Grade/4814372e95c543a69c69004c853b17be https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg

Fuzzy calculation in Python.

Features

  • TODO

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Installation

https://img.shields.io/pypi/v/phuzzy.svg Documentation Status https://travis-ci.org/lepy/phuzzy.svg?branch=master https://coveralls.io/repos/github/lepy/phuzzy/badge.svg Updates https://api.codacy.com/project/badge/Grade/4814372e95c543a69c69004c853b17be https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg https://zenodo.org/badge/DOI/10.5281/zenodo.1219617.svg

Stable release

To install phuzzy, run this command in your terminal:

$ pip install phuzzy

This is the preferred method to install phuzzy, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

From sources

The sources for phuzzy can be downloaded from the Github repo.

You can either clone the public repository:

$ git clone git://github.com/lepy/phuzzy

Or download the tarball:

$ curl  -OL https://github.com/lepy/phuzzy/tarball/master

Once you have a copy of the source, you can install it with:

$ python setup.py install

Usage

To use phuzzy in a project:

import phuzzy
tn = phuzzy.TruncNorm(alpha0=[2, 3], alpha1=[], number_of_alpha_levels=15, name="t")
tri = phuzzy.Triangle(alpha0=[1, 4], alpha1=[2], number_of_alpha_levels=5)
f = tn + tri
print(f.df)

available shapes

Uniform

1
2
3
import phuzzy.mpl as phm
uni = phm.Uniform(alpha0=[1, 4], number_of_alpha_levels=5, name="x")
uni.plot(show=True, filepath="/tmp/uniform.png", title=True)
uniform fuzzy number

Uniform fuzzy number (this is just an interval)

Triangle

1
2
3
4
import phuzzy.mpl as phm

tri = phm.Triangle(alpha0=[1, 4], alpha1=[2], number_of_alpha_levels=5)
tri.plot(show=False, filepath="/tmp/triangle.png", title=True)
Triangle fuzzy number

Triangle fuzzy number

Trapezoid

1
2
3
import phuzzy.mpl as phm
trap = phm.Trapezoid(alpha0=[1, 5], alpha1=[2, 3], number_of_alpha_levels=5)
trap.plot(show=False, filepath="/tmp/trapezoid.png", title=True)
Trapezoid fuzzy number

Trapezoid fuzzy number

TruncNorm

1
2
3
import phuzzy.mpl as phm
tn = phm.TruncNorm(alpha0=[1, 3], number_of_alpha_levels=15, name="x")
tn.plot(show=False, filepath="/tmp/truncnorm.png", title=True)
TruncNorm fuzzy number

TruncNorm fuzzy number

TruncGenNorm

1
2
3
import phuzzy.mpl as phm
tgn = phm.TruncGenNorm(alpha0=[1, 4], alpha1=[2, 3], number_of_alpha_levels=15, beta=3.)
tgn.plot(show=False, filepath="/tmp/truncgennorm.png", title=True)
TruncGenNorm fuzzy number

TruncGenNorm fuzzy number

Superellipse

1
2
3
import phuzzy.mpl as phm
se = phm.Superellipse(alpha0=[-1, 2.], alpha1=None, m=1.0, n=.5, number_of_alpha_levels=17)
se.plot(show=True, filepath="/tmp/superellipse.png", title=True)
Superellipse fuzzy number

Superellipse fuzzy number

basic operations

Addition

z = x + y

1
2
3
4
x = phuzzy.Trapezoid(alpha0=[0, 4], alpha1=[2, 3], number_of_alpha_levels=5)
y = phuzzy.TruncNorm(alpha0=[1, 3], number_of_alpha_levels=15, name="y")
z = x + y
z.name = "x+y"
add

Addition of fuzzy numbers

Substraction

z = x - y

1
2
3
4
x = phuzzy.Trapezoid(alpha0=[0, 4], alpha1=[2, 3], number_of_alpha_levels=5)
y = phuzzy.TruncNorm(alpha0=[1, 3], number_of_alpha_levels=15, name="y")
z = x - y
z.name = "x-y"
add

Substraction of fuzzy numbers

Multiplication

z = x  y

1
2
3
4
x = phuzzy.Trapezoid(alpha0=[0, 4], alpha1=[2, 3], number_of_alpha_levels=5)
y = phuzzy.TruncNorm(alpha0=[1, 3], number_of_alpha_levels=15, name="y")
z = x * y
z.name = "x*y"
add

Multiplication of fuzzy numbers

Division

z = \frac{x}{y}

1
2
3
4
x = phuzzy.Trapezoid(alpha0=[0, 4], alpha1=[2, 3], number_of_alpha_levels=5)
y = phuzzy.TruncNorm(alpha0=[1, 3], number_of_alpha_levels=15, name="y")
z = x / y
z.name = "x/y"
add

Division of fuzzy numbers

Power

z = x^y

1
2
3
4
x = phuzzy.Trapezoid(alpha0=[0, 4], alpha1=[2, 3], number_of_alpha_levels=5)
y = phuzzy.TruncNorm(alpha0=[1, 3], number_of_alpha_levels=15, name="y")
z = x ** y
z.name = "x^y"
add

Power operation with fuzzy numbers

Shapes

Uniform

1
2
3
import phuzzy.mpl as phm
uni = phm.Uniform(alpha0=[1, 4], number_of_alpha_levels=5, name="x")
uni.plot(show=True, filepath="/tmp/uniform.png", title=True)
uniform fuzzy number

Uniform fuzzy number

Triangle

1
2
3
4
import phuzzy.mpl as phm

tri = phm.Triangle(alpha0=[1, 4], alpha1=[2], number_of_alpha_levels=5)
tri.plot(show=False, filepath="/tmp/triangle.png", title=True)
Triangle fuzzy number

Triangle fuzzy number

Trapezoid

1
2
3
import phuzzy.mpl as phm
trap = phm.Trapezoid(alpha0=[1, 5], alpha1=[2, 3], number_of_alpha_levels=5)
trap.plot(show=False, filepath="/tmp/trapezoid.png", title=True)
Trapezoid fuzzy number

Trapezoid fuzzy number

TruncNorm

1
2
3
import phuzzy.mpl as phm
tn = phm.TruncNorm(alpha0=[1, 3], number_of_alpha_levels=15, name="x")
tn.plot(show=False, filepath="/tmp/truncnorm.png", title=True)
TruncNorm fuzzy number

TruncNorm fuzzy number

TruncGenNorm

1
2
3
import phuzzy.mpl as phm
tgn = phm.TruncGenNorm(alpha0=[1, 4], alpha1=[2, 3], number_of_alpha_levels=15, beta=3.)
tgn.plot(show=False, filepath="/tmp/truncgennorm.png", title=True)
TruncGenNorm fuzzy number

TruncGenNorm fuzzy number

Superellipse

1
2
3
import phuzzy.mpl as phm
se = phm.Superellipse(alpha0=[-1, 2.], alpha1=None, m=1.0, n=.5, number_of_alpha_levels=17)
se.plot(show=True, filepath="/tmp/superellipse.png", title=True)
Superellipse fuzzy number

Superellipse fuzzy number

Superellipse fuzzy number (variation m, n)

Superellipse fuzzy number (variation m, n)

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions

Report Bugs

Report bugs at https://github.com/lepy/phuzzy/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.

Write Documentation

phuzzy could always use more documentation, whether as part of the official phuzzy docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/lepy/phuzzy/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that contributions are welcome :)

Get Started!

Ready to contribute? Here’s how to set up phuzzy for local development.

  1. Fork the phuzzy repo on GitHub.

  2. Clone your fork locally:

    $ git clone git@github.com:your_name_here/phuzzy.git
    
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    $ mkvirtualenv phuzzy
    $ cd phuzzy/
    $ python setup.py develop
    
  4. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    

    Now you can make your changes locally.

  5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:

    $ flake8 phuzzy tests
    $ python setup.py test or py.test
    $ tox
    

    To get flake8 and tox, just pip install them into your virtualenv.

  6. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  7. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests.
  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
  3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check https://travis-ci.org/lepy/phuzzy/pull_requests and make sure that the tests pass for all supported Python versions.

Tips

To run a subset of tests:

$ py.test tests.test_phuzzy

Deploying

A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in HISTORY.rst). Then run:

$ git push
$ git push --tags

Travis will then deploy to PyPI if tests pass.

Credits

Development Lead

Contributors

None yet. Why not be the first?

History

0.4.0 (2018-04-13)

  • First release on PyPI.

0.5.0 (2018-04-16)

  • rename FuzzyNumber.df.columns = [“alpha”, “l”, “r”]
lsdyna

Indices and tables