Skip to main content

Temporally aware vector of values that can be aggregated using different methods over different time periods

Project description

Advanced Simulation: Temporal Vector

Description

This package was created to support Monte Carlo simulations that require 1-D numerical value vectors of data across time. The vectors are time-aware, and can be expanded or condensed to different time periods using different aggregation methods (max, min, cumulative). Update methods are provided to write the entire vector, update a specific range, or pass a list of index, range, value lines. Methods to add, multiply, and divide vectors are provided. For speed, the underlying vector is based on Numpy.

This is used to abstract the underlying vector functionality to make the simulation code simpler.

Getting Started

Download links:

SSH clone URL: ssh://git@git.jetbrains.space/cmckay/advanced-simulation/pkg_temporal_vector.git

HTTPS clone URL: https://git.jetbrains.space/cmckay/advanced-simulation/pkg_temporal_vector.git

How to use this package

Instantiating and using a vector:

import temporalvector.temporal_vector as tv
import temporalvector.temporal_enums as tve

# Create a vector with 1 day of duration, stored in hourly format, 
# with cumulative aggregation, 1 default value.  Further calls must recognize base vector is in Hour format
v = tv.TemporalVector(1, 
                      tve.VectorTimescales.Day, tve.VectorTimescales.Hour, 
                      tve.VectorAggregations.Cumulative, 1)

# this makes a numpy array of length 24, value of 1 

# retrieve the numpy vector values in days, and hours of duration (cumulative)
v_days = v.get(tve.VectorTimescales.Day)  # returns numpy array of length 1, value 24 (because cumulative aggregation)
v_hours = v.get(tve.VectorTimescales.Hour) # returns numpy array of length 24, value 1

# update the vector for the first 12 hours (index 0 to 11), so now half zeroes, half 1's
v.update_by_index(start_index=0, end_index=12, value=0, timescale=tve.VectorTimescales.Hour)

length = v.length(tve.VectorTimescales.Hour)

# update list to make first 12 hours 1, last 12 hour 0
bulk_update = [[0, 12, 1], [12, length - 1, 0]]
v.update_bulk(bulk_update, tve.VectorTimescales.Hour)

# Should return cumulative vector [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
v_cumulative = v.get_cumulative(tve.VectorTimescales.Hour)

Other VectorAggregations include Minimum and Maximum, if you want only the minimum and maximum values when updating the timescale on a vector.

Other functions

Multiply, divide, add, and subtract a vector. I didn't use overloading at this time because the functions are meant to be an in-place operation. Functions can accept a list, another TemporalVector, or a single value.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

temporalvector-0.1.0.tar.gz (15.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

temporalvector-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file temporalvector-0.1.0.tar.gz.

File metadata

  • Download URL: temporalvector-0.1.0.tar.gz
  • Upload date:
  • Size: 15.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for temporalvector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 087634123390191a736403f8e2938ada27464115b2686c3a947eae96ce41543a
MD5 e9a2835623db58ca4cb3f9b1c79c5a39
BLAKE2b-256 9e3b17c7c5868c7642513b6b4eccc338473471fedec4ce07163c144deb9b0578

See more details on using hashes here.

File details

Details for the file temporalvector-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: temporalvector-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for temporalvector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86565e7ff44246c6d553cf1ae20d00174bba0afe1bc11e012ea5bb91bf589aa4
MD5 0a0612e16c858a2a84bffde13d2de1f2
BLAKE2b-256 1c21bc200d85e3a4fbdbf6947dda13dfe24f246c1a48f525a192abe99b7cc4a0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page