philipce / nifty Goto Github PK
View Code? Open in Web Editor NEWNumerical computing in Swift – for Linux and macOS
License: Apache License 2.0
Numerical computing in Swift – for Linux and macOS
License: Apache License 2.0
It appears that commit 5574e0b
makes it so that travis thinks that randn is broken even though that test is unimplemented.
In the “isEqual” function, tolerance is a parameter of the function. We can actually do better, using “ulp”.
They talked a bit about this in the 34th episode of Swift Unwrapped. In the shownotes there are two articles written by Jesse Squires where he talks about this in more detail.
What “ulp” is, in a nutshell, is a floating point value that shows you the next representable number at that level of precision. This will allows us to fine-tune any check that looks for floating point equality — not only looking for exact word equality, but rather by looking +- ulp (or wider, as needed) around the numbers.
The installation instructions tell me to use the included project file if I'm using Xcode, but it doesn't say which project file, so I'm assuming I should clone the project, build and use the Nifty.framework.
So I tried that, but I get the following errors:
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/_fft.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/_cumsum.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/_sort.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/find.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/interp1.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/_poly.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/_cumprod.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/_repmat.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/TimeFrame.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/_linspace.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/_shuffle.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/_ifft.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/TimeSeries.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/DataFrame.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/DataSeries.swift'
<unknown>:0: error: no such file or directory: '/Users/rodrigoruiz/Downloads/Nifty/Sources/_meshgrid.swift'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
In this repository and in the documentation
brew install homebrew/dupes/lapack homebrew/science/openblas
should now be
brew install homebrew/homebrew-core/lapack homebrew/homebrew-core/openblas
Thinking back to our discussion about precondition vs throwing... maybe a there's a better option than both. What if nifty provides a global logging object (similar to python logging) that allows for logging levels debug, info, warning, error, critical. These print the message to the console, to a file, etc depending on what the user has set. They could also have a handler, e.g. the user can pass a closure to execute on occurrence of a particular event. By default, the critical handler is print the message, log to file, then fatalError(). Then, instead of precondition, our errors just use the logger, e.g. log.critical("Matrix is not invertible")
. In our tests then we can override the default handler to set a flag so we can effectively test for precondition... Thoughts?
I recently listened to episode 54 of the Swift Coders Podcast, with Robert Widmann, a Core Team intern. Robert (aka CodaFi) recommended Property Testing, which is like an upgraded form of Unit Testing.
The idea is to automatically create random instances for testing, instead of making them by hand. You can also restrict how they are made, of course. He recommended also SwiftCheck
, which is basically Property Testing for Swift... and maintained by him 😄
What do you think of it? After playing with the refactoring of the Vector, Matrix and Tensor structs, I'll make some tests with this and see how it goes. I think it could be marvelous to find small bugs in the implementation, that would usually go under the radar with the unit tests :)
Hi. I am a graphic designer. I volunteer to design a logo for open source projects. I can design it for you to use it in the readme file. What dou you say?
Apple has mean calculation for vectors in Accelerate. We should use this for a potential speedup. https://developer.apple.com/reference/accelerate/1449980-vdsp_meanv?language=objc
To finish the idea we started on #24.
I tried to make that Refactor work, and I think it may be close to finished. Tha said, it has some weird behavior and introduces strange complexities with the Associated Types that come in the Tensor Protocol.
Maybe the Generics on Swift aren’t ready for such a refactor to be worth its weight yet. Maybe this code duplication is better than pure DRY since it’s much easier to read and to predict its behavior.
I don’t know. We can always refactor it later, specially if we have good tests (which I’m formalizing in another issue).
What do you think?
This is the start of a list of the basic, most essential features from pandas that we want to include in the nifty series/frame:
Near-term:
Long-term:
Glad to see you made it through exams and had some time to travel!
Sorry I've been absent. I've been making some big life changes--moving house, jobs, and other great things. I'll be getting back to Nifty in the next week or two for real. Here are the things I'm planning to work on (in no particular order):
When all that's done, I'd like to make a real v1.0 release (I know, I know, there's already a 1.0--I have to delete that and do like a 0.9 or something while we finish up) and then I'd like to solicit some support for the project--post to the swift-users list, on reddit, etc. But before that, I'd like to get it to a more consumable state, which I think is covered between what you've talked about and the stuff I just mentioned.
Anyway, happy coding! Anything I can do to help you, just ask! I'm by no means an expert on tensors and such but I'm happy to chat/skype/whatever and discuss whatever--this is a learning experience for me too!
Not a pressing issue but I was just thinking that my original thoughts on how to save these data structures to file are a little off. Instead of saving values to file such that shape can be inferred (e.g. columns are separated by commas, rows by newlines, pages by semicolons, etc.), we should just be explicit about the shape, then store everything in row major order. So some format like:
tensorName:3,4,6,2:0.456,234.4,234,567,143, ...
We can have the name (and any other meta data), the shape, and then the comma separated values can easily be shoved into the tensor's array for easy creation.
Then, perhaps each object is separated by semi colons. So the whole file may encode a bunch of variables. Then importing a file would put all the variables in a dict, for easy access.
We loose the readability of a nice csv... but I don't think a 3+ dimensional tensor is readable anyway... plus, the description computed property is readable anyway.
It would be cool to allow specifying whether your matrix should be stored row major or column major order (right now we just do row major).
This could be useful for a number of reasons. Right now though, I'm thinking it would be cool to default to column-major order on xcode builds. The lapack interface in the Accelerate framework doesn't give an option to have row major, so we end up transposing before and after certain operations, which is wasteful. If it were column major by default, we'd only have to do the extra transposes if the user specifically requested row major.
I think right now, slicing a Matrix returns a new Matrix containing the sliced elements. I think we want to return a view so that I can slice a Matrix, do the operation on the slice, and have that reflected in the original matrix (in the same way that numpy does).
As far as I can see, there is no way to initialize the random number generators that underlie the rand(), randn() and randi() functions with a seed. It is possible to pass a seed as a parameter, but this means that repeated calls to these functions will always yield the same result.
What I would like to be able to so is to initialize the RNG once with a seed, which would make subsequent calls to any of the rand() functions deterministic.
When you see T, M and V, they appear to be almost the same thing, if you judge them by their properties:
@Tensor
/// Number of elements in the tensor.
public let count: Int
/// Number of elements in each dimension of the tensor.
public var size: [Int]
/// Data contained in tensor in row-major order.
public var data: [T]
/// Optional name of tensor (e.g., for use in display).
public var name: String?
/// Determine whether to show name when displaying tensor.
public var showName: Bool
/// Formatter to be used in displaying tensor elements.
public var format: NumberFormatter
@Matrix
/// Number of elements in the matrix.
public let count: Int
/// Number of [rows, columns] in the matrix.
public var size: [Int]
public var rows: Int { return self.size[0] }
public var columns: Int { return self.size[1] }
/// Data contained in matrix in row-major order.
public var data: [T]
/// Optional name of matrix (e.g., for use in display).
public var name: String?
/// Determine whether to show name when displaying matrx.
public var showName: Bool
/// Formatter to be used in displaying matrix elements.
public var format: NumberFormatter
@Vector
/// Number of elements in vector.
public let count: Int
/// Data contained in vector.
public var data: [T]
/// Optional name of vector for use in display
public var name: String?
/// Determine whether to show name when displaying matrx.
public var showName: Bool
/// Formatter to be used in displaying matrix elements.
public var format: NumberFormatter
For better maintainability, shouldn't they share more code? By means of a protocol, for example. This would help with not only maintenance, it would also help with testing and functions by joining together test cases and functions that are basically the same across types (see the mean
function for example).
Btw, I like this project because it actually works in Linux 😄 I wanna help with this in my spare time
Since Nifty deals with simple structs with many functions and properties, it’s close to being perfect for Property Testing.
This issue consists on enhancing some of the already-in-place coverage with Properties by using SwiftCheck. This library allows us to express properties using First Order Logic, which is quite powerful.
I was wondering about this. Do we have one? We should have one to start making tasks and crossing them out :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.