Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/tiga1231/sgd2
08 April 2026, 17:08:34 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    No releases to show
  • 44ecc7e
  • /
  • utils
  • /
  • weight_schedule.py
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:e71c9d94d6850d88229a05215b4607b709476ebe
origin badgedirectory badge
swh:1:dir:ca52be72fa7bff082737dff0201a7cf2ceef2d06
origin badgerevision badge
swh:1:rev:13ca3d978626473e59fdddd641e457edc57208bc
origin badgesnapshot badge
swh:1:snp:139ff70469db38efd8ca16259dcc2fc37237cb74

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: 13ca3d978626473e59fdddd641e457edc57208bc authored by jack on 02 March 2022, 18:24:49 UTC
update OS note
Tip revision: 13ca3d9
weight_schedule.py
import bisect

##private
class LinearStepSchedule:
    def __init__(self, x0=0, x1=1.5e5, y0=1, y1=0.01):
        self.x0 = x0
        self.x1 = x1
        self.y0 = y0
        self.y1 = y1
        
    def __call__(self, x):
        x0,x1,y0,y1 = self.x0,self.x1,self.y0,self.y1
        if x <= x0:
            return y0
        if x0 < x <= x1:
            return (y1-y0)/(x1-x0) * (x-x0) + y0
        else:
            return y1

##private
class SmoothStepSchedule:
    ## y=3x^2-2x^3
    def __init__(self, x0=0, x1=1.5e5, y0=1, y1=0.01):
        self.x0 = x0
        self.x1 = x1
        self.y0 = y0
        self.y1 = y1
        
    def __call__(self, x):
        x0,x1,y0,y1 = self.x0,self.x1,self.y0,self.y1
        if x <= x0:
            return y0
        if x0 < x <= x1:
            x = (x-x0) / (x1-x0)
            y = 3*x**2 - 2*x**3
            y = y0 + y*(y1-y0)
            return y
        else:
            return y1
        
        
##private
class Concat:
    def __init__(self, *schedules):
        '''
        Assuming s1.x0 < s1.x1 < s2.x0 < s2.x1 < ...
        for schedules = [s1, s2, ...]
        '''
        self.schedules = schedules
#         self.xs = sum([[s.x0, s.x1] for s in schedules],[])
#         self.ys = sum([[s.y0, s.y1] for s in schedules],[])
        self.switches = [(s1.x1+s2.x0)/2 for s1,s2 in zip(schedules[:-1], schedules[1:])] 
    def __call__(self, x):
        i = bisect.bisect_left(self.switches, x)
        return self.schedules[i](x)
    
    
##public
class SmoothSteps:
    def __init__(self, xs, ys):
        self.xs = xs
        self.ys = ys
        self.schedule = Concat(*[
            SmoothStepSchedule(x0,x1,y0,y1) 
            for x0,x1,y0,y1 in zip(xs[:-1], xs[1:], ys[:-1], ys[1:])
        ])
        
    def __call__(self, x):
        return self.schedule(x)
    
##public
class LinearSteps:
    def __init__(self, xs, ys):
        self.xs = xs
        self.ys = ys
        self.schedule = Concat(*[
            LinearStepSchedule(x0,x1,y0,y1) 
            for x0,x1,y0,y1 in zip(xs[:-1], xs[1:], ys[:-1], ys[1:])
        ])
        
    def __call__(self, x):
        return self.schedule(x)

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API