Register
to be an Exhibitor
Apply
to be a Hosted Buyer
Toggle navigation
Home
About
Venue and Schedule
Attendees
Exhibitors
Visitors
List of Buyers
FAQs
Visitor
Visitor's Registration
Exhibit
Exhibitor Enquiry
Delhi
Mumbai
Hyderabad
Sponsorship and Promotion
FAQs
Testimonials
Seller's Testimonials
Buyer's Testimonials
Speaker's Testimonials
Hosted Buyer's Testimonials
Media
Image Gallery
Press
My Events
Log In


//= includes/head.html
//= ../blocks/header/header.html
//= ../blocks/no-page/no-page.html
//= ../blocks/main/main.html //= ../blocks/footer/footer.html //= includes/scripts.html


- 1. Introduction
- 2. Objects
- 3. Non Functional Attributes
- 4. Classes
1. Introduction
Reach is a web/Android based application that enables its users to locate events occurring within a radius around their current location.
The problem it solves is that, the ability to find events that are happening nearby within a short time is dependent on having a big network of friends to reach out to.
Often times this network is unreliable in the short term and Reach solves this problem by giving users an alternative to a reliance on their network of friends.
1.1 Purpose
This document is a framework for Reach. This document is intended for whoever would like to gain an in depth understanding of the application as well as Reach's development team.
2. Objects
2.1 Object Diagram
2.2 Entity Objects
- Event - event location and information posted by user
- User - user of Reach application
2.3 Control Objects
- Event Controller - Coordinates displaying event data to the user and the user changing event data
- Map Controller - Displays Events on the map to the User
- Profile Controller - Controls data related to the user
2.4 Boundary Objects
- Event Setting View - The interface for users to edit and Event
- Event Details View - The interface to display the properties of an Event
- Login View - The interface the User uses to login/create their account
- Map View - The actual map to display the Event
- Profile Setting View - The interface for hte user to chane their settings
3. Non Functional Attributes
- User will view map
- Events will appear on map
4. Classes


4.2 Strassen's algorithm for matrix multiplication
4.2-1
Use Strassen's algorithm to compute the matrix product
$$ \begin{pmatrix} 1 & 3 \\ 7 & 5 \end{pmatrix} \begin{pmatrix} 6 & 8 \\ 4 & 2 \end{pmatrix} . $$
Show your work.
The first matrices are
$$ \begin{array}{ll} S_1 = 6 & S_6 = 8 \\ S_2 = 4 & S_7 = -2 \\ S_3 = 12 & S_8 = 6 \\ S_4 = -2 & S_9 = -6 \\ S_5 = 6 & S_{10} = 14. \end{array} $$
The products are
$$ \begin{aligned} P_1 & = 1 \cdot 6 = 6 \\ P_2 & = 4 \cdot 2 = 8 \\ P_3 & = 6 \cdot 12 = 72 \\ P_4 & = -2 \cdot 5 = -10 \\ P_5 & = 6 \cdot 8 = 48 \\ P_6 & = -2 \cdot 6 = -12 \\ P_7 & = -6 \cdot 14 = -84. \end{aligned} $$
The four matrices are
$$ \begin{aligned} C_{11} & = 48 + (-10) - 8 + (-12) = 18 \\ C_{12} & = 6 + 8 = 14 \\ C_{21} & = 72 + (-10) = 62 \\ C_{22} & = 48 + 6 - 72 - (-84) = 66. \end{aligned} $$
The result is
$$ \begin{pmatrix} 18 & 14 \\ 62 & 66 \end{pmatrix} . $$
4.2-2
Write pseudocode for Strassen's algorithm.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | STRASSEN(A, B) n = A.rows if n == 1 return a[1, 1] * b[1, 1] let C be a new n × n matrix A[1, 1] = A[1..n / 2][1..n / 2] A[1, 2] = A[1..n / 2][n / 2 + 1..n] A[2, 1] = A[n / 2 + 1..n][1..n / 2] A[2, 2] = A[n / 2 + 1..n][n / 2 + 1..n] B[1, 1] = B[1..n / 2][1..n / 2] B[1, 2] = B[1..n / 2][n / 2 + 1..n] B[2, 1] = B[n / 2 + 1..n][1..n / 2] B[2, 2] = B[n / 2 + 1..n][n / 2 + 1..n] S[1] = B[1, 2] - B[2, 2] S[2] = A[1, 1] + A[1, 2] S[3] = A[2, 1] + A[2, 2] S[4] = B[2, 1] - B[1, 1] S[5] = A[1, 1] + A[2, 2] S[6] = B[1, 1] + B[2, 2] S[7] = A[1, 2] - A[2, 2] S[8] = B[2, 1] + B[2, 2] S[9] = A[1, 1] - A[2, 1] S[10] = B[1, 1] + B[1, 2] P[1] = STRASSEN(A[1, 1], S[1]) P[2] = STRASSEN(S[2], B[2, 2]) P[3] = STRASSEN(S[3], B[1, 1]) P[4] = STRASSEN(A[2, 2], S[4]) P[5] = STRASSEN(S[5], S[6]) P[6] = STRASSEN(S[7], S[8]) P[7] = STRASSEN(S[9], S[10]) C[1..n / 2][1..n / 2] = P[5] + P[4] - P[2] + P[6] C[1..n / 2][n / 2 + 1..n] = P[1] + P[2] C[n / 2 + 1..n][1..n / 2] = P[3] + P[4] C[n / 2 + 1..n][n / 2 + 1..n] = P[5] + P[1] - P[3] - P[7] return C |
4.2-3
How would you modify Strassen's algorithm to multiply $n \times n$ matrices in which $n$ is not an exact power of $2$? Show that the resulting algorithm runs in time $\Theta(n^{\lg7})$.
We can just extend it to an $n \times n$ matrix and pad it with zeroes. It's obviously $\Theta(n^{\lg7})$.
4.2-4
What is the largest $k$ such that if you can multiply $3 \times 3$ matrices using $k$ multiplications (not assuming commutativity of multiplication), then you can multiply $n \times n$ matrices is time $o(n^{\lg 7})$? What would the running time of this algorithm be?
Assume $n = 3^m$ for some $m$. Then, using block matrix multiplication, we obtain the recursive running time $T(n) = kT(n / 3) + O(1)$.
By master theorem, we can find the largest $k$ to satisfy $\log_3 k < \lg 7$ is $k = 21$.
4.2-5
V. Pan has discovered a way of multiplying $68 \times 68$ matrices using $132464$ multiplications, a way of multiplying $70 \times 70$ matrices using $143640$ multiplications, and a way of multiplying $72 \times 72$ matrices using $155424$ multiplications. Which method yields the best asymptotic running time when used in a divide-and-conquer matrix-multiplication algorithm? How does it compare to Strassen's algorithm?
Using what we know from the last exercise, we need to pick the smallest of the following
$$ \begin{aligned} \log_{68} 132464 & \approx 2.795128 \\ \log_{70} 143640 & \approx 2.795122 \\ \log_{72} 155424 & \approx 2.795147. \end{aligned} $$
The fastest one asymptotically is $70 \times 70$ using $143640$.
4.2-6
How quickly can you multiply a $kn \times n$ matrix by an $n \times kn$ matrix, using Strassen's algorithm as a subroutine? Answer the same question with the order of the input matrices reversed.
- $(kn \times n)(n \times kn)$ produces a $kn \times kn$ matrix. This produces $k^2$ multiplications of $n \times n$ matrices.
- $(n \times kn)(kn \times n)$ produces an $n \times n$ matrix. This produces $k$ multiplications and $k - 1$ additions.
4.2-7
Show how to multiply the complex numbers $a + bi$ and $c + di$ using only three multiplications of real numbers. The algorithm should take $a$, $b$, $c$ and $d$ as input and produce the real component $ac - bd$ and the imaginary component $ad + bc$ separately.
The three matrices are
$$ \begin{aligned} A & = (a + b)(c + d) = ac + ad + bc + bd \\ B & = ac \\ C & = bd. \end{aligned} $$
The result is
$$(B - C) + (A - B - C)i.$$


The settings charm window is hidden by default. Swipe the right edge of the screen and select Settings to invoke it.
Observe the contents of the settings charm window. Select the Permissions link and observe info about the app capabilities extracted from the app’s package manifest.
This sample declares capabilities for illustration purposes that are not actually used. You should only declare capabilities that your app uses.


| Book of Mormon |
Annotations |
|
Chapter 13
|
|
|
1 And again, my brethren, I would cite your minds forward
to the time when the Lord God gave these commandments unto his children; and
I would that ye should remember that the Lord God ordained priests, after his
holy order, which was after the order of his Son, to teach these things unto
the people.
|
|
|
2 And those priests were ordained after the order of his
Son, in a manner that thereby the people might know in what manner to look
forward to his Son for redemption.
|
|
|
3 And this is the manner after which they were
ordained—being called and prepared from the foundation of the world according
to the foreknowledge of God, on account of their exceeding faith and
good works; in the first place being left to choose good or evil; therefore
they having chosen good, and exercising exceedingly great faith, are
called with a holy calling, yea, with that holy calling which was
prepared with, and according to, a preparatory redemption for such.
|
The Church teaches that God foretells based on his
foreknowledge, and that there is no predestination, but what’s the difference
unless the Church wants to admit that God could foretell things incorrectly?
29 For him whom he did foreknow, he also did
predestinate to be conformed to his own image, that he might be the firstborn
among many brethren.
30 Moreover, him whom he did predestinate, him
he also called and him whom he called, him he also sanctified and him whom he
sanctified, him he also glorified
(JST, Romans 8).
(See also 2 Ne 9:20, Words of Mormon 1:7, Moroni 7:22)
|
|
4 And thus they have been called to this holy calling on
account of their faith, while others would reject the Spirit of God on
account of the hardness of their hearts and blindness of their minds, while,
if it had not been for this they might have had as great privilege as their
brethren.
|
|
|
5 Or in fine, in the first place they were on the same
standing with their brethren; thus this holy calling being prepared from the
foundation of the world for such as would not harden their hearts, being in
and through the atonement of the Only Begotten Son, who was prepared—
|
|
|
6 And thus being called by this holy calling, and ordained
unto the high priesthood of the holy order of God, to teach his commandments
unto the children of men, that they also might enter into his rest—
|
|
|
7 This high priesthood being after the order of his Son,
which order was from the foundation of the world; or in other words, being
without beginning of days or end of years, being prepared from eternity to
all eternity, according to his foreknowledge of all things—
|
|
|
8 Now they were ordained after this manner—being called
with a holy calling, and ordained with a holy ordinance, and taking upon them
the high priesthood of the holy order, which calling, and ordinance, and high
priesthood, is without beginning or end—
|
|
|
9 Thus they become high priests forever, after the order
of the Son, the Only Begotten of the Father, who is without beginning of days
or end of years, who is full of grace, equity, and truth. And thus it is.
Amen.
|
|
|
10 Now, as I said concerning the holy order, or this high
priesthood, there were many who were ordained and became high priests of God;
and it was on account of their exceeding faith and repentance, and their
righteousness before God, they choosing to repent and work righteousness
rather than to perish;
|
|
|
11 Therefore they were called after this holy order, and
were sanctified, and their garments were washed white through the blood of
the Lamb.
|
|
|
12 Now they, after being sanctified by the Holy Ghost,
having their garments made white, being pure and spotless before God, could
not look upon sin save it were with abhorrence; and there were many,
exceedingly great many, who were made pure and entered into the rest of the
Lord their God.
|
|
|
13 And now, my brethren, I would that ye should humble
yourselves before God, and bring forth fruit meet for repentance, that ye may
also enter into that rest.
|
|
|
14 Yea, humble yourselves even as the people in the days
of Melchizedek, who was also a high priest after this same order which I have
spoken, who also took upon him the high priesthood forever.
|
|
|
15 And it was this same Melchizedek to whom Abraham paid
tithes; yea, even our father Abraham paid tithes of one-tenth part of all he
possessed.
|
|
|
16 Now these ordinances were given after this manner, that
thereby the people might look forward on the Son of God, it being a type of
his order, or it being his order, and this that they might look forward to
him for a remission of their sins, that they might enter into the rest of the
Lord.
|
|
|
17 Now this Melchizedek was a king over the land of Salem;
and his people had waxed strong in iniquity and abomination; yea, they had
all gone astray; they were full of all manner of wickedness;
|
|
|
18 But Melchizedek having exercised mighty faith, and
received the office of the high priesthood according to the holy order of
God, did preach repentance unto his people. And behold, they did repent; and
Melchizedek did establish peace in the land in his days; therefore he was
called the prince of peace, for he was the king of Salem; and he did reign
under his father.
|
|
|
19 Now, there were many before him, and also there were
many afterwards, but none were greater; therefore, of him they have more
particularly made mention.
|
|
|
20 Now I need not rehearse the matter; what I have said
may suffice. Behold, the scriptures are before you; if ye will wrest them it
shall be to your own destruction.
|
|
|
21 And now it came to pass that when Alma had said these
words unto them, he stretched forth his hand unto them and cried with a
mighty voice, saying: Now is the time to repent, for the day of salvation
draweth nigh;
|
|
|
22 Yea, and the voice of the Lord, by the mouth of angels,
doth declare it unto all nations; yea, doth declare it, that they may have
glad tidings of great joy; yea, and he doth sound these glad tidings among
all his people, yea, even to them that are scattered abroad upon the face of
the earth; wherefore they have come unto us.
|
|
|
23 And they are made known unto us in plain terms, that we
may understand, that we cannot err; and this because of our being wanderers
in a strange land; therefore, we are thus highly favored, for we have these
glad tidings declared unto us in all parts of our vineyard.
|
|
|
24 For behold, angels are declaring it unto many at this
time in our land; and this is for the purpose of preparing the hearts of the
children of men to receive his word at the time of his coming in his glory.
|
|
|
25 And now we only wait to hear the joyful news declared
unto us by the mouth of angels, of his coming; for the time cometh, we know
not how soon. Would to God that it might be in my day; but let it be sooner
or later, in it I will rejoice.
|
|
|
26 And it shall be made known unto just and holy men, by
the mouth of angels, at the time of his coming, that the words of our fathers
may be fulfilled, according to that which they have spoken concerning him,
which was according to the spirit of prophecy which was in them.
|
|
|
27 And now, my brethren, I wish from the inmost part of my
heart, yea, with great anxiety even unto pain, that ye would hearken unto my
words, and cast off your sins, and not procrastinate the day of your
repentance;
|
|
|
28 But that ye would humble yourselves before the Lord,
and call on his holy name, and watch and pray continually, that ye may not be
tempted above that which ye can bear, and thus be led by the Holy Spirit,
becoming humble, meek, submissive, patient, full of love and all
long-suffering;
|
|
|
29 Having faith on the Lord; having a hope that ye shall
receive eternal life; having the love of God always in your hearts, that ye
may be lifted up at the last day and enter into his rest.
|
|
|
30 And may the Lord grant unto you repentance, that ye may
not bring down his wrath upon you, that ye may not be bound down by the
chains of hell, that ye may not suffer the second death.
|
|
|
31 And Alma spake many more words unto the people, which
are not written in this book.
|
|


const ( // Anything is used in Diff and Assert when the argument being tested // shouldn't be taken into consideration. Anything = "mock.Anything" )
func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool
AssertExpectationsForObjects asserts that everything specified with On and Return of the specified objects was in fact called as expected.
Calls may have occurred in any order.
func MatchedBy(fn interface{}) argumentMatcher
MatchedBy can be used to match a mock call based on only certain properties from a complex struct or some calculation. It takes a function that will be evaluated with the called argument and will return true when there's a match and false otherwise.
Example: m.On("Do", MatchedBy(func(req *http.Request) bool { return req.Host == "example.com" }))
|fn|, must be a function accepting a single argument (of the expected type) which returns a bool. If |fn| doesn't match the required signature, MatchedBy() panics.
AnythingOfTypeArgument is a string that contains the type of an argument for use when type checking. Used in Diff and Assert.
type AnythingOfTypeArgument string
func AnythingOfType(t string) AnythingOfTypeArgument
AnythingOfType returns an AnythingOfTypeArgument object containing the name of the type to check for. Used in Diff and Assert.
For example:
Assert(t, AnythingOfType("string"), AnythingOfType("int"))
Arguments holds an array of method arguments or return values.
type Arguments []interface{}
func (args Arguments) Assert(t TestingT, objects ...interface{}) bool
Assert compares the arguments with the specified objects and fails if they do not exactly match.
func (args Arguments) Bool(index int) bool
Bool gets the argument at the specified index. Panics if there is no argument, or if the argument is of the wrong type.
func (args Arguments) Diff(objects []interface{}) (string, int)
Diff gets a string describing the differences between the arguments and the specified objects.
Returns the diff string and number of differences found.
func (args Arguments) Error(index int) error
Error gets the argument at the specified index. Panics if there is no argument, or if the argument is of the wrong type.
func (args Arguments) Get(index int) interface{}
Get Returns the argument at the specified index.
func (args Arguments) Int(index int) int
Int gets the argument at the specified index. Panics if there is no argument, or if the argument is of the wrong type.
func (args Arguments) Is(objects ...interface{}) bool
Is gets whether the objects match the arguments specified.
func (args Arguments) String(indexOrNil ...int) string
String gets the argument at the specified index. Panics if there is no argument, or if the argument is of the wrong type.
If no index is provided, String() returns a complete string representation of the arguments.
Call represents a method call and is used for setting expectations, as well as recording activity.
type Call struct { Parent *Mock // The name of the method that was or will be called. Method string // Holds the arguments of the method. Arguments Arguments // Holds the arguments that should be returned when // this method is called. ReturnArguments Arguments // The number of times to return the return arguments when setting // expectations. 0 means to always return the value. Repeatability int // Holds a channel that will be used to block the Return until it either // receives a message or is closed. nil means it returns immediately. WaitFor <-chan time.Time // Holds a handler used to manipulate arguments content that are passed by // reference. It's useful when mocking methods such as unmarshalers or // decoders. RunFn func(Arguments) // contains filtered or unexported fields }
func (c *Call) After(d time.Duration) *Call
After sets how long to block until the call returns
Mock.On("MyMethod", arg1, arg2).After(time.Second)
func (c *Call) Maybe() *Call
Maybe allows the method call to be optional. Not calling an optional method will not cause an error while asserting expectations
func (c *Call) On(methodName string, arguments ...interface{}) *Call
On chains a new expectation description onto the mocked interface. This allows syntax like.
Mock. On("MyMethod", 1).Return(nil). On("MyOtherMethod", 'a', 'b', 'c').Return(errors.New("Some Error"))
go:noinline
func (c *Call) Once() *Call
Once indicates that that the mock should only return the value once.
Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Once()
func (c *Call) Return(returnArguments ...interface{}) *Call
Return specifies the return arguments for the expectation.
Mock.On("DoSomething").Return(errors.New("failed"))
func (c *Call) Run(fn func(args Arguments)) *Call
Run sets a handler to be called before returning. It can be used when mocking a method such as unmarshalers that takes a pointer to a struct and sets properties in such struct
Mock.On("Unmarshal", AnythingOfType("*map[string]interface{}").Return().Run(func(args Arguments) { arg := args.Get(0).(*map[string]interface{}) arg["foo"] = "bar" })
func (c *Call) Times(i int) *Call
Times indicates that that the mock should only return the indicated number of times.
Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Times(5)
func (c *Call) Twice() *Call
Twice indicates that that the mock should only return the value twice.
Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Twice()
func (c *Call) WaitUntil(w <-chan time.Time) *Call
WaitUntil sets the channel that will block the mock's return until its closed or a message is received.
Mock.On("MyMethod", arg1, arg2).WaitUntil(time.After(time.Second))
Mock is the workhorse used to track activity on another object. For an example of its usage, refer to the "Example Usage" section at the top of this document.
type Mock struct { // Represents the calls that are expected of // an object. ExpectedCalls []*Call // Holds the calls that were made to this mocked object. Calls []Call // contains filtered or unexported fields }
func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interface{}) bool
AssertCalled asserts that the method was called. It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method.
func (m *Mock) AssertExpectations(t TestingT) bool
AssertExpectations asserts that everything specified with On and Return was in fact called as expected. Calls may have occurred in any order.
func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...interface{}) bool
AssertNotCalled asserts that the method was not called. It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method.
func (m *Mock) AssertNumberOfCalls(t TestingT, methodName string, expectedCalls int) bool
AssertNumberOfCalls asserts that the method was called expectedCalls times.
func (m *Mock) Called(arguments ...interface{}) Arguments
Called tells the mock object that a method has been called, and gets an array of arguments to return. Panics if the call is unexpected (i.e. not preceded by appropriate .On .Return() calls) If Call.WaitFor is set, blocks until the channel is closed or receives a message.
func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Arguments
MethodCalled tells the mock object that the given method has been called, and gets an array of arguments to return. Panics if the call is unexpected (i.e. not preceded by appropriate .On .Return() calls) If Call.WaitFor is set, blocks until the channel is closed or receives a message.
func (m *Mock) On(methodName string, arguments ...interface{}) *Call
On starts a description of an expectation of the specified method being called.
Mock.On("MyMethod", arg1, arg2)
func (m *Mock) Test(t TestingT)
Test sets the test struct variable of the mock object
func (m *Mock) TestData() objx.Map
TestData holds any data that might be useful for testing. Testify ignores this data completely allowing you to do whatever you like with it.
TestingT is an interface wrapper around *testing.T
type TestingT interface { Logf(format string, args ...interface{}) Errorf(format string, args ...interface{}) FailNow() }


There is so much going on at Bahari Beach Hotel – you will be spoilt for choice
In the daytime activities at the hotel include snorkling,diving, water aerobics, water volleyball and basketball, beach volleyball, squash, table tennis or pool. Outside of the hotel, there are local attractions not too far away, which are a must for the cultural enthusiast. Whatever you choose to do, our Animation Team will organise the best experience for you. If your children don’t want to do the same as you, we have a qualified team to look after your children at our Kid’s Club. In the evening, there are always a vast range of evening activities from discos to cabaret shows.


A simple script to test how to simulate CCD bleeding effects.
| requires: | PyFITS |
|---|---|
| requires: | NumPy |
| author: | Sami-Matias Niemi |
| contact: |<EMAIL_ADDRESS>|
Writes out a simple FITS file.
| Parameters: |
|
|---|---|
| Returns: | None |
A simple script to convert Zemax text file output to FITS format. Copies the meta to the header.
| requires: | PyFITS |
|---|---|
| requires: | NumPy |
| version: | 0.1 |
| author: | Sami-Matias Niemi |
| contact: |<EMAIL_ADDRESS>|
Converts Zemax output TXT file to FITS format. Stores the extra information from the Zemax output to the FITS header.
| Parameters: |
|
|---|---|
| Returns: | None |
A simple script to generate a random location cosmetics map.
| requires: | NumPy |
|---|---|
| author: | Sami-Matias Niemi |
| contact: |<EMAIL_ADDRESS>|
Generates a cosmetics catalogue with dead and hot pixels with random locations. The default numbers have been taken from MSSL/Euclid/TR/12003 Issue 2 Draft b.
Results are written to a CSV file.
| Parameters: |
|
|---|---|
| Returns: | None |
This simple class can be used to include cosmic ray events to an image. By default the cosmic ray events are drawn from distributions describing the length and energy of the events. Such distributions can be generated for example using Stardust code (http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=04636917). The energy of the cosmic ray events can also be set to constant for testing purposes. The class can be used to draw a single cosmic ray event or up to a covering fraction.
| requires: | NumPy |
|---|---|
| requires: | SciPy |
| version: | 0.2 |
| author: | Sami-Matias Niemi |
| contact: |<EMAIL_ADDRESS>|
Cosmic ray generation class. Can either draw events from distributions or set the energy of the events to a constant.
| Parameters: |
|
|---|
Include cosmic rays to the image given.
| Returns: | image with cosmic rays |
|---|---|
| Return type: | ndarray |
Include a single cosmic ray event to the image given.
| Returns: | image with cosmic rays |
|---|---|
| Return type: | ndarray |
Add cosmic ray events up to the covering Fraction.
| Parameters: |
|
|---|---|
| Returns: | image with cosmic rays |
| Return type: | ndarray |
Basic image manipulation algorithms such as Gaussian smoothing and free rebinning.
| requires: | NumPy |
|---|---|
| requires: | SciPy |
| author: | Sami-Matias Niemi |
| contact: |<EMAIL_ADDRESS>|
| version: | 0.1 |
blurs the image by convolving with a gaussian kernel of typical size np. The optional keyword argument ny allows for a different size in the y direction.
Arbitrary resampling of source array to new dimension sizes. Currently only supports maintaining the same number of dimensions. To use 1-D arrays, first promote them to shape (x,1).
Uses the same parameters and creates the same co-ordinate lookup points as IDL’’s congrid routine, which apparently originally came from a VAX/VMS routine of the same name.
method: neighbour - closest value from original data nearest and linear - uses n x 1-D interpolations using scipy.interpolate.interp1d (see Numerical Recipes for validity of use of n 1-D interpolations) spline - uses ndimage.map_coordinates
centre: True - interpolation points are at the centres of the bins False - points are at the front edge of the bin
minusone: For example- inarray.shape = (i,j) & new dimensions = (x,y) False - inarray is resampled by factors of (i/x) * (j/y) True - inarray is resampled by(i-1)/(x-1) * (j-1)/(y-1) This prevents extrapolation one element beyond bounds of input array.
Shrink or expand the size of an array an arbitary amount using interpolation. Conserves flux by ensuring that each input pixel is equally represented in the output array.
Todo
one could do the binning faster if old and new outputs are modulo 0
Note
modelled after the IDL code frebin.pro, so this may not be the fastest solution
| Parameters: |
|
|---|---|
| Returns: | binned array |
| Return type: | ndarray |
Returns a normalized 2D gauss kernel array for convolutions.
rebin ndarray data into a smaller ndarray of the same rank whose dimensions are factors of the original dimensions. eg. An array with 6 columns and 4 rows can be reduced to have 6,3,2 or 1 columns and 4,2 or 1 rows. example usages: >>> a=rand(6,4); b=rebin(a,3,2) >>> a=rand(6); b=rebin(a,2)


This page contains the notes for R Workshop Module 1: Introduction to R, which is part of the R Workshop series prepared by ICJIA Research Analyst Bobae Kang to enable and encourage ICJIA researchers to take advantage of R, a statistical programming language that is one of the most powerful modern research tools.
My name is Bobae Kang and I am a Research Analyst at ICJIA. I have been using R for approximately one year and a half at the time of writing, and I believe that R is one of the most powerful modern computational tools for research and data analysis. I have developed this workshop to invite my colleagues and fellow researchers at ICJIA to start taking advantage of this amazing tool. See About Me to read more about me.
Workshop objectives
This workshop is developed to offer a gentle introduction to the R programming language for ICJIA researchers. More specifically, the goal of this workshop is to enable and empower its participants to:
Import and manipulate tabular data files using R;
Create simple data visualizations (scatterplot, histogram, bar chart, line chart, etc.) to extract insight from data using R;
Perform basic statistical analysis using R;
Generate a report on a simple data analysis task using R;
Understand the basic elements of the R programming language;
Employ the programmatic approach to research and data analysis projects; and
Leverage online resources to find solutions to specific questions on using R for a given task.
Of course, mastering any of the listed skills requires more than this workshop. This workshop alone will not make any of its participants an expert R programmer. However, it will help the participants to get started and provide them with the basic skills and techniques in using R for research and data analysis. Ultimately, this workshop seeks to help the participants to gain the knowledge and confidence necesary to learn what they need to know for their own research projects.
Among the core objectives of this workshop is to convince its participants to try a different approach to research: a programming (or programmatic) approach.
Many researchers and analysts rely on “graphical user interface” (GUI) tools; a lot of point-and-clicks and drag-and-drops happens with such tools. This is understandable since GUI tools offer a highly intuitive way of interacting with data. Also, learning a programming language often appears to be a daunting task to many with little to no prior experience in programming. However, adopting a programming approach has strong advantages that could far outweigh the pain of learning it–which, by the way, can be fun as well!
GUI workflow vs. programmatic workflow
Before discussing specific advantages of the programmatic approach to research, let us compare two different workflows–one dependent on GUI tools, and the other programmatic–with examples.
Here we introduce two reserchers:
Sterling Malory Archer is an ICJIA research analyst who relies almost explicitly on the GUI tools for his research projects.
Lana Anthony Kane, another ICJIA research analyst, has adopted a programming approach to research.
Let us now compare how these two work differently for a simple data analysis project.
Sterling, a typical GUI-oriented workflow
Sterling finds out that he needs Uniform Crime Reports (UCR) data from Illinois State Police (ISP) website for his project. In fact, he needs data for the five most recent years He goes to the website and download each file separately, which lands on the default Downloads folder.
Sterling browses to the Downloads folder and opens the files in MS Excel:
Sterling wants to have data for all years in a single spreadsheet. So he copy pastes multiple times to have all in the same place.
Sterling then realizes that he needs only a few variables for his analysis. He deletes all columns but the ones he needs, and saves it (mydata.xlsx) to the research directory that he creates as he is saving the combined data file.
Sterling opens the combined data in SPSS:
Sterling runs a quick regression analysis and checks the results. The model fit doesn’t look good–oops, he should have included another variable in the model.
Sterling so goes back to the Downloads folder for the original files, spends some minutes to find the downloaded files (there are so many files in the Downloads folder!), opens all spreadsheets in Excel, and copy-and-pastes the desired column from them to the combined spreadsheet. He saves it as a separate file (mydata2.xlsx).
Sterling opens the updated data file in SPSS and runs the model again with more point-and-clicks. Finally, the results look good.
Sterling opens MS Word to write a report on his model output.
He copy-and-pastes the model outputs and graphs from the SPSS report to the Word document.
Sterling sends the report to his supervisor. Done!
If his supervisor later comes to Sterling and asks him how he came to his conclusion, will Sterling remember all the steps he took?
Lana, a programmatic workflow
Before anything, Lana sets up a directory specifically for the project at hand and creates some sub-directories where different types of inputs and outputs will be stored. From past experience, Lana knows that she needs at lease the following sub-directories:
data: to store data inputs
images: to store image outputs
reports: to store report outputs
Lana goes to the ISP website to find where the UCR data files are located. Then she writes a program to download and store them to the data subdirectory–all at once! She saves the R scrpt for the current program in the main directory.
Lana writes a separate program that imports the data files and combines them into a single table. Then she takes a closer look at the table to identify which variables she needs, and writes a few more lines of code to select only the corresponding columns and save the modified version of data table into the data folder. Again, she saves the R script in the main directory.
Lana creates another separate program, which imports the clean data file, fits a regression model, and generates some nice-looking plots. The plots are saved in the images folder.
Oops, the model fit does not look good. She should have included another variable. Lana goes back to the tab for the data cleaning script and, by tweaking a few lines in her code, quickly re-creates the data file.
Lana then comes back to the modeling script tab and, without changing a single line of code, simply re-runs it to get satisfying regression results and plots.
She saves the script in the main directory.
Lana creates a R Markdown file for her report. Since R Markdown can easily incorporate R code, no need to copy-and-paste the results. Lana knits the report into a nice-looking html document, now saved in reports subdirectory. The R Markdown script is also saved.
Lana sends the report to her supervisor with a link to her project directory. Done!
If the supervisor later comes back to Lana and questions how she came to her conclusion, everything is there and she has nothing to hide!
Benefits of a programming approach
Automation
At its core, a programming approach to research seeks for automating the work of research as much as possible. In practice, automation means implementing the research work in programs (e.g., R script files), which will run later to automatically execute the work. This is opposite to the GUI-based approach where each and every step of the research process takes place in an interactive fashion. By automating certain tasks, a researcher can rest assured that she will get consistent results when she revisit her work or share it with others.
Modularity
In software design, modularity refers to a logical partitioning of the “software design” that allows complex software to be manageable for the purpose of implementation and maintenance. - “Modularity”, Wikipedia
A programming approach to research enables researchers to acheive a great degree of modularity, where a researcher can break down different stages or steps of research work into smaller but meaningful parts. In our example, this is shown by Lana’s writing separate programs for collecting, clearning, and analyzing her data. The benefit of modularity is clear here. When Lana had to make changes on her data clearning, she only had to change the part of the program that is relevant to the change while leaving everything else pretty much intact–a great gain in efficiency.
In fact, a researcher may accomplish a greater degree of modularity, for instance, by writing custom functions that can be reused in various steps of the project–or even in another project!
Reproducibiltiy
Reproducibility refers to the ability of a researcher to duplicate the results of a prior study using the same materials and procedures as were used by the original investigator. […] Reproducibility is a minimum necessary condition for a finding to be believable and informative. - U.S. NSF Subcommittee on Replicability in Science
Although it may be possible to ensure reproducibility with a GUI-oriented approach it is no less than an uphill battle, since each step in the procedure has to be documented thoroughly and separately. Also, there is little guarantee that researchers who come later will follow the directions strictly as intended by the original researcher. In contrast, the work of research stored in a program, or a set of programs, is highly reproducible. Replicating such a work does not rely on human interpretation of the documented procedure. Rather, the computer simply and faithfully follows the directions inscribed in the program.
A high degree of reproducibility can also greatly enhance productivity in a collaborative project. Its co-researchers can simply share the code that has all the information about what steps to take, which leaves little room to the possibility of miscommunication while allowing the researchers to focus on what is important.
Version control
The notion of version control refers to the practice of managing changes in a document or a program in a systematic fashion. One major benefit of version control is that it can protect the work of research from unwanted changes, such as mistakenly deleting files, as such changes can be easily identified and reverted.
Although the topic of version control is beyond the scope of this workshop, suffice it to note that a programming approach to research makes it easy to implement version control in research as there exist many excellent version control systems available free of charge. Git is the most popular of such systems; read its documentation to learn more about Git.
“R is a language and environment for statistical computing and graphics.” - The R Foundation
Built for data analysis and visualization
One of the the most popular choices of programming language among academic researchers and data scientists
The following figure captures the growth of R in the recent years, compared to other programming languages. Although the data used to generate this figure does not provide the whole picture, it certainly reflects the reality where R has established itself as one of the most popular tool for researchers and data analysts.
Being open source also means that its source code, much of which is written in C and Fortran as well as R itself, is open for anyone to review and (albeit rarely) contribute.
Built for statistical analysis
R, at its very core, is designed for statistical computing. As such, a wide range of statistical and graphical techniques, which are often offered as preminum add-ons in other commercial tools, are part of the language’s core pacakge.
Reproducible and transparent
Saving one’s R code as an R script can be used to easily reproduce any data manipulation and analysis, ensuring the maximal clarity regarding which inputs are used for analysis and which steps are taken to generate the output. Collaborators can share their work in the R script format to quickly reach a shared understanding of the progress.
As stated above, R is an open source. This open-source nature of R gives the language the level of transparency that other commercial softwares cannot afford. Also most of R packages are also open source, making it possible for any interested user to see precisely how things work under the hood.
Extensible through powerful third-party packages
Supported by its active user community
The strong R community is often considered as one of the key advantages of using the language.2
Enabling researchers to tackle a variety of tasks using a single platform
Data manipulation and analyiss
Basic and advanced statistical modeling
Publication-ready data visualization
Generating reports in various formats (html webpage, MS word, PDF)
Slideshows, websites, interactive dashboards, etc.
Comparisons
R vs MS Excel
License cost
Although often taken for granted, the MS Office Suite is in fact not free. In contrast, R is free. (Of course, this may be a moot point since other MS Office Suite products are well loved and widely used on daily basis.)
Speed and scalability
Excel is slow, and its performance quickly deteriorates as the data size grows. R offers many tools highly optimized to work with large data.
Excel has limits on the number of rows and columns on a worksheet (1,048,576 rows by 16,384 columns). R does not.
Visualization
While Excel provides some basic visualzation options, it is difficult in Excel to create highly customized and publication-quality plots. R can achieve this with only several lines of code.
Complex and advanced analysis
Data manipulation capability of R is simply superior to that of Excel.
Although Excel does offer a variety of built-in functions for data analysis to many people’s surprise, users are still limited to the built-in options. Not only R comes with advanced data analysis functionalities, they can also be easily exended with add-on pacakges.
Reproducibility
Reproducibility can be achieved in Excel to only a limited extent, any marginally complex analysis in Excel becomes extremely difficult to reproduce.
R vs IBM SPSS
License cost (again)
At the time of writing, the Base pricing option for SPSS is $99 per user per month. In addition, add-ons for other advanced functionalities must be purchased separately.3R is free.
Syntax
SPSS provides Syntax to programmatically perform data clearing, analysis and statistical modeling tasks. However, it is often noted that the grammatical/syntactic structure of SPSS Syntax is difficult to use (especially for complex operations) and often at odds with the programming standards in general.4 R, on the other hand, follows much of the standard grammar of modern programming languages. In addition, many tutorials on the basics of R language are readily available.
Visualization
Although SPSS offers basic visualization options for commonly used charts and graphs, just as in Excel, only minimal customization is available and the outputs are little better than Excel graphs.
Reporting
SPSS is capable for quickly generating a report on the data, but the output is merely functional. On the other hand, R offers RMarkdown documents that can be used to generate highly customized, publication-ready reports and articles in various formats: html webpage, MS Word, and PDF document.
R vs Tableau
License cost (DUH!)
At the time of writing, the Professional Edition of Tableau Desktop software costs $70 per user per month. Also, to store data sources and workbooks securely, an additional cost of $35 per user per month for Tableau Server must be paid.5R is free.
Reproducibility
Tableau is first and foremost a Graphic User Interface tool. Accordingly, communicating the process of making the workbook is much difficult in Tableau although it is possible to share Tableau workbooks with others. (See above for more on the benefits of reproducibility.)
Data manipulation
Although Tableau offers some useful data manipulation features, its focus is visualization. As a result, Tableau’s data manipulation features are limited to meet the real-life needs and its users often need to rely on another tool to prepare data for use in Tableau.6
It is telling that Tableau offers an R integration functionality to create complex parameters. If this is the case, why not use R itself in its native environment?
Complex and advanced analysis
Tableau’s focus of quick-and-simple data visualization makes the tool largely unfit for conducting and thereby visualizing complex data analysis and statistical modeling results. R, on the other hand, is fully capable of handle both tasks of high-quality data visualization and advanced data analysis as well as modeling, either separately or jointly.
This is not to say that these tools (Excel, SPSS, and Tableau) are simply inferior to R in all aspects. Each software is designed with a specific set of tasks and comes with the ease of use for the right tasks. Furthermore, compared to these tools, R has a relatively steep learning curve, which makes it difficult for anyone without sufficient background knowledge to quickly master and use it for real tasks.
Nonetheless, R is a highly performant, versatile, and flexible tool for research and data analysis that is also largely compatible with any of the tools above. That said, R is a great addition to any researcher’s toolbox, and it can easily be the most preferred choice of tool.
Best Integrated Development Environment (IDE) for R
Although there are other IDEs supporting R, RStudio is a de facto standard tool in the R community and comes with many great features to extend R’s power beyond statistical computing.
Powerful and convenient features
Advanced debugging tools
RMarkdown integration
Shiny integration
R Presentation integration
Interactive workflow
Open source (again!)
Although RStudio, Inc. offers paid options for the IDE, which comes with additional support, the open source version, which is free of charge, can meet practicaly all needs of any researcher.
Environment: view objects in the global environment
History: search and view command history
Files/Plots/Packages/Help pane
Files: navigate directories
Plots: view generated plots
Packages: manage installed packages in the library
Help: view help documentations for any package/function
Customization
Panes
The size and position of panes can be customized. On the top right of each pane, there are buttons to adjust the pane size. Also, place your mouse pointer/cursor on the border line between panes and when the pointer changes its shape, click and drag to adjust the pane size. For more options, go to View > Panes on the menu bar. Alternatively, try Tools > Global Options > Pane Layout.
Appearances
The overall appearance can be customized as well. Go to Tools > Global options > Appearnce on the menu bar to change themes, fonts, and more.
Here, participants will learn the basic building blocks of R language. Once participants gain some knowledge in the fundamental topics, they will be introduced to the popular tidyverse framework and provided with a recommendation as to a “good” style for coding in R.
This module consists of the following two parts:
Part 1: Fundamentals of R programming
Part 2: Gearing up for data analysis
Module 3
Data analysis with R
This module focuses on manimuplating and transforming tabular data using R. Participants will learn how to import data into R environment and use common tidyverse syntax to clean and analyze data. Specifically, core functions from dplyr, tidyr, stringr, and lubridate packages will be covered.
This module consists of the following two parts:
Part 1: Getting started with tidyverse
Part 2: More on data analysis
Module 4
Data visualization with R
In this module, participants will get started with generating plots to visually present and communicate insights from data. The main focus of this module is the popular ggplot2 package. Participants will also be introduced to some options for generating maps and interactive plots.
This module consists of the following two parts:
Part 1: The Grammar of Graphics
Part 2: Advanced visualiation
Module 5
Statistical modeling with R
In this module, workshop participants will learn how to conduct basic statistical analysis with R, including Student’s t-test, analysis of variance (ANOVA), basic linear regression model, and generalized linear models. Participants will also be provided with resources for more advanced statistical modeling.
This module consists of the following two parts:
Part 1: Basics of statistical modeling
Part 2: Options for advanced modeling
Module 6
“To Infinity and Beyond”
This module will introduce workshop participants to various ways to share their work by using R Markdown, R Presentation, and Shiny. Participants will also learn how to leverage the power of the Internet to facilitate search for answers to specific questions.
This module consists of the following two parts:
Part 1: Sharing your work
Part 2: Leveraging online resources
ICJIA Workshop on the web
All the workshop materials are available as a website:


Carolyn's Weather Wardrobe Database
You can use this website to search your your previous outfits based on what the weather was like.
Search your wardrobe
(current)
Put things in your wardrobe
(current)
%}
Temperature
City
Month
Time
Day
Night
Search your wardrobe!


[gecode-users] Memory management bug in 2.2.0?
Christian Schulte
cschulte at kth.se
Wed Mar 25 14:59:27 CET 2009
Hi Filip,
yes that was strange stuff and we fixed for 3.0.0... Guido knows more about
it.
Christian
--
Christian Schulte, www.ict.kth.se/~cschulte/
-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Filip Konvicka
Sent: Wednesday, March 25, 2009 2:18 PM
To: users at gecode.org
Subject: [gecode-users] Memory management bug in 2.2.0?
Hi,
I know I'm probably late with this... I am hunting a memory leak in a
program that uses Gecode 2.2.0. The script (space) constructor
incrementally adds variables to a var-array (one by one). IMHO,
VarArray::resize acts strangely:
VarArray<Var>::resize(Space* home, int m) {
...
x = static_cast<Var*>(Memory::malloc(sizeof(Var)*newsize));
...
if (used != n)
Memory::free(oldx);
else
home->reuse(oldx, n);
n = newsize; used = m;
}
In my case, "used==n" always holds, so the allocated blocks are
"deallocated" using Space::reuse(), not Memory::free().
Originally, I was using the default constructor for the array. After I
saw this I tried to initialize it with (this, 0) in the constructor
initializer list, but this does not change anything.
It seems to me that VarArray::add and VarArray::resize could never
actually work... the only way the var-array allocates memory from space
is in the constructor and update(). Or did I miss something in the docs?
Is it forbidden to call add and resize?
Thanks,
Filip
_______________________________________________
Gecode users mailing list
users at gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users
More information about the gecode-users
mailing list


Users chat
Login now
Unicorns be waiting
Username
Password
Don't have an account?

Let's see what we can do. We'll need some information first though.
Username
Email
Password
Repeat password


DSiamMFT: An RGB-T fusion tracking method via dynamic Siamese networks using multi-layer feature fusion
Abstract
The task of object tracking is very important since its various applications. However, most object tracking methods are based on visible images, which may fail when visible images are unreliable, for example when the illumination conditions are poor. To address this issue, in this paper a fusion tracking method which combines information from RGB and thermal infrared images (RGB-T) is presented based on the fact that infrared images reveal thermal radiation of objects thus providing complementary features. Particularly, a fusion tracking method based on dynamic Siamese networks with multi-layer fusion, termed as DSiamMFT, is proposed. Visible and infrared images are firstly processed by two dynamic Siamese Networks, namely visible and infrared network, respectively. Then, multi-layer feature fusion is performed to adaptively integrate multi-level deep features between visible and infrared networks. Response maps produced from different fused layer features are then combined through an elementwise fusion approach to produce the final response map, based on which the target can be located. Extensive experiments on large datasets with various challenging scenarios have been conducted. The results demonstrate that the proposed method shows very competitive performance against the-state-of-art RGB-T trackers. The proposed approach also improves tracking performance significantly compared to methods based on images of single modality.
Materials
BibTeX
@article{ZHANG2020115756,
title = {DSiamMFT: An RGB-T fusion tracking method via dynamic Siamese networks using multi-layer feature fusion},
author = {Xingchen Zhang and Ping Ye and Shengyun Peng and Jun Liu and Gang Xiao},
journal = {Signal Processing: Image Communication},
year = {2020},
volume = {84},
pages = {115756},
issn = {0923-5965},
doi = {https://doi.org/10.1016/j.image.2019.115756},
url = {https://www.sciencedirect.com/science/article/pii/S092359651930342X},
}


The Great Hunt
Prologue: In the Shadow
The Flame of Tar Valon
The Welcome
Friends and Enemies
Summoned
The Shadow in Shienar
Dark Prophecy
Blood Calls Blood
The Dragon Reborn
Leavetakings
The Hunt Begins
Glimmers of the Pattern
Woven in the Pattern
From Stone to Stone
Wolfbrother
Kinslayer
In the Mirror of Darkness
Choices
To the White Tower
Beneath the Dagger
Saidin
The Nine Rings
Watchers
The Testing
New Friends and Old Enemies
Cairhien
Discord
The Shadow in the Night
A New Thread in the Pattern
Seanchan
Daes Dae’mar
On the Scent
Dangerous Words
A Message From the Dark
The Wheel Weaves
Stedding Tsofu
Among the Elders
What Might Be
Practice
Flight From the White Tower
Damane
Disagreements
Falme
A Plan
Five Will Ride Forth
Blademaster
To Come Out of the Shadow
The Grave Is No Bar to My Call
First Claiming
What Was Meant to Be
After
Glossary
Book 2 of
The Wheel of Time
Robert Jordan
Index of Books
|
Next—Book Three:
The Dragon Reborn


Usage Instructions
To load a comma separated value (CSV) formatted file click the 'Choose CSV File' button. The first line of the file should list the names of each column of values. The data types of the column values will be automatically determined. Columns with valid date values will be available from the 'Settings' dialog to map to the x-axis of the charts. The last date value in the list of columns will be selected by default. The other numeric columns will be shown as separate charts. An example CSV file can be viewed here. This data can also be viewed from the 'Load Sample Data' menu option.
The 'Redraw' button can be used to regenerate all the visible charts. If the window is resized, regenerating the plots will adjust the chart widths.
The 'Settings' button can be used to control several visual parameters of the charts.
Each chart has a close icon located at the top right of the chart. Click the close icon to remove the chart.


mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
This function returns a string or an array with all occurrences of search in subject replaced with the given replace value. If you don't need fancy replacing rules (like regular expressions), you should always use this function instead of preg_replace().
This function returns a string or an array with the replaced values.


Source code for etg.util.agentset
"""
A class to mimic Netlogos agentsets iteration behaviour
"""
import random
[docs]class AgentSet:
"""
A class to mimic Netlogo's agentsets random iteration behaviour. Also has
some convience methods that making common sequence operations for which
order does not matter faster.
"""
def __init__(self, *args, _list=None, _iter=None):
"""
An object can be initialized by giving the agents that shoudl initially
be in the set in its constructor.
"""
if _list:
self._list = _list
elif _iter:
self._list = list(_iter)
else:
self._list = list(args)
def __iter__(self):
"""
Return an iterator that goes over the agents in a random order.
"""
return iter(random.sample(self._list, len(self._list)))
def __len__(self):
"""
Get the number of agents in this agentset.
"""
return len(self._list)
def __contains__(self, agent):
"""
A check to see if a certain agent is in the set.
"""
return agent in self._list
[docs] def add_agent(self, agent):
"""
Add an agent to the agent set. If the agent is already in the set, do
nothing.
"""
if agent not in self._list:
self._list.append(agent)
[docs] def remove_agent(self, agent):
"""
Remove an agent from the set. If the agent is not in the set, do
nothing.
"""
self._list.remove(agent)
[docs] def n_of(self, number):
"""
Return number of agents from the set, as an :class:`~etg.util.agentset.AgentSet`.
"""
ret = AgentSet()
for agent in self:
ret.add_agent(agent)
if len(ret) >= number:
break
return ret
[docs] def one_of(self):
"""
Return a random agent from the set.
"""
for agent in self.n_of(1):
return agent
[docs] def filter(self, predicate):
"""
A more efficient filter that works directly on the underlaying
datastructure, and therefore does not shuffle the list first. If order
is not important for the filtering, this method is preferred over the
built in filter
"""
return AgentSet(_iter=filter(predicate, self._list))


projects/classroom-rds/src/app/classroom/course-works/course-works.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FlexLayoutModule } from '@angular/flex-layout';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { EntityDataService, EntityDefinitionService, EntityServices } from '@ngrx/data';
import * as fromCourseWork from '@rds-store/course-work';
import * as fromStudentSubmission from '@rds-store/student-submission';
import * as fromTopic from '@rds-store/topic';
import { StudentSubmissionDataService } from<EMAIL_ADDRESS>import { StudentSubmissionEntityService } from<EMAIL_ADDRESS>import { CourseWorkDataService } from<EMAIL_ADDRESS>import { CourseWorkEntityService } from<EMAIL_ADDRESS>import { TopicDataService } from<EMAIL_ADDRESS>import { TopicEntityService } from<EMAIL_ADDRESS>import { CourseWorksRoutingModule } from './course-works-routing.module';
import { CourseWorksResolver } from './services/course-works.resolver';
import { CourseWorksService } from './services/course-works.service';
import { StudentSubmissionsResolver } from './services/student-submissions.resolver';
import { TopicsResolver } from './services/topics.resolver';
import { CourseWorkComponent } from './components/course-work/course-work.component';
import { MaterialModule } from '~/app/modules/material.module';
import * as fromEntity from '~/app/store/app/config/entity-metadata';
@NgModule({
declarations: [CourseWorkComponent],
exports: [CourseWorkComponent],
imports: [
CommonModule,
CourseWorksRoutingModule,
MaterialModule,
FlexLayoutModule,
FontAwesomeModule
],
providers: [
CourseWorksService,
CourseWorkEntityService,
CourseWorkDataService,
CourseWorksResolver,
TopicDataService,
TopicEntityService,
TopicsResolver,
StudentSubmissionDataService,
StudentSubmissionEntityService,
StudentSubmissionsResolver,
]
})
export class CourseWorksModule {
constructor(
eds: EntityDefinitionService,
entityServices: EntityServices,
courseWorkEntityService: CourseWorkEntityService,
entityDataService: EntityDataService,
courseWorkDataService: CourseWorkDataService,
topicDataService: TopicDataService,
topicEntityService: TopicEntityService,
studentSubmissionEntityService: StudentSubmissionEntityService,
studentSubmissionDataService: StudentSubmissionDataService
) {
entityServices.registerEntityCollectionServices([courseWorkEntityService, topicEntityService, studentSubmissionEntityService]);
eds.registerMetadataMap(fromEntity.entityMetadata);
entityDataService.registerService(fromTopic.entityCollectionName, topicDataService);
entityDataService.registerService(fromStudentSubmission.entityCollectionName, studentSubmissionDataService);
entityDataService.registerService(fromCourseWork.entityCollectionName, courseWorkDataService);
}
}


We are a rad shop that makes the one and only Salmon Cookie.
Our cookies are nutritious and tasty, with a distinctive Salmony goodness you wont find anywhere else.
Our cookies are made with the best Salmon; moveover, our cookies are only made with Salmon.


You can use the discriminant via the `variant` property of `Maybe` instances if you need to match explicitly on it. */ export enum Variant { Just = 'Just', Nothing = 'Nothing', } export interface MaybeShape<T> { /** Distinguish between the `Just` and `Nothing` [variants](../enums/_maybe_.variant). */ variant: Variant; /** Method variant for [`Maybe.isJust`](../modules/_maybe_.html#isjust) */ isJust(this: Maybe<T>): this is Just<T>; /** Method variant for [`Maybe.isNothing`](../modules/_maybe_.html#isnothing) */ isNothing(this: Maybe<T>): this is Nothing<T>; /** Method variant for [`Maybe.map`](../modules/_maybe_.html#map) */ map<U>(this: Maybe<T>, mapFn: (t: T) => U): Maybe<U>; /** Method variant for [`Maybe.mapOr`](../modules/_maybe_.html#mapor) */ mapOr<U>(this: Maybe<T>, orU: U, mapFn: (t: T) => U): U; /** Method variant for [`Maybe.mapOrElse`](../modules/_maybe_.html#maporelse) */ mapOrElse<U>(this: Maybe<T>, orElseFn: (...args: any[]) => U, mapFn: (t: T) => U): U; /** Method variant for [`Maybe.match`](../modules/_maybe_.html#match) */ match<U>(this: Maybe<T>, matcher: Matcher<T, U>): U; /** Method variant for [`Maybe.or`](../modules/_maybe_.html#or) */ or(this: Maybe<T>, mOr: Maybe<T>): Maybe<T>; /** Method variant for [`Maybe.orElse`](../modules/_maybe_.html#orelse) */ orElse(this: Maybe<T>, orElseFn: (...args: any[]) => Maybe<T>): Maybe<T>; /** Method variant for [`Maybe.and`](../modules/_maybe_.html#and) */ and<U>(this: Maybe<T>, mAnd: Maybe<U>): Maybe<U>; /** Method variant for [`Maybe.andThen`](../modules/_maybe_.html#andthen) */ andThen<U>(this: Maybe<T>, andThenFn: (t: T) => Maybe<U>): Maybe<U>; /** Method variant for [`Maybe.chain`](../modules/_maybe_.html#chain) */ chain<U>(this: Maybe<T>, chainFn: (t: T) => Maybe<U>): Maybe<U>; /** Method variant for [`Maybe.flatMap`](../modules/_maybe_.html#flatmap) */ flatMap<U>(this: Maybe<T>, flatMapFn: (t: T) => Maybe<U>): Maybe<U>; /** Method variant for [`Maybe.unwrap`](../modules/_maybe_.html#unwrap) */ unsafelyUnwrap(): T | never; /** Method variant for [`Maybe.unwrapOrElse`](../modules/_maybe_.html#unwraporelse) */ unwrapOrElse(this: Maybe<T>, elseFn: (...args: any[]) => T): T; /** Method variant for [`Maybe.toOkOrErr`](../modules/_maybe_.html#tookorerr) */ toOkOrErr<E>(this: Maybe<T>, error: E): Result<T, E>; /** Method variant for [`Maybe.toOkOrElseErr`](../modules/_maybe_.html#tookorelseerr) */ toOkOrElseErr<E>(this: Maybe<T>, elseFn: (...args: any[]) => E): Result<T, E>; /** Method variant for [`Maybe.toString`](../modules/_maybe_.html#tostring) */ toString(this: Maybe<T>): string; } /** A `Just` instance is the *present* variant instance of the [`Maybe`](../modules/_maybe_.html#maybe) type, representing the presence of a value which may be absent. For a full discussion, see [the module docs](../modules/_maybe_.html). @typeparam T The type wrapped in this `Just` variant of `Maybe`. */ export class Just<T> implements MaybeShape<T> { /** `Just` is always [`Variant.Just`](../enums/_maybe_.variant#just). */ variant = Variant.Just; private value: T; /** Create an instance of `Maybe.Just` with `new`. @note While you *may* create the `Just` type via normal JavaScript class construction, it is not recommended for the functional style for which the library is intended. Instead, use [`Maybe.of`] (for the general case) or [`Maybe.just`] for this specific case. [`Maybe.of`]: ../modules/_maybe_.html#of [`Maybe.just`]: ../modules/_maybe_.html#just ```ts // Avoid: const aString = new Maybe.Just('characters'); // Prefer: const aString = Maybe.just('characters); ``` @param value The value to wrap in a `Maybe.Just`. `null` and `undefined` are allowed by the type signature so that the constructor may `throw` on those rather than constructing a type like `Maybe<undefined>`. @throws If you pass `null` or `undefined`. */ constructor(value?: T | null) { if (isVoid(value)) { throw new Error('Tried to construct `Just` with `null` or `undefined`'); } this.value = value; } /** Method variant for [`Maybe.isJust`](../modules/_maybe_.html#isjust) */ isJust(this: Maybe<T>): this is Just<T> { return isJust(this); } /** Method variant for [`Maybe.isNothing`](../modules/_maybe_.html#isnothing) */ isNothing(this: Maybe<T>): this is Nothing<T> { return isNothing(this); } /** Method variant for [`Maybe.map`](../modules/_maybe_.html#map) */ map<U>(this: Maybe<T>, mapFn: (t: T) => U): Maybe<U> { return map(mapFn, this); } /** Method variant for [`Maybe.mapOr`](../modules/_maybe_.html#mapor) */ mapOr<U>(this: Maybe<T>, orU: U, mapFn: (t: T) => U): U { return mapOr(orU, mapFn, this); } /** Method variant for [`Maybe.mapOrElse`](../modules/_maybe_.html#maporelse) */ mapOrElse<U>(this: Maybe<T>, orElseFn: (...args: any[]) => U, mapFn: (t: T) => U): U { return mapOrElse(orElseFn, mapFn, this); } /** Method variant for [`Maybe.match`](../modules/_maybe_.html#match) */ match<U>(this: Maybe<T>, matcher: Matcher<T, U>): U { return match(matcher, this); } /** Method variant for [`Maybe.or`](../modules/_maybe_.html#or) */ or(this: Maybe<T>, mOr: Maybe<T>): Maybe<T> { return or(mOr, this); } /** Method variant for [`Maybe.orElse`](../modules/_maybe_.html#orelse) */ orElse(this: Maybe<T>, orElseFn: (...args: any[]) => Maybe<T>): Maybe<T> { return orElse(orElseFn, this); } /** Method variant for [`Maybe.and`](../modules/_maybe_.html#and) */ and<U>(this: Maybe<T>, mAnd: Maybe<U>): Maybe<U> { return and(mAnd, this); } /** Method variant for [`Maybe.andThen`](../modules/_maybe_.html#andthen) */ andThen<U>(this: Maybe<T>, andThenFn: (t: T) => Maybe<U>): Maybe<U> { return andThen(andThenFn, this); } /** Method variant for [`Maybe.chain`](../modules/_maybe_.html#chain) */ chain<U>(this: Maybe<T>, chainFn: (t: T) => Maybe<U>): Maybe<U> { return this.andThen(chainFn); } /** Method variant for [`Maybe.flatMap`](../modules/_maybe_.html#flatmap) */ flatMap<U>(this: Maybe<T>, flatMapFn: (t: T) => Maybe<U>): Maybe<U> { return this.andThen(flatMapFn); } /** Method variant for [`Maybe.unsafelyUnwrap`](../modules/_maybe_.html#unsafelyunwrap) */ unsafelyUnwrap(): T { return this.value; } /** Method variant for [`Maybe.unwrapOr`](../modules/_maybe_.html#unwrapor) */ unwrapOr(this: Maybe<T>, defaultValue: T): T { return unwrapOr(defaultValue, this); } /** Method variant for [`Maybe.unwrapOrElse`](../modules/_maybe_.html#unwraporelse) */ unwrapOrElse(this: Maybe<T>, elseFn: (...args: any[]) => T): T { return unwrapOrElse(elseFn, this); } /** Method variant for [`Maybe.toOkOrErr`](../modules/_maybe_.html#tookorerr) */ toOkOrErr<E>(this: Maybe<T>, error: E): Result<T, E> { return toOkOrErr(error, this); } /** Method variant for [`Maybe.toOkOrElseErr`](../modules/_maybe_.html#tookorelseerr) */ toOkOrElseErr<E>(this: Maybe<T>, elseFn: (...args: any[]) => E): Result<T, E> { return toOkOrElseErr(elseFn, this); } /** Method variant for [`Maybe.toString`](../modules/_maybe_.html#tostring) */ toString(this: Maybe<T>): string { return toString(this); } } /** A `Nothing` instance is the *absent* variant instance of the [`Maybe`](../modules/_maybe_.html#maybe) type, representing the presence of a value which may be absent. For a full discussion, see [the module docs](../modules/_maybe_.html). @typeparam T The type which would be wrapped in a `Just` variant of `Maybe`. */ export class Nothing<T> implements MaybeShape<T> { /** `Nothing` is always [`Variant.Nothing`](../enums/_maybe_.variant#nothing). */ variant = Variant.Nothing; /** Create an instance of `Maybe.Nothing` with `new`. @note While you *may* create the `Nothing` type via normal JavaScript class construction, it is not recommended for the functional style for which the library is intended. Instead, use [`Maybe.of`] (for the general case) or [`Maybe.nothing`] for this specific case. [`Maybe.of`]: ../modules/_maybe_.html#of [`Maybe.nothing`]: ../modules/_maybe_.html#nothing ```ts // Avoid: const aNothing = new Maybe.Err(); // Prefer: const aNothing = Maybe.nothing(); ``` `null` and `undefined` are allowed so that you may explicitly construct the `Err` type with a known `null` or `undefined` value. (This maybe helpful primarily when transitioning a codebase to the use of `Maybe`.) @throws If you pass `null` or `undefined`. */ constructor(_?: null) { /* nothing to do */ } /** Method variant for [`Maybe.isJust`](../modules/_maybe_.html#isjust) */ isJust(this: Maybe<T>): this is Just<T> { return isJust(this); } /** Method variant for [`Maybe.isNothing`](../modules/_maybe_.html#isnothing) */ isNothing(this: Maybe<T>): this is Nothing<T> { return isNothing(this); } /** Method variant for [`Maybe.map`](../modules/_maybe_.html#map) */ map<U>(this: Maybe<T>, mapFn: (t: T) => U): Maybe<U> { return map(mapFn, this); } /** Method variant for [`Maybe.mapOr`](../modules/_maybe_.html#mapor) */ mapOr<U>(this: Maybe<T>, orU: U, mapFn: (t: T) => U): U { return mapOr(orU, mapFn, this); } /** Method variant for [`Maybe.mapOrElse`](../modules/_maybe_.html#maporelse) */ mapOrElse<U>(this: Maybe<T>, orElseFn: (...args: any[]) => U, mapFn: (t: T) => U): U { return mapOrElse(orElseFn, mapFn, this); } /** Method variant for [`Maybe.match`](../modules/_maybe_.html#match) */ match<U>(this: Maybe<T>, matcher: Matcher<T, U>): U { return match(matcher, this); } /** Method variant for [`Maybe.or`](../modules/_maybe_.html#or) */ or(this: Maybe<T>, mOr: Maybe<T>): Maybe<T> { return or(mOr, this); } /** Method variant for [`Maybe.orElse`](../modules/_maybe_.html#orelse) */ orElse(this: Maybe<T>, orElseFn: (...args: any[]) => Maybe<T>): Maybe<T> { return orElse(orElseFn, this); } /** Method variant for [`Maybe.and`](../modules/_maybe_.html#and) */ and<U>(this: Maybe<T>, mAnd: Maybe<U>): Maybe<U> { return and(mAnd, this); } /** Method variant for [`Maybe.andThen`](../modules/_maybe_.html#andthen) */ andThen<U>(this: Maybe<T>, andThenFn: (t: T) => Maybe<U>): Maybe<U> { return andThen(andThenFn, this); } /** Method variant for [`Maybe.chain`](../modules/_maybe_.html#chain) */ chain<U>(this: Maybe<T>, chainFn: (t: T) => Maybe<U>): Maybe<U> { return this.andThen(chainFn); } /** Method variant for [`Maybe.flatMap`](../modules/_maybe_.html#flatmap) */ flatMap<U>(this: Maybe<T>, flatMapFn: (t: T) => Maybe<U>): Maybe<U> { return this.andThen(flatMapFn); } /** Method variant for [`Maybe.unsafelyUnwrap`](../modules/_maybe_.html#unsafelyunwrap) */ unsafelyUnwrap(): never { throw new Error('Tried to `unsafelyUnwrap(Nothing)`'); } /** Method variant for [`Maybe.unwrapOr`](../modules/_maybe_.html#unwrapor) */ unwrapOr(this: Maybe<T>, defaultValue: T): T { return unwrapOr(defaultValue, this); } /** Method variant for [`Maybe.unwrapOrElse`](../modules/_maybe_.html#unwraporelse) */ unwrapOrElse(this: Maybe<T>, elseFn: (...args: any[]) => T): T { return unwrapOrElse(elseFn, this); } /** Method variant for [`Maybe.toOkOrErr`](../modules/_maybe_.html#tookorerr) */ toOkOrErr<E>(this: Maybe<T>, error: E): Result<T, E> { return toOkOrErr(error, this); } /** Method variant for [`Maybe.toOkOrElseErr`](../modules/_maybe_.html#tookorelseerr) */ toOkOrElseErr<E>(this: Maybe<T>, elseFn: (...args: any[]) => E): Result<T, E> { return toOkOrElseErr(elseFn, this); } /** Method variant for [`Maybe.toString`](../modules/_maybe_.html#tostring) */ toString(this: Maybe<T>): string { return toString(this); } } /** Is this result a `Just` instance? @typeparam T The type of the wrapped value. @param maybe The `Maybe` instance to check. @returns `true` if `maybe` is `Just`, `false` otherwise. In TypeScript, also narrows the type from `Maybe<T>` to `Just<T>`. */ export function isJust<T>(maybe: Maybe<T>): maybe is Just<T> { return maybe.variant === Variant.Just; } /** Is this result a `Nothing` instance? @typeparam T The type of the wrapped value. @param maybe The `Maybe` instance to check. @returns `true` if `maybe` is `nothing`, `false` otherwise. In TypeScript, also narrows the type from `Maybe<T>` to `Nothing<T>`. */ export function isNothing<T>(maybe: Maybe<T>): maybe is Nothing<T> { return maybe.variant === Variant.Nothing; } /** Create an instance of `Maybe.Just`. `null` and `undefined` are allowed by the type signature so that the function may `throw` on those rather than constructing a type like `Maybe<undefined>`. @typeparam T The type of the item contained in the `Maybe`. @param value The value to wrap in a `Maybe.Just`. @returns An instance of `Maybe.Just<T>`. @throws If you pass `null` or `undefined`. */ export function just<T>(value?: T | null): Maybe<T> { return new Just<T>(value); } /** Create an instance of `Maybe.Nothing`. If you want to create an instance with a specific type, e.g. for use in a function which expects a `Maybe<T>` where the `<T>` is known but you have no value to give it, you can use a type parameter: ```ts const notString = Maybe.nothing<string>(); ``` @typeparam T The type of the item contained in the `Maybe`. @returns An instance of `Maybe.Nothing<T>`. */ export function nothing<T>(_?: null): Maybe<T> { return new Nothing<T>(_); } /** Create a `Maybe` from any value. To specify that the result should be interpreted as a specific type, you may invoke `Maybe.of` with an explicit type parameter: ```ts const foo = Maybe.of<string>(null); ``` This is usually only important in two cases: 1. If you are intentionally constructing a `Nothing` from a known `null` or undefined value *which is untyped*. 2. If you are specifying that the type is more general than the value passed (since TypeScript can define types as literals). @typeparam T The type of the item contained in the `Maybe`. @param value The value to wrap in a `Maybe`. If it is `undefined` or `null`, the result will be `Nothing`; otherwise it will be the type of the value passed. */ export function of<T>(value?: T | null): Maybe<T> { return isVoid(value) ? nothing<T>() : just(value); } /** Alias for [`of`](#of), primarily for compatibility with Folktale. */ export const fromNullable = of; /** Map over a `Maybe` instance: apply the function to the wrapped value if the instance is `Just`, and return `Nothing` if the instance is `Nothing`. `Maybe.map` works a lot like `Array.prototype.map`: `Maybe` and `Array` are both *containers* for other things. If you have no items in an array of numbers named `foo` and call `foo.map(x => x + 1)`, you'll still just have an array with nothing in it. But if you have any items in the array (`[2, 3]`), and you call `foo.map(x => x + 1)` on it, you'll get a new array with each of those items inside the array "container" transformed (`[3, 4]`). That's exactly what's happening with `Maybe.map`. If the container is *empty* – the `Nothing` variant – you just get back an empty container. If the container has something in it – the `Just` variant – you get back a container with the item inside transformed. (So... why not just use an array? The biggest reason is that an array can be any length. With a `Maybe`, we're capturing the idea of "something or nothing" rather than "0 to n" items. And this lets us implement a whole set of *other* interfaces, like those in this module.) #### Examples ```ts const length = (s: string) => s.length; const justAString = Maybe.just('string'); const justTheStringLength = map(length, justAString); console.log(justTheStringLength.toString()); // Just(6) const notAString = Maybe.nothing<string>(); const notAStringLength = map(length, notAString); console.log(notAStringLength.toString()); // "Nothing" ``` @typeparam T The type of the wrapped value. @typeparam U The type of the wrapped value of the returned `Maybe`. @param mapFn The function to apply the value to if `Maybe` is `Just`. @param maybe The `Maybe` instance to map over. @returns A new `Maybe` with the result of applying `mapFn` to the value in a `Just`, or `Nothing` if `maybe` is `Nothing`. */ export function map<T, U>(mapFn: (t: T) => U): (maybe: Maybe<T>) => Maybe<U>; export function map<T, U>(mapFn: (t: T) => U, maybe: Maybe<T>): Maybe<U>; export function map<T, U>( mapFn: (t: T) => U, maybe?: Maybe<T> ): Maybe<U> | ((maybe: Maybe<T>) => Maybe<U>) { const op = (m: Maybe<T>) => (isJust(m) ? just(mapFn(unwrap(m))) : nothing<U>()); return curry1(op, maybe); } /** Map over a `Maybe` instance and get out the value if `maybe` is a `Just`, or return a default value if `maybe` is a `Nothing`. #### Examples ```ts const length = (s: string) => s.length; const justAString = Maybe.just('string'); const theStringLength = mapOr(0, length, justAString); console.log(theStringLength); // 6 const notAString = Maybe.nothing<string>(); const notAStringLength = mapOr(0, length, notAString) console.log(notAStringLength); // 0 ``` @typeparam T The type of the wrapped value. @typeparam U The type of the wrapped value of the returned `Maybe`. @param orU The default value to use if `maybe` is `Nothing` @param mapFn The function to apply the value to if `Maybe` is `Just` @param maybe The `Maybe` instance to map over. */ export function mapOr<T, U>(orU: U, mapFn: (t: T) => U, maybe: Maybe<T>): U; export function mapOr<T, U>(orU: U, mapFn: (t: T) => U): (maybe: Maybe<T>) => U; export function mapOr<T, U>(orU: U): (mapFn: (t: T) => U) => (maybe: Maybe<T>) => U; export function mapOr<T, U>( orU: U, mapFn?: (t: T) => U, maybe?: Maybe<T> ): U | ((maybe: Maybe<T>) => U) | ((mapFn: (t: T) => U) => (maybe: Maybe<T>) => U) { function fullOp(fn: (t: T) => U, m: Maybe<T>) { return isJust(m) ? fn(unwrap(m)) : orU; } function partialOp(fn: (t: T) => U): (maybe: Maybe<T>) => U; function partialOp(fn: (t: T) => U, curriedMaybe: Maybe<T>): U; function partialOp(fn: (t: T) => U, curriedMaybe?: Maybe<T>): U | ((maybe: Maybe<T>) => U) { return curriedMaybe !== undefined ? fullOp(fn, curriedMaybe) : (extraCurriedMaybe: Maybe<T>) => fullOp(fn, extraCurriedMaybe); } return mapFn === undefined ? partialOp : maybe === undefined ? partialOp(mapFn) : partialOp(mapFn, maybe); } /** Map over a `Maybe` instance and get out the value if `maybe` is a `Just`, or use a function to construct a default value if `maybe` is `Nothing`. #### Examples ```ts const length = (s: string) => s.length; const getDefault = () => 0; const justAString = Maybe.just('string'); const theStringLength = mapOrElse(getDefault, length, justAString); console.log(theStringLength); // 6 const notAString = Maybe.nothing<string>(); const notAStringLength = mapOrElse(getDefault, length, notAString) console.log(notAStringLength); // 0 ``` @typeparam T The type of the wrapped value. @typeparam U The type of the wrapped value of the returned `Maybe`. @param orElseFn The function to apply if `maybe` is `Nothing`. @param mapFn The function to apply to the wrapped value if `maybe` is `Just` @param maybe The `Maybe` instance to map over. */ export function mapOrElse<T, U>( orElseFn: (...args: any[]) => U, mapFn: (t: T) => U, maybe: Maybe<T> ): U; export function mapOrElse<T, U>( orElseFn: (...args: any[]) => U, mapFn: (t: T) => U ): (maybe: Maybe<T>) => U; export function mapOrElse<T, U>( orElseFn: (...args: any[]) => U ): (mapFn: (t: T) => U) => (maybe: Maybe<T>) => U; export function mapOrElse<T, U>( orElseFn: (...args: any[]) => U, mapFn?: (t: T) => U, maybe?: Maybe<T> ): U | ((maybe: Maybe<T>) => U) | ((mapFn: (t: T) => U) => (maybe: Maybe<T>) => U) { function fullOp(fn: (t: T) => U, m: Maybe<T>) { return isJust(m) ? fn(unwrap(m)) : orElseFn(); } function partialOp(fn: (t: T) => U): (maybe: Maybe<T>) => U; function partialOp(fn: (t: T) => U, curriedMaybe: Maybe<T>): U; function partialOp(fn: (t: T) => U, curriedMaybe?: Maybe<T>): U | ((maybe: Maybe<T>) => U) { return curriedMaybe !== undefined ? fullOp(fn, curriedMaybe) : (extraCurriedMaybe: Maybe<T>) => fullOp(fn, extraCurriedMaybe); } if (mapFn === undefined) { return partialOp; } else if (maybe === undefined) { return partialOp(mapFn); } else { return partialOp(mapFn, maybe); } } /** You can think of this like a short-circuiting logical "and" operation on a `Maybe` type. If `maybe` is `Just`, then the result is the `andMaybe`. If `maybe` is `Nothing`, the result is `Nothing`. This is useful when you have another `Maybe` value you want to provide if and *only if* you have a `Just` – that is, when you need to make sure that if you `Nothing`, whatever else you're handing a `Maybe` to *also* gets a `Nothing`. Notice that, unlike in [`map`](#map) or its variants, the original `maybe` is not involved in constructing the new `Maybe`. #### Examples ```ts import Maybe from 'true-myth/maybe'; const justA = Maybe.just('A'); const justB = Maybe.just('B'); const nothing: Maybe<number> = nothing(); console.log(Maybe.and(justB, justA).toString()); // Just(B) console.log(Maybe.and(justB, nothing).toString()); // Nothing console.log(Maybe.and(nothing, justA).toString()); // Nothing console.log(Maybe.and(nothing, nothing).toString()); // Nothing ``` @typeparam T The type of the initial wrapped value. @typeparam U The type of the wrapped value of the returned `Maybe`. @param andMaybe The `Maybe` instance to return if `maybe` is `Just` @param maybe The `Maybe` instance to check. @return `Nothing` if the original `maybe` is `Nothing`, or `andMaybe` if the original `maybe` is `Just`. */ export function and<T, U>(andMaybe: Maybe<U>, maybe: Maybe<T>): Maybe<U>; export function and<T, U>(andMaybe: Maybe<U>): (maybe: Maybe<T>) => Maybe<U>; export function and<T, U>( andMaybe: Maybe<U>, maybe?: Maybe<T> ): Maybe<U> | ((maybe: Maybe<T>) => Maybe<U>) { const op = (m: Maybe<T>) => (isJust(m) ? andMaybe : nothing() as Maybe<U>); return curry1(op, maybe); } /** Apply a function to the wrapped value if `Just` and return a new `Just` containing the resulting value; or return `Nothing` if `Nothing`. This differs from `map` in that `thenFn` returns another `Maybe`. You can use `andThen` to combine two functions which *both* create a `Maybe` from an unwrapped type. You may find the `.then` method on an ES6 `Promise` helpful for comparison: if you have a `Promise`, you can pass its `then` method a callback which returns another `Promise`, and the result will not be a *nested* promise, but a single `Promise`. The difference is that `Promise#then` unwraps *all* layers to only ever return a single `Promise` value, whereas `Maybe.andThen` will not unwrap nested `Maybe`s. This is also commonly known as (and therefore aliased as) [`flatMap`] or [`chain`]. It is sometimes also known as `bind`, but *not* aliased as such because [`bind` already means something in JavaScript][bind]. [`flatMap`]: #flatmap [`chain`]: #chain [bind]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind #### Example (This is a somewhat contrived example, but it serves to show the way the function behaves.) ```ts import Maybe from 'true-myth/maybe'; // string -> Maybe<number> const toMaybeLength = (s: string): Maybe<number> => Maybe.of(s.length); // Maybe<string> const aMaybeString = Maybe.of('Hello, there!'); // Maybe<number> const resultingLength = Maybe.andThen(toMaybeLength, aMaybeString); console.log(Maybe.toString(resultingLength)); // 13 ``` Note that the result is not `(Just(13))`, but `13`! @typeparam T The type of the wrapped value. @typeparam T The type of the wrapped value in the resulting `Maybe`. @param thenFn The function to apply to the wrapped `T` if `maybe` is `Just`. @param maybe The `Maybe` to evaluate and possibly apply a function to the contents of. @returns The result of the `thenFn` (a new `Maybe`) if `maybe` is a `Just`, otherwise `Nothing` if `maybe` is a `Nothing`. */ export function andThen<T, U>(thenFn: (t: T) => Maybe<U>, maybe: Maybe<T>): Maybe<U>; export function andThen<T, U>(thenFn: (t: T) => Maybe<U>): (maybe: Maybe<T>) => Maybe<U>; export function andThen<T, U>( thenFn: (t: T) => Maybe<U>, maybe?: Maybe<T> ): Maybe<U> | ((maybe: Maybe<T>) => Maybe<U>) { const op = (m: Maybe<T>) => (isJust(m) ? thenFn(unwrap(m)) : nothing() as Maybe<U>); return maybe !== undefined ? op(maybe) : op; } /** Alias for [`andThen`](#andthen). */ export const chain = andThen; /** Alias for [`andThen`](#andthen). */ export const flatMap = andThen; /** Provide a fallback for a given `Maybe`. Behaves like a logical `or`: if the `maybe` value is a `Just`, returns that `maybe`; otherwise, returns the `defaultMaybe` value. This is useful when you want to make sure that something which takes a `Maybe` always ends up getting a `Just` variant, by supplying a default value for the case that you currently have a nothing. ```ts import Maybe from 'true-utils/maybe'; const justA = Maybe.just("a"); const justB = Maybe.just("b"); const aNothing: Maybe<string> = nothing(); console.log(Maybe.or(justB, justA).toString()); // Just(A) console.log(Maybe.or(aNothing, justA).toString()); // Just(A) console.log(Maybe.or(justB, aNothing).toString()); // Just(B) console.log(Maybe.or(aNothing, aNothing).toString()); // Nothing ``` @typeparam T The type of the wrapped value. @param defaultMaybe The `Maybe` to use if `maybe` is a `Nothing`. @param maybe The `Maybe` instance to evaluate. @returns `maybe` if it is a `Just`, otherwise `defaultMaybe`. */ export function or<T>(defaultMaybe: Maybe<T>, maybe: Maybe<T>): Maybe<T>; export function or<T>(defaultMaybe: Maybe<T>): (maybe: Maybe<T>) => Maybe<T>; export function or<T>( defaultMaybe: Maybe<T>, maybe?: Maybe<T> ): Maybe<T> | ((maybe: Maybe<T>) => Maybe<T>) { const op = (m: Maybe<T>) => (isJust(m) ? m : defaultMaybe); return maybe !== undefined ? op(maybe) : op; } /** Like `or`, but using a function to construct the alternative `Maybe`. Sometimes you need to perform an operation using other data in the environment to construct the fallback value. In these situations, you can pass a function (which may be a closure) as the `elseFn` to generate the fallback `Maybe<T>`. Useful for transforming empty scenarios based on values in context. @typeparam T The type of the wrapped value. @param elseFn The function to apply if `maybe` is `Nothing` @param maybe The `maybe` to use if it is `Just`. @returns The `maybe` if it is `Just`, or the `Maybe` returned by `elseFn` if the `maybe` is `Nothing. */ export function orElse<T>(elseFn: (...args: any[]) => Maybe<T>, maybe: Maybe<T>): Maybe<T>; export function orElse<T>(elseFn: (...args: any[]) => Maybe<T>): (maybe: Maybe<T>) => Maybe<T>; export function orElse<T>( elseFn: (...args: any[]) => Maybe<T>, maybe?: Maybe<T> ): Maybe<T> | ((maybe: Maybe<T>) => Maybe<T>) { const op = (m: Maybe<T>) => (isJust(m) ? m : elseFn()); return curry1(op, maybe); } /** Get the value out of the `Maybe`. Returns the content of a `Just`, but **throws if the `Maybe` is `Nothing`**. Prefer to use [`unwrapOr`](#unwrapor) or [`unwrapOrElse`](#unwraporelse). @typeparam T The type of the wrapped value. @param maybe The value to unwrap @returns The unwrapped value if the `Maybe` instance is `Just`. @throws If the `maybe` is `Nothing`. */ export const unsafelyUnwrap = <T>(maybe: Maybe<T>): T => maybe.unsafelyUnwrap(); /** Alias for [`unsafelyUnwrap`](#unsafelyunwrap) */ export const unsafelyGet = unsafelyUnwrap; /** Alias for [`unsafelyUnwrap`](#unsafelyunwrap) */ export const unsafeGet = unsafelyUnwrap; // For internal use; but not exported because we want to emphasize that this is // a bad idea via the name. const unwrap = unsafelyUnwrap; /** Safely get the value out of a `Maybe`. Returns the content of a `Just` or `defaultValue` if `Nothing`. This is the recommended way to get a value out of a `Maybe` most of the time. ```ts import Maybe from 'true-myth/maybe'; const notAString = Maybe.nothing<string>(); const isAString = Maybe.just('look ma! some characters!'); console.log(Maybe.unwrapOr('<empty>', notAString)); // "<empty>" console.log(Maybe.unwrapOr('<empty>', isAString)); // "look ma! some characters!" ``` @typeparam T The type of the wrapped value. @param defaultValue The value to return if `maybe` is a `Nothing`. @param maybe The `Maybe` instance to unwrap if it is a `Just`. @returns The content of `maybe` if it is a `Just`, otherwise `defaultValue`. */ export function unwrapOr<T>(defaultValue: T, maybe: Maybe<T>): T; export function unwrapOr<T>(defaultValue: T): (maybe: Maybe<T>) => T; export function unwrapOr<T>(defaultValue: T, maybe?: Maybe<T>): T | ((maybe: Maybe<T>) => T) { const op = (m: Maybe<T>) => (isJust(m) ? unwrap(m) : defaultValue); return curry1(op, maybe); } /** Alias for [`unwrapOr`](#unwrapor) */ export const getOr = unwrapOr; /** Safely get the value out of a [`Maybe`](#maybe) by returning the wrapped value if it is `Just`, or by applying `orElseFn` if it is `Nothing`. This is useful when you need to *generate* a value (e.g. by using current values in the environment – whether preloaded or by local closure) instead of having a single default value available (as in [`unwrapOr`](#unwrapor)). ```ts import Maybe from 'true-myth/maybe'; // You can imagine that someOtherValue might be dynamic. const someOtherValue = 99; const handleNothing = () => someOtherValue; const aJust = Maybe.just(42); console.log(Maybe.unwrapOrElse(handleNothing, aJust)); // 42 const aNothing = nothing<number>(); console.log(Maybe.unwrapOrElse(handleNothing, aNothing)); // 99 ``` @typeparam T The wrapped value. @param orElseFn A function used to generate a valid value if `maybe` is a `Nothing`. @param maybe The `Maybe` instance to unwrap if it is a `Just` @returns Either the content of `maybe` or the value returned from `orElseFn`. */ export function unwrapOrElse<T>(orElseFn: (...args: any[]) => T, maybe: Maybe<T>): T; export function unwrapOrElse<T>(orElseFn: (...args: any[]) => T): (maybe: Maybe<T>) => T; export function unwrapOrElse<T>( orElseFn: (...args: any[]) => T, maybe?: Maybe<T> ): T | ((maybe: Maybe<T>) => T) { const op = (m: Maybe<T>) => (isJust(m) ? unwrap(m) : orElseFn()); return curry1(op, maybe); } /** Alias for [`unwrapOrElse`](#unwraporelse) */ export const getOrElse = unwrapOrElse; /** Transform the [`Maybe`](#maybe) into a [`Result`](../modules/_result_.html#result), using the wrapped value as the `Ok` value if `Just`; otherwise using the supplied `error` value for `Err`. @typeparam T The wrapped value. @typeparam E The error type to in the `Result`. @param error The error value to use if the `Maybe` is `Nothing`. @param maybe The `Maybe` instance to convert. @returns A `Result` containing the value wrapped in `maybe` in an `Ok`, or `error` in an `Err`. */ export function toOkOrErr<T, E>(error: E, maybe: Maybe<T>): Result<T, E>; export function toOkOrErr<T, E>(error: E): (maybe: Maybe<T>) => Result<T, E>; export function toOkOrErr<T, E>( error: E, maybe?: Maybe<T> ): Result<T, E> | ((maybe: Maybe<T>) => Result<T, E>) { const op = (m: Maybe<T>) => (isJust(m) ? ok(unwrap(m)) : err(error)) as Result<T, E>; return maybe !== undefined ? op(maybe) : op; } /** Transform the [`Maybe`](#maybe) into a [`Result`](../modules/_result_.html#result), using the wrapped value as the `Ok` value if `Just`; otherwise using `elseFn` to generate `Err`. @typeparam T The wrapped value. @typeparam E The error type to in the `Result`. @param elseFn The function which generates an error of type `E`. @param maybe The `Maybe` instance to convert. @returns A `Result` containing the value wrapped in `maybe` in an `Ok`, or `the value generated by `elseFn` in an `Err`. */ export function toOkOrElseErr<T, E>(elseFn: (...args: any[]) => E, maybe: Maybe<T>): Result<T, E>; export function toOkOrElseErr<T, E>( elseFn: (...args: any[]) => E ): (maybe: Maybe<T>) => Result<T, E>; export function toOkOrElseErr<T, E>( elseFn: (...args: any[]) => E, maybe?: Maybe<T> ): Result<T, E> | ((maybe: Maybe<T>) => Result<T, E>) { const op = (m: Maybe<T>) => (isJust(m) ? ok(unwrap(m)) : err(elseFn())) as Result<T, E>; return curry1(op, maybe); } /** Construct a `Maybe<T>` from a `Result<T, E>`. If the `Result` is an `Ok`, wrap its value in `Just`. If the `Result` is an `Err`, throw away the wrapped `E` and transform to a `Nothing`. @typeparam T The type of the value wrapped in a `Result.Ok` and in the `Just` of the resulting `Maybe`. @typeparam E The type of the value wrapped in a `Result.Err`; thrown away in the resulting `Maybe`. @param result The `Result` to construct a `Maybe` from. @returns `Just` if `result` was `Ok` or `Nothing` if it was `Err`. */ export function fromResult<T, E>(result: Result<T, E>): Maybe<T> { return isOk(result) ? just(Result.unsafelyUnwrap(result)) : nothing(); } /** Create a `String` representation of a `Maybe` instance. A `Just` instance will be printed as `Just(<representation of the value>)`, where the representation of the value is simply the value's own `toString` representation. For example: | call | output | |----------------------------------------|-------------------------| | `toString(Maybe.of(42))` | `Just(42)` | | `toString(Maybe.of([1, 2, 3]))` | `Just(1,2,3)` | | `toString(Maybe.of({ an: 'object' }))` | `Just([object Object])` | | `toString(Maybe.nothing())` | `Nothing` | @typeparam T The type of the wrapped value; its own `.toString` will be used to print the interior contents of the `Just` variant. @param maybe The value to convert to a string. @returns The string representation of the `Maybe`. */ export function toString<T>(maybe: Maybe<T>): string { const body = isJust(maybe) ? `(${unwrap(maybe).toString()})` : ''; return `${maybe.variant}${body}`; } /** A lightweight object defining how to handle each variant of a Maybe. */ export type Matcher<T, A> = { Just: (value: T) => A; Nothing: () => A; }; /** Performs the same basic functionality as `getOrElse`, but instead of simply unwrapping the value if it is `Just` and applying a value to generate the same default type if it is `Nothing`, lets you supply functions which may transform the wrapped type if it is `Just` or get a default value for `Nothing`. This is kind of like a poor man's version of pattern matching, which JavaScript currently lacks. Instead of code like this: ```ts import Maybe from 'true-myth/maybe'; const logValue = (mightBeANumber: Maybe<number>) => { const valueToLog = Maybe.isJust(mightBeANumber) ? Maybe.unsafelyUnwrap(mightBeANumber).toString() : 'Nothing to log.'; console.log(valueToLog); }; ``` ...we can write code like this: ```ts import Maybe from 'true-myth/maybe'; const logValue = (mightBeANumber: Maybe<number>) => { const value = Maybe.match( { Just: n => n.toString(), Nothing: () => 'Nothing to log.', }, mightBeANumber ); console.log(value); }; ``` This is slightly longer to write, but clearer: the more complex the resulting expression, the hairer it is to understand the ternary. Thus, this is especially convenient for times when there is a complex result, e.g. when rendering part of a React component inline in JSX/TSX. @param matcher A lightweight object defining what to do in the case of each variant. @param maybe The `maybe` instance to check. */ export function match<T, A>(matcher: Matcher<T, A>, maybe: Maybe<T>): A; export function match<T, A>(matcher: Matcher<T, A>): (m: Maybe<T>) => A; export function match<T, A>(matcher: Matcher<T, A>, maybe?: Maybe<T>): A | ((m: Maybe<T>) => A) { return maybe !== undefined ? mapOrElse(matcher.Nothing, matcher.Just, maybe) : (curriedMaybe: Maybe<T>) => mapOrElse(matcher.Nothing, matcher.Just, curriedMaybe); } /** Alias for [`match`](#match) */ export const cata = match; /** A value which may (`Just<T>`) or may not (`Nothing`) be present. */ export type Maybe<T> = Just<T> | Nothing<T>; export const Maybe = { Variant, Just, Nothing, isJust, isNothing, just, nothing, of, fromNullable, map, mapOr, mapOrElse, and, andThen, chain, flatMap, or, orElse, unsafelyUnwrap, unsafelyGet, unsafeGet, unwrapOr, getOr, unwrapOrElse, getOrElse, toOkOrErr, toOkOrElseErr, fromResult, toString, match, cata, }; export default Maybe; |


Every day, close to 2000 Nepalis leave Kathmandu for temporary jobs in the Gulf Countries and East Asia. Many of these young workers struggle to obtain information on the complex process of migration and its many pitfalls, leaving them vulnerable to labor exploitation, human trafficking, and financial distress.
With Nepal's mobile phone penetration already over 100%, we believe mobile devices hold tremendous potential to help migrants stay safe. The Shuvayatra mobile app connects users to an ever-expanding trove of multimedia content supplied by a consortium of experts, advocates, and peers. Migrants can access quick capsules of relevant information on a range of topics, including:
Shuvayatra’s live streaming model gives users a dynamic link to timely, relevant information on the migration process, all in local Nepali languages.
Our partners bring decades of experience working on migration issues in Nepal, and we make sure all of Shuvayatra’s content is accurate and helpful to migrants.
Through its in-app social media and sharing features, Shuvayatra puts the combined knowledge of the global Nepali diaspora in the hands of migrant workers.
Shuvayatra is backed by The Asia Foundation, the Non-Resident Nepali Association, and a dedicated consortium of innovators and social entrepreneurs in Nepal. In 2016, the team will be working to add new features to the application and expand Shuvayatra’s impact. Keep up with our progress by following us on social media, or contact us directly through the link below.
We welcome collaboration at every stage of the process, and if you share our vision for real change and our passion for sustainable solutions, we want to work with you. Core support to the development team will add real, tangible value to the Shuvayatra app, and help improve the lives of Nepalis around the world. We invite you to join us in supporting Nepali migrant workers at home and abroad.


Previous: Lists as Sets, Up: Conses as Lists
Except as explicitly specified otherwise, any standardized function that takes a parameter that is required to be a list should be prepared to signal an error of type type-error if the value received is a dotted list.
Except as explicitly specified otherwise, for any standardized function that takes a parameter that is required to be a list, the consequences are undefined if that list is circular.


49+ Tecban Logo Png Pics. By downloading this vector artwork you agree to the. Vector + high quality images (.png).
I don't have the rights for the image. Search more hd transparent logo image on kindpng. 4,000+ vectors, stock photos & psd files.
More icons from this author.
Here on free pngs you can browse and download 70,000+ free transparent png images straight to your desktop. ✓ free for commercial use ✓ high quality images. Download free tecban logo vector logo and icons in ai, eps, cdr, svg, png formats. Find over 100+ of the best free logo png images.


Featured
HBO Receives 28 Guild Nominations
Game of Thrones Wins Best Drama
The Official Viewers's Guide
Explore more about Game of thrones Season 7


This is the index.html file in the dir-with-index directory.
index.html
dir-with-index
An example text file.
Home