Time ranges with python

Overview

Discord

Badges
Build Python package semantic-release PyPI Read the Docs
Tests coverage pre-commit
Standards SemVer 2.0.0 Conventional Commits
Code Code style: black Imports: isort Checked with mypy
Repo GitHub issues GitHub stars GitHub license All Contributors Contributor Covenant

timeranges

Time ranges.

Read the Docs

Installation

pip

timeranges is available on pip:

pip install timeranges

GitHub

You can also install the latest version of the code directly from GitHub:

pip install git+git://github.com/MicaelJarniac/timeranges

Usage

For more examples, see the full documentation.

10:00" time_range = TimeRange(time(0), time(10)) # Check if these times are contained in `time_range` assert time(0) in time_range assert time(5) in time_range assert time(10) in time_range # Check if these times aren't contained in `time_range` assert time(10, 0, 1) not in time_range assert time(11) not in time_range assert time(20) not in time_range time_range_2 = TimeRange(time(15), time(20)) time_ranges = TimeRanges([time_range, time_range_2]) assert time(0) in time_ranges assert time(5) in time_ranges assert time(10) in time_ranges assert time(12) not in time_ranges assert time(15) in time_ranges assert time(17) in time_ranges assert time(20) in time_ranges assert time(22) not in time_ranges ">
from datetime import time

from timeranges import TimeRange, TimeRanges, WeekRange, Weekday


# Create a `TimeRange` instance with the interval "0:00 -> 10:00"
time_range = TimeRange(time(0), time(10))

# Check if these times are contained in `time_range`
assert time(0) in time_range
assert time(5) in time_range
assert time(10) in time_range

# Check if these times aren't contained in `time_range`
assert time(10, 0, 1) not in time_range
assert time(11) not in time_range
assert time(20) not in time_range


time_range_2 = TimeRange(time(15), time(20))
time_ranges = TimeRanges([time_range, time_range_2])

assert time(0) in time_ranges
assert time(5) in time_ranges
assert time(10) in time_ranges
assert time(12) not in time_ranges
assert time(15) in time_ranges
assert time(17) in time_ranges
assert time(20) in time_ranges
assert time(22) not in time_ranges

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

More details can be found in CONTRIBUTING.

Contributors

License

MIT

Created from cookiecutter-python-project.

Comments
  • fix: proper handling with empty structures

    fix: proper handling with empty structures

    As presented in https://github.com/tractian/tractian-python-sdk/issues/30#issuecomment-993901186,

    • empty dictionary in day_ranges means all days, with this, any datetime should return True in __contains__
    • empty list in time_ranges means all hours, with this, any datetime at the same weekday should return True in __contains__ The actual PR is a suggestion to this behavior works, which is not working properly.

    Examples of misleading behavior:

    • Datetime in a weekday with empty list as time_ranges image
    • Datetime not in a empty dict as day_ranges image
    opened by lucascust2 1
  • docs: add MicaelJarniac as a contributor for bug, code, doc, example, ideas, maintenance, projectManagement, review, tool, test

    docs: add MicaelJarniac as a contributor for bug, code, doc, example, ideas, maintenance, projectManagement, review, tool, test

    Add @MicaelJarniac as a contributor for bug, code, doc, example, ideas, maintenance, projectManagement, review, tool, test.

    This was requested by MicaelJarniac in this comment

    opened by allcontributors[bot] 0
  • Fix public API

    Fix public API

    On VS Code, if I type

    from timeranges import
    

    it doesn't auto-complete.

    Something about the way I'm "exporting" the public items on __init__.py isn't quite right.

    bug 
    opened by MicaelJarniac 0
  • Create a method for getting a fully-filled object

    Create a method for getting a fully-filled object

    Something like TimeRanges.full() that'd return TimeRanges([TimeRange()]), and WeekRange.full() that'd return WeekRange({Weekday.MONDAY: TimeRanges.full(), ...}) (with all days of the week).

    enhancement 
    opened by MicaelJarniac 0
  • Make `TimeRanges` and `WeekRange` behave more like native collections

    Make `TimeRanges` and `WeekRange` behave more like native collections

    TimeRanges could behave like a list, and WeekRange like a dict.

    https://docs.python.org/3/reference/datamodel.html#emulating-container-types

    • [ ] __bool__
    enhancement 
    opened by MicaelJarniac 1
  • Compare multiple times at once

    Compare multiple times at once

    assert (time(...), time(...)) in TimeRange(...)
    assert (time(...), time(...)) in TimeRanges(...)
    assert (datetime(...), datetime(...)) in WeekRange(...)
    
    enhancement 
    opened by MicaelJarniac 0
Releases(v1.0.2)
Owner
Micael Jarniac
Micael Jarniac
Show you how to integrate Zeppelin with Airflow

Introduction This repository is to show you how to integrate Zeppelin with Airflow. The philosophy behind the ingtegration is to make the transition f

Jeff Zhang 11 Dec 30, 2022
Sentiment analysis on streaming twitter data using Spark Structured Streaming & Python

Sentiment analysis on streaming twitter data using Spark Structured Streaming & Python This project is a good starting point for those who have little

Himanshu Kumar singh 2 Dec 04, 2021
A powerful data analysis package based on mathematical step functions. Strongly aligned with pandas.

The leading use-case for the staircase package is for the creation and analysis of step functions. Pretty exciting huh. But don't hit the close button

48 Dec 21, 2022
International Space Station data with Python research 🌎

International Space Station data with Python research 🌎 Plotting ISS trajectory, calculating the velocity over the earth and more. Plotting trajector

Facundo Pedaccio 41 Jun 16, 2022
Synthetic data need to preserve the statistical properties of real data in terms of their individual behavior and (inter-)dependences

Synthetic data need to preserve the statistical properties of real data in terms of their individual behavior and (inter-)dependences. Copula and functional Principle Component Analysis (fPCA) are st

32 Dec 20, 2022
Active Learning demo using two small datasets

ActiveLearningDemo How to run step one put the dataset folder and use command below to split the dataset to the required structure run utils.py For ea

3 Nov 10, 2021
Python ELT Studio, an application for building ELT (and ETL) data flows.

The Python Extract, Load, Transform Studio is an application for performing ELT (and ETL) tasks. Under the hood the application consists of a two parts.

Schlerp 55 Nov 18, 2022
Single-Cell Analysis in Python. Scales to >1M cells.

Scanpy – Single-Cell Analysis in Python Scanpy is a scalable toolkit for analyzing single-cell gene expression data built jointly with anndata. It inc

Theis Lab 1.4k Jan 05, 2023
University Challenge 2021 With Python

University Challenge 2021 This repository contains: The TeX file of the technical write-up describing the University / HYPER Challenge 2021 under late

2 Nov 27, 2021
Flexible HDF5 saving/loading and other data science tools from the University of Chicago

deepdish Flexible HDF5 saving/loading and other data science tools from the University of Chicago. This repository also host a Deep Learning blog: htt

UChicago - Department of Computer Science 255 Dec 10, 2022
Generates a simple report about the current Covid-19 cases and deaths in Malaysia

Generates a simple report about the current Covid-19 cases and deaths in Malaysia. Results are delay one day, data provided by the Ministry of Health Malaysia Covid-19 public data.

Yap Khai Chuen 7 Dec 15, 2022
Projects that implement various aspects of Data Engineering.

DATAWAREHOUSE ON AWS The purpose of this project is to build a datawarehouse to accomodate data of active user activity for music streaming applicatio

2 Oct 14, 2021
BAyesian Model-Building Interface (Bambi) in Python.

Bambi BAyesian Model-Building Interface in Python Overview Bambi is a high-level Bayesian model-building interface written in Python. It's built on to

861 Dec 29, 2022
Data exploration done quick.

Pandas Tab Implementation of Stata's tabulate command in Pandas for extremely easy to type one-way and two-way tabulations. Support: Python 3.7 and 3.

W.D. 20 Aug 27, 2022
Statsmodels: statistical modeling and econometrics in Python

About statsmodels statsmodels is a Python package that provides a complement to scipy for statistical computations including descriptive statistics an

statsmodels 8k Dec 29, 2022
Processo de ETL (extração, transformação, carregamento) realizado pela equipe no projeto final do curso da Soul Code Academy.

Processo de ETL (extração, transformação, carregamento) realizado pela equipe no projeto final do curso da Soul Code Academy.

Débora Mendes de Azevedo 1 Feb 03, 2022
Zipline, a Pythonic Algorithmic Trading Library

Zipline is a Pythonic algorithmic trading library. It is an event-driven system for backtesting. Zipline is currently used in production as the backte

Quantopian, Inc. 15.7k Jan 07, 2023
BioMASS - A Python Framework for Modeling and Analysis of Signaling Systems

Mathematical modeling is a powerful method for the analysis of complex biological systems. Although there are many researches devoted on produ

BioMASS 22 Dec 27, 2022
Universal data analysis tools for atmospheric sciences

U_analysis Universal data analysis tools for atmospheric sciences Script written in python 3. This file defines multiple functions that can be used fo

Luis Ackermann 1 Oct 10, 2021