Skip to content

Commit

Permalink
fix: testing with python version 3.9.13 and 3.9.17
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoMagnini committed Sep 19, 2024
1 parent b2dd123 commit e63de98
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- macos-latest
python-version:
- '3.9.13'
- '3.9.20'
- '3.9.17'
runs-on: ${{ matrix.os }}
name: Run tests on Python ${{ matrix.python-version }}, on ${{ matrix.os }}
timeout-minutes: 60
Expand Down
2 changes: 1 addition & 1 deletion psyki/fuzzifiers/netbuilder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,4 @@ def _visit_unary(self, node: Unary):
def _visit_negation(self, node: Negation, local_mapping, substitutions):
return Dense(
1, kernel_initializer=Ones, activation=eta_abs_one, trainable=False
)(self._visit(node.predicate, local_mapping, substitutions))
)(self._visit(node.predicate, local_mapping, substitutions))
10 changes: 9 additions & 1 deletion psyki/fuzzifiers/towell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@
from tensorflow import Tensor, sigmoid
from tensorflow.keras.initializers import constant, Zeros
from psyki.fuzzifiers import StructuringFuzzifier
from psyki.logic.operators import Disjunction, Conjunction, Equal, Less, LessEqual, Greater, GreaterEqual
from psyki.logic.operators import (
Disjunction,
Conjunction,
Equal,
Less,
LessEqual,
Greater,
GreaterEqual,
)
from psyki.ski import EnrichedModel
from psyki.utils import eta_one_abs, eta, concat, match_case

Expand Down
85 changes: 44 additions & 41 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

here = pathlib.Path(__file__).parent.resolve()

version_file = here / 'VERSION'
version_file = here / "VERSION"

# Get the long description from the README file
long_description = (here / 'README.md').read_text(encoding='utf-8')
long_description = (here / "README.md").read_text(encoding="utf-8")


def format_git_describe_version(version):
if '-' in version:
splitted = version.split('-')
if "-" in version:
splitted = version.split("-")
tag = splitted[0]
index = f"dev{splitted[1]}"
return f"{tag}.{index}"
Expand All @@ -25,17 +25,19 @@ def format_git_describe_version(version):

def get_version_from_git():
try:
process = subprocess.run(["git", "describe"], cwd=str(here), check=True, capture_output=True)
version = process.stdout.decode('utf-8').strip()
process = subprocess.run(
["git", "describe"], cwd=str(here), check=True, capture_output=True
)
version = process.stdout.decode("utf-8").strip()
version = format_git_describe_version(version)
with version_file.open('w') as f:
with version_file.open("w") as f:
f.write(version)
return version
except subprocess.CalledProcessError:
if version_file.exists():
return version_file.read_text().strip()
else:
return '0.1.0'
return "0.1.0"


version = get_version_from_git()
Expand All @@ -47,7 +49,7 @@ def get_version_from_git():
class GetVersionCommand(distutils.cmd.Command):
"""A custom command to get the current project version inferred from git describe."""

description = 'gets the project version from git describe'
description = "gets the project version from git describe"
user_options = []

def initialize_options(self):
Expand All @@ -63,7 +65,7 @@ def run(self):
class DownloadDatasets(distutils.cmd.Command):
"""A custom command to download the datasets used in the examples."""

description = 'downloads the datasets used in the examples'
description = "downloads the datasets used in the examples"
user_options = []

def initialize_options(self):
Expand All @@ -74,6 +76,7 @@ def finalize_options(self):

def run(self):
import psyki

try:
from test.resources.data import DATASETS

Expand All @@ -84,50 +87,50 @@ def run(self):


setup(
name='psyki', # Required
name="psyki", # Required
version=version,
description='Python-based implementation of PSyKI, i.e. a Platform for Symbolic Knowledge Injection',
license='Apache 2.0 License',
description="Python-based implementation of PSyKI, i.e. a Platform for Symbolic Knowledge Injection",
license="Apache 2.0 License",
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/psykei/psyki-python',
author='Matteo Magnini',
author_email='[email protected]',
long_description_content_type="text/markdown",
url="https://github.com/psykei/psyki-python",
author="Matteo Magnini",
author_email="[email protected]",
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Prolog'
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Prolog",
],
keywords='symbolic knowledge injection, ski, symbolic ai', # Optional
keywords="symbolic knowledge injection, ski, symbolic ai", # Optional
# package_dir={'': 'src'}, # Optional
packages=find_packages(), # Required
include_package_data=True,
python_requires='>=3.9.13, <3.10',
python_requires=">=3.9.13, <3.10",
install_requires=[
'tensorflow>=2.14.1,<2.15.0',
'numpy>=1.22.3',
'2ppy>=0.4.0',
'scikit-learn>=1.0.2',
'pandas>=1.4.2',
'codecarbon>=2.2.4,<2.3.0',
'prometheus_client>=0.17.0'
"tensorflow>=2.14.1,<2.15.0",
"numpy>=1.22.3",
"2ppy>=0.4.0",
"scikit-learn>=1.0.2",
"pandas>=1.4.2",
"codecarbon>=2.2.4,<2.3.0",
"prometheus_client>=0.17.0",
], # Optional
zip_safe = False,
platforms = "Independant",
zip_safe=False,
platforms="Independant",
project_urls={ # Optional
'Bug Reports': 'https://github.com/psykei/psyki-python/issues',
"Bug Reports": "https://github.com/psykei/psyki-python/issues",
# 'Funding': 'https://donate.pypi.org',
# 'Say Thanks!': 'http://saythanks.io/to/example',
'Source': 'https://github.com/psykei/psyki-python',
"Source": "https://github.com/psykei/psyki-python",
},
cmdclass={
'get_project_version': GetVersionCommand,
'download_datasets': DownloadDatasets
"get_project_version": GetVersionCommand,
"download_datasets": DownloadDatasets,
},
)
9 changes: 7 additions & 2 deletions test/psyki/ski/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


SEED = 0 # Set seed to make sure that the test is reproducible
TEST_SIZE = 1/3 # 1/3 is a fairly common test size
TEST_SIZE = 1 / 3 # 1/3 is a fairly common test size
EPOCHS = 2 # Just check if it runs without errors (2 epochs are required because only one could not catch some errors)
BATCH_SIZE = 32 # 32 is a fairly common batch size
VERBOSE = 0 # 0 = silent, 1 = progress bar, 2 = one line per epoch
Expand All @@ -33,7 +33,12 @@ def _test_educated_training(self, educated: Model, dataset: pd.DataFrame):
psyki.logger.info(f"testing educated training")
time = datetime.now()
set_seed(SEED)
train, test = train_test_split(dataset, test_size=TEST_SIZE, random_state=SEED, stratify=dataset.iloc[:, -1:])
train, test = train_test_split(
dataset,
test_size=TEST_SIZE,
random_state=SEED,
stratify=dataset.iloc[:, -1:],
)
train_x, train_y = train.iloc[:, :-1], to_categorical(train.iloc[:, -1:])
test_x, test_y = test.iloc[:, :-1], to_categorical(test.iloc[:, -1:])
history = educated.fit(
Expand Down

0 comments on commit e63de98

Please sign in to comment.