intervals

Auto-Interval precision in MS Chart

跟風遠走 提交于 2019-11-30 08:30:24
I'm currently using the charting within .NET using System.Windows.Forms.DataVisualization.Charting.Chart . Thus far it seems very powerful, and works great. However, there is a huge problem in terms of how it is auto-calculating intervals. I use a lot of double values, and in libraries like ZedGraph, it handles this perfectly. It selects min/max/interval just fine. However, in MS Chart, it may select 206.3334539832 as a minimum, and intervals of a similar decimal precision. Obviously this looks quite ugly. So, I tried simply making the axis format {0.00} and it works great when it loads the

Group together arbitrary date objects that are within a time range of each other

我与影子孤独终老i 提交于 2019-11-30 07:01:24
问题 I want to split the calendar into two-week intervals starting at 2008-May-5 , or any arbitrary starting point. So I start with several date objects: import datetime as DT raw = ("2010-08-01", "2010-06-25", "2010-07-01", "2010-07-08") transactions = [(DT.datetime.strptime(datestring, "%Y-%m-%d").date(), "Some data here") for datestring in raw] transactions.sort() By manually analyzing the dates, I am quite able to figure out which dates fall within the same fortnight interval. I want to get

Parse and create ISO 8601 Date and time intervals, like PT15M in PHP

不问归期 提交于 2019-11-30 06:20:54
A library and webservice I am using communicates time-intervals in ISO 8601 format: PnYnMnDTnHnMnS . I want to convert such formats to seconds. And vice versa. Seconds are a lot easier to calculate with. Example interval values are: PT1M or PT60S (1 minute) PT1H, PT60M or PT3600S (1 hour) I need two functions: parse from such values to seconds: iso8601_interval_to_seconds() and from seconds into such intervals: iso8601_interval_from_seconds() . The latter is rather simple, because it could be done as `"PT{$seconds}S", just pass seconds along, at all times. Maybe this can be done nicer with a

Timing in JS - multiple setIntervals running at once and starting at the same time?

核能气质少年 提交于 2019-11-30 06:07:54
Let's say I have a function: myFunc = function(number) { console.log("Booyah! "+number); } And I want it to run on a set interval. Sounds like I should use setInterval , huh! But what if I want to run multiple intervals of the same function, all starting at the exact same time? setInterval(function(){ myFunc(1); }, 500); setInterval(function(){ myFunc(2); }, 1000); setInterval(function(){ myFunc(3); }, 2000); So that the first runs exactly twice in the time it takes the second to run once, and the same between the second and third. How do you make sure that they all start at the same time so

Partition into classes: jenks vs kmeans

此生再无相见时 提交于 2019-11-30 01:58:40
问题 I want to partition a vector (length around 10^5) into five classes. With the function classIntervals from package classInt I wanted to use style = "jenks" natural breaks but this takes an inordinate amount of time even for a much smaller vector of only 500. Setting style = "kmeans" executes almost instantaneously. library(classInt) my_n <- 100 set.seed(1) x <- mapply(rnorm, n = my_n, mean = (1:5) * 5) system.time(classIntervals(x, n = 5, style = "jenks")) R> system.time(classIntervals(x, n =

Python - Rounding by quarter-intervals

谁说胖子不能爱 提交于 2019-11-30 00:54:12
问题 I'm running into the following issue: Given various numbers like: 10.38 11.12 5.24 9.76 does an already 'built-in' function exists to round them up to the closest 0.25 step like e.g.: 10.38 --> 10.50 11.12 --> 11.00 5.24 --> 5.25 9.76 --> 9-75 ? Or can I go ahead and hack together a function that performs the desired task? Thanks in advance and with best regards Dan 回答1: >>> def my_round(x): ... return round(x*4)/4 ... >>> >>> assert my_round(10.38) == 10.50 >>> assert my_round(11.12) == 11

Run a function periodically in Scala

↘锁芯ラ 提交于 2019-11-29 22:55:23
I want to call an arbitrary function every n seconds. Basically I want something identical to SetInterval from Javascript. How can I achieve this in Scala? You could use standard stuff from java.util.concurrent : import java.util.concurrent._ val ex = new ScheduledThreadPoolExecutor(1) val task = new Runnable { def run() = println("Beep!") } val f = ex.scheduleAtFixedRate(task, 1, 1, TimeUnit.SECONDS) f.cancel(false) Or java.util.Timer : val t = new java.util.Timer() val task = new java.util.TimerTask { def run() = println("Beep!") } t.schedule(task, 1000L, 1000L) task.cancel() If you happen

How to match multiple columns in pandas DataFrame for an “interval”?

主宰稳场 提交于 2019-11-29 20:41:52
问题 I have the following pandas DataFrame: import pandas as pd df = pd.DataFrame('filename.csv') print(df) order start end value 1 1342 1357 category1 1 1459 1489 category7 1 1572 1601 category23 1 1587 1599 category2 1 1591 1639 category1 .... 15 792 813 category13 15 892 913 category5 .... So, there is an order column encompasses many rows each, and then a range/interval from start to end for each row. Each row then is labeled by a certain value (e.g. category1, category2, etc.) Now I have

Time interval in Java

偶尔善良 提交于 2019-11-29 16:47:19
how to call a method after a time interval? e.g if want to print a statement on screen after 2 second, what is its procedure? System.out.println("Printing statement after every 2 seconds"); The answer is using the javax.swing.Timer and java.util.Timer together: private static javax.swing.Timer t; public static void main(String[] args) { t = null; t = new Timer(2000,new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("Printing statement after every 2 seconds"); //t.stop(); // if you want only one print uncomment this line } }); java.util.Timer tt =

How to convert an interval like “1 day 01:30:00” into “25:30:00”?

人走茶凉 提交于 2019-11-29 16:33:08
问题 I need to add some intervals and use the result in Excel. Since sum(time.endtime-time.starttime) returns the interval as "1 day 01:30:00" and this format breaks my Excel sheet, I thought it'd be nice to have the output like "25:30:00" but found no way to do it in the PostgreSQL documentation. Can anyone here help me out? 回答1: Since there is not an exact solution for the topic: => SELECT date_part('epoch', INTERVAL '1 day 01:30:00') * INTERVAL '1 second' hours; hours ----------- 25:30:00 (1