pegeler / eddington2 Goto Github PK
View Code? Open in Web Editor NEWCalculating your Eddington Number for Cycling ๐ฒ๐
Home Page: https://eddington.bike
License: GNU General Public License v3.0
Calculating your Eddington Number for Cycling ๐ฒ๐
Home Page: https://eddington.bike
License: GNU General Public License v3.0
ignore
The minimum R >=4.3.0 is unusual. Why is it necessary?
The hash map of ride history is just a pointer (Rcpp::XPtr
) to a std::unordered_map
. So if a user attempts to save the Eddington
class using save()
or saveRDS()
, they will be disappointed when reloading data since the pointer will be nil
and the data will be lost.
This means that in current-state, several functions will not work as intended when attempting to manipulate the same object between sessions. Some will error silently (like the update()
method) and others will raise an error (like attempting to access the H
active field).
Related to #3
Using the clone()
or clone(deep = TRUE)
method will result in the internal hashmap pointing to the same memory address. Therefore, changes made to any of these objects will propagate to others.
# Random data
rides <- rgamma(15, shape = 2, scale = 10)
# Make shallow and deep clones
e <- Eddington$new(rides)
e$H
## ride_length ride_count
## 1 11 1
## 2 12 2
## 3 13 1
## 4 16 2
## 5 19 1
## 6 36 1
## 7 37 1
## 8 47 1
foo <- e$clone()
bar <- e$clone(TRUE)
# See that the pointer for each hashmap is the same
e$.__enclos_env__$private$.H
## <pointer: 0x0123456789ab>
foo$.__enclos_env__$private$.H
## <pointer: 0x0123456789ab>
bar$.__enclos_env__$private$.H
## <pointer: 0x0123456789ab>
# Update data in 'e' ONLY
e$update(rep(50,50))
# Hashmap has been updated for clones as well
e$H
## [1] ride_length ride_count
## <0 rows> (or 0-length row.names)
foo$H
## [1] ride_length ride_count
## <0 rows> (or 0-length row.names)
bar$H
## [1] ride_length ride_count
## <0 rows> (or 0-length row.names)
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.