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
Data Science Environment Setup in single line

datascienv is package that helps your to setup your environment in single line of code with all dependency and it is also include pyforest that provide single line of import all required ml libraries

Ashish Patel 55 Dec 16, 2022
This is an analysis and prediction project for house prices in King County, USA based on certain features of the house

This is a project for analysis and estimation of House Prices in King County USA The .csv file contains the data of the house and the .ipynb file con

Amit Prakash 1 Jan 21, 2022
Wafer Fault Detection - Wafer circleci with python

Wafer Fault Detection Problem Statement: Wafer (In electronics), also called a slice or substrate, is a thin slice of semiconductor, such as a crystal

Avnish Yadav 14 Nov 21, 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
Find exposed data in Azure with this public blob scanner

BlobHunter A tool for scanning Azure blob storage accounts for publicly opened blobs. BlobHunter is a part of "Hunting Azure Blobs Exposes Millions of

CyberArk 250 Jan 03, 2023
A real data analysis and modeling project - restaurant inspections

A real data analysis and modeling project - restaurant inspections Jafar Pourbemany 9/27/2021 This project represents data analysis and modeling of re

Jafar Pourbemany 2 Aug 21, 2022
A collection of learning outcomes data analysis using Python and SQL, from DQLab.

Data Analyst with PYTHON Data Analyst berperan dalam menghasilkan analisa data serta mempresentasikan insight untuk membantu proses pengambilan keputu

6 Oct 11, 2022
An Integrated Experimental Platform for time series data anomaly detection.

Curve Sorry to tell contributors and users. We decided to archive the project temporarily due to the employee work plan of collaborators. There are no

Baidu 486 Dec 21, 2022
MDAnalysis is a Python library to analyze molecular dynamics simulations.

MDAnalysis Repository README [*] MDAnalysis is a Python library for the analysis of computer simulations of many-body systems at the molecular scale,

MDAnalysis 933 Dec 28, 2022
MetPy is a collection of tools in Python for reading, visualizing and performing calculations with weather data.

MetPy MetPy is a collection of tools in Python for reading, visualizing and performing calculations with weather data. MetPy follows semantic versioni

Unidata 971 Dec 25, 2022
Investigating EV charging data

Investigating EV charging data Introduction: Got an opportunity to work with a home monitoring technology company over the last 6 months whose goal wa

Yash 2 Apr 07, 2022
Synthetic Data Generation for tabular, relational and time series data.

An Open Source Project from the Data to AI Lab, at MIT Website: https://sdv.dev Documentation: https://sdv.dev/SDV User Guides Developer Guides Github

The Synthetic Data Vault Project 1.2k Jan 07, 2023
First and foremost, we want dbt documentation to retain a DRY principle. Every time we repeat ourselves, we waste our time. Second, we want to understand column level lineage and automate impact analysis.

dbt-osmosis First and foremost, we want dbt documentation to retain a DRY principle. Every time we repeat ourselves, we waste our time. Second, we wan

Alexander Butler 150 Jan 06, 2023
Powerful, efficient particle trajectory analysis in scientific Python.

freud Overview The freud Python library provides a simple, flexible, powerful set of tools for analyzing trajectories obtained from molecular dynamics

Glotzer Group 195 Dec 20, 2022
First steps with Python in Life Sciences

First steps with Python in Life Sciences This course material is part of the "First Steps with Python in Life Science" three-day course of SIB-trainin

SIB Swiss Institute of Bioinformatics 22 Jan 08, 2023
This repo contains a simple but effective tool made using python which can be used for quality control in statistical approach.

This repo contains a powerful tool made using python which is used to visualize, analyse and finally assess the quality of the product depending upon the given observations

SasiVatsal 8 Oct 18, 2022
pyETT: Python library for Eleven VR Table Tennis data

pyETT: Python library for Eleven VR Table Tennis data Documentation Documentation for pyETT is located at https://pyett.readthedocs.io/. Installation

Tharsis Souza 5 Nov 19, 2022
Performance analysis of predictive (alpha) stock factors

Alphalens Alphalens is a Python Library for performance analysis of predictive (alpha) stock factors. Alphalens works great with the Zipline open sour

Quantopian, Inc. 2.5k Jan 09, 2023
Udacity-api-reporting-pipeline - Udacity api reporting pipeline

udacity-api-reporting-pipeline In this exercise, you'll use portions of each of

Fabio Barbazza 1 Feb 15, 2022
X-news - Pipeline data use scrapy, kafka, spark streaming, spark ML and elasticsearch, Kibana

X-news - Pipeline data use scrapy, kafka, spark streaming, spark ML and elasticsearch, Kibana

Nguyễn Quang Huy 5 Sep 28, 2022