Skip to content

Commit

Permalink
Merge pull request #3 from akali/summary
Browse files Browse the repository at this point in the history
Summary
  • Loading branch information
akali authored May 1, 2020
2 parents 15ac2c0 + cb00c07 commit 6d3f4a1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
34 changes: 25 additions & 9 deletions fuzzy_lib/MembershipFunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,45 @@ def _(x):
return self.modifier(_(X))

def extract_range(self, alpha_cut) -> (float, float):
return self._extract_left(alpha_cut), self._extract_right(alpha_cut)
if self(self.a) != 0 or self(self.b) != 1 or self(self.c) != 0:
normal = False
else:
normal = True
return self._extract_left(alpha_cut, normal), self._extract_right(alpha_cut, normal)

def _extract_left(self, alpha_cut):
def _extract_left(self, alpha_cut, normal=True):
left = self.a
right = self.b
for _ in range(100):
m = (left + right) / 2
if self(m) + _EPS <= alpha_cut:
left = m
if normal:
if self(m) + _EPS <= alpha_cut:
left = m
else:
right = m
else:
right = m
if self(m) + _EPS >= alpha_cut:
left = m
else:
right = m

return left

def _extract_right(self, alpha_cut):
def _extract_right(self, alpha_cut, normal=True):
left = self.b
right = self.c
for _ in range(100):
m = (left + right) / 2
if self(m) + _EPS <= alpha_cut:
right = m
if normal:
if self(m) + _EPS <= alpha_cut:
right = m
else:
left = m
else:
left = m
if self(m) + _EPS >= alpha_cut:
right = m
else:
left = m

return right

Expand Down
3 changes: 1 addition & 2 deletions fuzzy_lib/Modifier.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import copy
import math
from dataclasses import dataclass
from typing import Callable, List
from typing import Callable


def default_modifier(x):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
setup(
name='fuzzy_lib',
packages=['fuzzy_lib'],
version='0.2',
version='0.3',
license='MIT',
description='Fuzzy logic library containing modifiers for making fuzzy_lib database queries',
author='Aisultan Kali',
author_email='[email protected]',
url='https://github.com/akali/fuzzy',
download_url='https://github.com/akali/fuzzy/archive/0.2.tar.gz',
download_url='https://github.com/akali/fuzzy/archive/0.3.tar.gz',
keywords=['fuzzy_lib', 'modifier', 'hedge', 'query', 'database'],
install_requires=[
"pandas==1.0.3",
Expand Down

0 comments on commit 6d3f4a1

Please sign in to comment.