Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r dev-requirements.txt
pip install -e .

- name: Set PYTHONPATH
run: echo "PYTHONPATH=$(pwd):$PYTHONPATH" >> $GITHUB_ENV

- name: Run validation
run: |
if [ -z "$NOVALIDATE" ]; then
make validate
else
echo "skipping validate"
fi

- name: Run tests with coverage
run: pytest --cov ffx

- name: Upload coverage to Coveralls
if: matrix.python-version == '3.11'
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
coveralls-endpoint: https://coveralls.io
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FFX: Fast Function Extraction

[![Build Status at Travis CI](https://travis-ci.org/natekupp/ffx.svg?branch=master)](https://travis-ci.org/natekupp/ffx)
[![CI](https://github.com/natekupp/ffx/workflows/CI/badge.svg)](https://github.com/natekupp/ffx/actions?query=workflow%3ACI)
[![Coverage Status](https://coveralls.io/repos/github/natekupp/ffx/badge.svg?branch=master)](https://coveralls.io/github/natekupp/ffx?branch=master)

FFX is a technique for symbolic regression. It is:
Expand Down
25 changes: 5 additions & 20 deletions ffx/time_utils.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import os
import signal
import sys
import time
from contextlib import contextmanager
from functools import wraps

if sys.version_info.major >= 3 and sys.version_info.minor >= 3:
time_fn = time.perf_counter
elif os.name == 'nt':
time_fn = time.clock
else:
time_fn = time.time
from builtins import TimeoutError


class TimerResult:
def __init__(self):
self.start_time = time_fn()
self.start_time = time.perf_counter()
self.end_time = None

@property
Expand All @@ -29,7 +21,7 @@ def millis(self):

@contextmanager
def time_execution_scope():
'''Usage:
"""Usage:

with time_execution_scope() as timer_result:
do_some_operation()
Expand All @@ -39,18 +31,11 @@ def time_execution_scope():
timer_result=timer_result
)
)
'''
"""

timer_result = TimerResult()
yield timer_result
timer_result.end_time = time_fn()


try:
from builtins import TimeoutError # pylint: disable=unused-import
except ImportError:
# TimeoutError was introduced in python 3.3+
TimeoutError = OSError
timer_result.end_time = time.perf_counter()


def timeout(seconds_before_timeout):
Expand Down
Loading